Skip to content

match-case class checking against collection.abc.Callable raises error [misc] #14014

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

Open
randolf-scholz opened this issue Nov 5, 2022 · 2 comments
Labels
bug mypy got something wrong topic-match-statement Python 3.10's match statement

Comments

@randolf-scholz
Copy link
Contributor

Bug Report

trying to match-case by class collections.abc.Callable raises

error: Expected type in class pattern; found "typing._SpecialForm" [misc]

To Reproduce

https://mypy-play.net/?mypy=master&python=3.10&gist=29d49c837fadc7e404ea295c82d0d28a

from collections.abc import *

x = {1:1}

match x:
    case Mapping():
        print("Mapping")
    case Sequence():
        print("Sequence")
    case Callable():  # ✘ error: Expected type in class pattern [misc]
        print("Callable")

Expected Behavior

Given that collection.abc classes are isinstance-checkable, and it works with the others it should work here as well.

Your Environment

Tested with 0.981, 0.982 and master branch

https://mypy-play.net/?mypy=master&python=3.10&gist=29d49c837fadc7e404ea295c82d0d28a

@randolf-scholz randolf-scholz added the bug mypy got something wrong label Nov 5, 2022
@randolf-scholz
Copy link
Contributor Author

randolf-scholz commented Mar 3, 2023

Still present in mypy≥1.0, python 3.11: https://mypy-play.net/?mypy=1.0.0&python=3.11&gist=80dc9ebaf3f4a35b2b2843d504e76e53

@AlexWaygood AlexWaygood added the topic-match-statement Python 3.10's match statement label Mar 3, 2023
@randolf-scholz
Copy link
Contributor Author

Could this be related to #11673 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong topic-match-statement Python 3.10's match statement
Projects
None yet
Development

No branches or pull requests

2 participants