Skip to content

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

Description

@randolf-scholz

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrongtopic-match-statementPython 3.10's match statement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions