mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-27 18:36:23 +00:00
Allow named expressions in __all__ assignments (#7673)
## Summary This PR adds support for named expressions when analyzing `__all__` assignments, as per https://github.com/astral-sh/ruff/issues/7672. It also loosens the enforcement around assignments like: `__all__ = list(some_other_expression)`. We shouldn't flag these as invalid, even though we can't analyze the members, since we _know_ they evaluate to a `list`. Closes https://github.com/astral-sh/ruff/issues/7672. ## Test Plan `cargo test`
This commit is contained in:
parent
fbbc982c29
commit
0a8cad2550
3 changed files with 35 additions and 5 deletions
|
|
@ -106,7 +106,27 @@ invalid_all_format.py:21:1: PLE0605 Invalid format for `__all__`, must be `tuple
|
|||
21 | __all__ = foo["bar"] # [invalid-all-format]
|
||||
| ^^^^^^^ PLE0605
|
||||
22 |
|
||||
23 | __all__ = ["Hello"]
|
||||
23 | __all__ = (foo := bar) # [invalid-all-format]
|
||||
|
|
||||
|
||||
invalid_all_format.py:23:1: PLE0605 Invalid format for `__all__`, must be `tuple` or `list`
|
||||
|
|
||||
21 | __all__ = foo["bar"] # [invalid-all-format]
|
||||
22 |
|
||||
23 | __all__ = (foo := bar) # [invalid-all-format]
|
||||
| ^^^^^^^ PLE0605
|
||||
24 |
|
||||
25 | __all__ = ["Hello"]
|
||||
|
|
||||
|
||||
invalid_all_format.py:23:12: PLE0605 Invalid format for `__all__`, must be `tuple` or `list`
|
||||
|
|
||||
21 | __all__ = foo["bar"] # [invalid-all-format]
|
||||
22 |
|
||||
23 | __all__ = (foo := bar) # [invalid-all-format]
|
||||
| ^^^ PLE0605
|
||||
24 |
|
||||
25 | __all__ = ["Hello"]
|
||||
|
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue