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 with type() #5573

Closed
KalleDK opened this issue Jul 25, 2023 · 3 comments
Closed

Pattern Matching with type() #5573

KalleDK opened this issue Jul 25, 2023 · 3 comments
Labels
addressed in next version Issue is fixed and will appear in next published version bug Something isn't working

Comments

@KalleDK
Copy link

KalleDK commented Jul 25, 2023

Environment data

  • Language Server version: 2023.7.31 (pyright b917b7a)
  • OS and version: WSL2 Debian
  • Python version (& distribution if applicable, e.g. Anaconda): 3.11

Code Snippet

y = str

match y:
    case type(): # <-- This line complains - Pattern will never be matched for subject type "y"
        print(8)
    case _:
        pass
@rchiodo
Copy link
Collaborator

rchiodo commented Jul 25, 2023

Thanks for the issue. Took me a bit to see the error. Requires turning on reportUnnecessaryComparison.

image

Seems like a core type checking issue. Transferring to Pyright.

@rchiodo rchiodo transferred this issue from microsoft/pylance-release Jul 25, 2023
@rchiodo rchiodo removed their assignment Jul 25, 2023
@erictraut erictraut added the bug Something isn't working label Jul 25, 2023
erictraut pushed a commit that referenced this issue Jul 25, 2023
…d class is `type()` or a subtype thereof and the subject contains a `type[X]` whose metaclass potentially matches the pattern. This addresses #5573.
erictraut added a commit that referenced this issue Jul 25, 2023
…d class is `type()` or a subtype thereof and the subject contains a `type[X]` whose metaclass potentially matches the pattern. This addresses #5573. (#5576)

Co-authored-by: Eric Traut <erictr@microsoft.com>
@erictraut erictraut added the addressed in next version Issue is fixed and will appear in next published version label Jul 25, 2023
@erictraut
Copy link
Collaborator

Thanks for the bug report. This will be addressed in the next release.

@erictraut
Copy link
Collaborator

This is addressed in pyright 1.1.319, which I just published. It will also be included in a future release of pylance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addressed in next version Issue is fixed and will appear in next published version bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants