Skip to content

Conversation

StanFromIreland
Copy link
Member

@StanFromIreland StanFromIreland commented Aug 31, 2025

The message:

starred assignment target must be in a list or tuple

has been changed for consistency.


>>> *a = range(10) # doctest:+ELLIPSIS
Traceback (most recent call last):
...
SyntaxError: starred assignment target must be in a list or tuple
SyntaxError: starred target must be in a list or tuple
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this one was ok?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docs do use the term starred target, so starred assignment target is both inconsistent/incorrect and longer, though I do not feel strongly about it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The doc uses the shorter term in the context of assignments (right?) Outside that context target could be something else, like a jump target. So I think it may not be clear.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The doc uses the shorter term in the context of assignments

Yes, in both instances of the usage of the term:

Assignment of an object to a target list, optionally enclosed in parentheses or
square brackets, is recursively defined as follows.

...

  • If the target list contains one target prefixed with an asterisk, called a
    "starred" target: The object must be an iterable with ...

Implements assignment with a starred target

We also use the term in codegen to name our variables.


How about we add ... in assignment ... instead, it is consistent with the other error messages, and clarifies the context?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have the same error for

for *a in []: pass

and

with contextlib.nullcontext([]) as *a: pass

So "in assignment" can be confusing.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know now, what message we should use. Any suggestions Serhiy?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants