Skip to content

Commit 3fd2325

Browse files
committed
Merge branches 'fix-type-cast-in-selectors', 'fix-stray-word-in-readme', 'fix-doc-string-spelling-error' and 'fix-issue-3'
4 parents 2b7b40b + 48e8678 + 4104774 + 899509a commit 3fd2325

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ Parsing is offered only in the form of Python modules — no "command-line" prog
7171

7272
### Why?
7373

74-
We wanted a "transparent" CSS parser — one that one could be used in different configurations without it imposing limitations that would strictly speaking go beyond parsing. Put differently, we wanted a parser that does not assume any particular application, a software _library_ in the classical sense of the term, or a true _API_ if you will.
74+
We wanted a "transparent" CSS parser — one that could be used in different configurations without it imposing limitations that would strictly speaking go beyond parsing. Put differently, we wanted a parser that does not assume any particular application, a software _library_ in the classical sense of the term, or a true _API_ if you will.
7575

7676
For instance, the popular [Less](http://lesscss.org) software seems to rather effortlessly parse CSS [3] text, but it invariably re-arranges white-space in the output, without giving the user any control over the latter. Less is not _transparent_ like that — there is no way to use it with recovery of the originally parsed text from the parse tree — parsing with Less is a one-way street for at least _some_ applications (specifically those that "transform" CSS but need to preserve all of the original input as-is).
7777

expand-macros.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
Macro processing refers here to eager rewriting/replacement/substitution of Python code constructs decorated with the "syntactic" (no definition available normally, when the containing module is imported) decorator `macro`. The purpose of such processing is to implement the equivalent to what is usually called "pre-processing" for e.g. C/C++ language(s). As `macro`-decorated procedures (only decorating of procedures is currently effectively supported for `macro`) are encountered during processing of Python code, the entire procedure is removed and "unparsed" equivalent of the series of AST statements it returned, are inserted in its place instead.
44
5-
This implements powerful and "semantically-aware" code pre-processing mechanism, for situations demanding it. Our immediate need with this was to allow type checkers like MyPy to be able to analyze as much of the project's Python code as possible, which these are normally unable to do in cases of so-called dynamically created types (and consequently object(s) of such types). And so instead of living with effectively uncheckable dynamic types created with the `type` built-in -- for e.g. `Token` subclasses -- we employ _pre-processing_ of Python code into Python code which lends to type-checking, a benefit we deemed to ba a "must-have" for the project.
5+
This implements powerful and "semantically-aware" code pre-processing mechanism, for situations demanding it. Our immediate need with this was to allow type checkers like MyPy to be able to analyze as much of the project's Python code as possible, which these are normally unable to do in cases of so-called dynamically created types (and consequently object(s) of such types). And so instead of living with effectively uncheckable dynamic types created with the `type` built-in -- for e.g. `Token` subclasses -- we employ _pre-processing_ of Python code into Python code which lends to type-checking, a benefit we deemed to be a "must-have" for the project.
66
"""
77

88
import ast

src/csspring/syntax/parsing.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,8 @@ def consume_list_of_component_values(input: Input, *, stop_token: type[Token | N
411411

412412
def consume_simple_block(input: Input, *, to: Appender[SimpleBlock]) -> SimpleBlock:
413413
"""Implements http://drafts.csswg.org/css-syntax/#consume-simple-block."""
414-
assert isinstance(token := input.next_token(), (OpenBraceToken, OpenBracketToken, OpenParenToken))
414+
token = input.next_token()
415+
assert isinstance(token, (OpenBraceToken, OpenBracketToken, OpenParenToken))
415416
ending_token = token.mirror_type
416417
block = SimpleBlock()
417418
consume_token(input, to=block)

0 commit comments

Comments
 (0)