-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SyntaxError in Python 3.11 when unpacking sequences inside of [] #2321
Comments
Oh just occurred to me, would this be better submitted to the RustPython project? |
Oh interesting! Yes, I think this would be at-home on RustPython. Do you mind filing there? |
Done: RustPython/RustPython#4479 As I mention in that issue, I wonder if it's related to the new Also, maybe this issue should then should really be about the fact that ruff doesn't support the |
Ok so it turns out this is an expected change in 3.11, but it wasn't called out in the changelog. See the section Change 1: Star Expressions in Indexes in PEP 646, which was accepted for 3.11. |
The parser parts are resolved |
@charliermarsh, I'm still getting an error when trying to annotate def f(*args: *tuple[int]) -> None: ...
Although, this is a valid syntax according to PEP 646, and it passes static type checking using Pyright. ruff 0.0.252 |
Moreover, Ruff seems not to support exception groups. print(ExceptionGroup)
Should I create a separate issue for this? |
Thanks @LeeeeT, can you file a separate issue for the |
Thank you for fixing it so quickly! ❤️ |
Ruff version: 0.0.237
Python version: 3.11.1
Command run:
Contents of
code.py
:This is valid Python 3.11 code, with the string
'ab'
being unpacked into a tuple, resulting the in they key with tuple('a','b')
being assigned a value of1
. The above invocation of ruff however throws this error:The snippet itself doesn't work in Python 3.9 or 3.10 (throwing SyntaxErrors), so this seems like a syntax enhancement in 3.11 that should be supported. That said, I can't find where this is documented as a change in 3.11. All I can see is this reference to Starred unpacking expressions can now be used in for statements. , which references this CPython issue, but that looks to be a different context for using
*
, and was only documenting behaviour that changed in 3.9.The text was updated successfully, but these errors were encountered: