Skip to content

Ruff fails to parse WithItem with a starred expression as optional_vars #8914

@LaBatata101

Description

@LaBatata101

Ruff version: v0.1.6

Ruff reports a syntax error for the following code

with 0 as *x: pass

While the python ast module parses with no error.

$ python
Python 3.12.0 (main, Oct  3 2023, 01:27:23) [Clang 17.0.1 ] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ast
>>> print(ast.dump(ast.parse("with a as *a: pass"), indent=4))
Module(
    body=[
        With(
            items=[
                withitem(
                    context_expr=Name(id='a', ctx=Load()),
                    optional_vars=Starred(
                        value=Name(id='a', ctx=Store()),
                        ctx=Store()))],
            body=[
                Pass()])],
    type_ignores=[])
>>>

Playground

Metadata

Metadata

Assignees

Labels

parserRelated to the parser

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions