Skip to content
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

Partial unpacking in return, yield, and for before Python 3.9 #16560

Open
ntBre opened this issue Mar 7, 2025 · 0 comments
Open

Partial unpacking in return, yield, and for before Python 3.9 #16560

ntBre opened this issue Mar 7, 2025 · 0 comments
Labels
parser Related to the parser rule Implementing or modifying a lint rule

Comments

@ntBre
Copy link
Contributor

ntBre commented Mar 7, 2025

I made this a sub-issue of #6591 for easier discussion, but I ran into the fact that syntax like this:

def f(): return 1, (*rest)
def g(): yield 1, (*rest)
for _ in  1, (*rest): ...

is allowed on Python 3.7 and 3.8 but not on 3.9 while working on #16485 and then again on #16558.

We actually already emit a normal parse error for this, so the change I guess we'd need is more like skipping the existing ParseError based on the version rather than adding an UnsupportedSyntaxError.

On the other hand, this only affects Python versions before 3.9, which are no longer supported. I'm leaning toward just removing this from #6591 and considering it finished without this check, but I wanted to get some other thoughts on this too.

That approach also raises the question of whether we should have taken the same approach with the parenthesized keyword argument names in #16482. That's the only other example of removed syntax in #6591, unless I'm missing another case in my unmerged PRs. We could just emit a ParseError for that and not worry about removed syntax for versions before 3.9.

For the partial unpacking case, specifically, I also didn't find any documentation about that change, so I think it just fell out of the PEG parser change in 3.9.

@ntBre ntBre changed the title def i(): return 1, (*rest) is no longer allowed (something with *rest) Partial unpacking in return, yield, and for before Python 3.9 Mar 7, 2025
@ntBre ntBre added rule Implementing or modifying a lint rule parser Related to the parser labels Mar 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
parser Related to the parser rule Implementing or modifying a lint rule
Projects
None yet
Development

No branches or pull requests

1 participant