Skip to content

No syntax error for [(a := ...) for a in b] #14395

@InSyncWithFoo

Description

@InSyncWithFoo

Currently, Ruff accepts this as valid (playground):

[(a := 0) for a in range(0)]

However, it isn't:

$ python -c "[(a := 0) for a in range(0)]"
  File "<string>", line 1
SyntaxError: assignment expression cannot rebind comprehension iteration variable 'a'

Metadata

Metadata

Assignees

No one assigned

    Labels

    ruleImplementing or modifying a lint rule

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions