Skip to content

Check for name capture syntax errors #7128

Open
@BioBox

Description

@BioBox

Current problem

The match keyword is prone to the following misunderstanding that pylint fails to catch:

a = 'a'
b = 'b'
s = 'a'

match s:
    case a:
        pass
    case b:
        pass

It's easy to see this as a correct case statement construct, but Python will actually interpret this as a capture pattern instead of the desired value pattern and respond with SyntaxError: name capture 'a' makes remaining patterns unreachable. Pylint fails to catch this.

Desired solution

There should be an error reported on the 6th line.

Additional context

I'm new to pylint so please correct me if this case is already handled.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions