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

Pattern matching throws false positive F821 when the value comes from the pattern #3103

Closed
Vegemash opened this issue Feb 21, 2023 · 1 comment

Comments

@Vegemash
Copy link

Woo pattern matching! Thank you for supporting 99% of our codebase, here's some bugs :P

class TheEyesHaveIt:
    def __init__(self, i=None, eye=None):
        self.i = i
        self.eye = eye


def match_the_thing(thing: TheEyesHaveIt) -> None:
    match thing:
        case TheEyesHaveIt(i=value) if value:
            print(f"The i's have it at {value}")
        case TheEyesHaveIt(eye=value) if value:
            print(f"The eyes have it at {value}")


a = TheEyesHaveIt(eye="foo")
b = TheEyesHaveIt(i="bar")
match_the_thing(a)
match_the_thing(b)

All those values are marked as undefined names "F821 Undefined name `value`".

@charliermarsh
Copy link
Member

I think these were fixed by #3098, but I'll double check.

I'll probably cut a new release today to get that out.

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