Skip to content

isinstance(..., collections.abc.Callable) complains about "_SpecialForm" #6864

Closed
@asottile

Description

@asottile

input

from collections.abc import Callable

def f(): pass

print(isinstance(f, Callable))

output

$ mypy t.py
t.py:5: error: Argument 2 to "isinstance" has incompatible type "_SpecialForm"; expected "Union[type, Tuple[Union[type, Tuple[Any, ...]], ...]]"
$ mypy --version
mypy 0.701

fix (for me)

the fix for me is to just use callable(...), however in some cases this wasn't possible and so for now I'm # type: ignoreing

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions