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

False positive on match with object's attribute #1414

Closed
Akomer opened this issue Dec 27, 2022 · 2 comments
Closed

False positive on match with object's attribute #1414

Akomer opened this issue Dec 27, 2022 · 2 comments

Comments

@Akomer
Copy link

Akomer commented Dec 27, 2022

I got a false positive SyntaxError in case i am using the match on an object's attribute:

class A:
    var1 = 5


def false_positive_case():
    a = A()
    match a.var1:
        case 5:
            print('easy match')
        case _:
            print('sad')


def okay_case():
    a = [1, 2, 3]
    match a:
        case [v1, v2, *_]:
            print('easy matcH:', v1, v2)


if __name__ == '__main__':
    false_positive_case()
    okay_case()
ruff ruff_match.py
ruff_match.py:7:12: E999 SyntaxError: invalid syntax. Got unexpected token 'a'
Found 1 error(s).

versions:
Python 3.10.6
ruff 0.0.196

@charliermarsh
Copy link
Member

Sadly, we don't yet support structural pattern matching (see: #282). It's the one language feature that we're still working on.

@charliermarsh
Copy link
Member

Fixed as of v0.0.250 which included match statement support.

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

No branches or pull requests

2 participants