mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-02 14:52:01 +00:00
![]() ## Summary This commit adds some additional error checking to the parser such that assignments that are invalid syntax are rejected. This covers the obvious cases like `5 = 3` and some not so obvious cases like `x + y = 42`. This does add an additional recursive call to the parser for the cases handling assignments. I had initially been concerned about doing this, but `set_context` is already doing recursion during assignments, so I didn't feel as though this was changing any fundamental performance characteristics of the parser. (Also, in practice, I would expect any such recursion here to be quite shallow since the recursion is done on the target of an assignment. Such things are rarely nested much in practice.) Fixes #6895 ## Test Plan I've added unit tests covering every case that is detected as invalid on an `Expr`. |
||
---|---|---|
.. | ||
carriage_return | ||
expression | ||
fmt_on_off | ||
fmt_skip | ||
parentheses | ||
statement | ||
stub_files | ||
.editorconfig | ||
docstring.options.json | ||
docstring.py | ||
empty_multiple_trailing_newlines.py | ||
empty_now_newline.py | ||
empty_trailing_newline.py | ||
empty_whitespace.py | ||
form_feed.py | ||
module_dangling_comment1.py | ||
module_dangling_comment2.py | ||
newlines.py | ||
newlines.pyi | ||
preview.options.json | ||
preview.py | ||
skip_magic_trailing_comma.options.json | ||
skip_magic_trailing_comma.py | ||
tab_width.options.json | ||
tab_width.py | ||
trailing_comments.py | ||
trivia.py |