Skip to content

isinstance(_, Callable) reports [arg-type] #18796

Open
@jorenham

Description

@jorenham

Bug Report

isinstance(_, collections.abc.Callable) is allowed at runtime, but is reported

(A clear and concise description of what the bug is.)

To Reproduce

from collections.abc import Callable
assert isinstance(int, Callable)

Expected Behavior

for isinstance(_, collections.abc.Callable) to behave identically to callable(_):

  • no error
  • _: T is narrowed to _: <callable subtype of T>

Actual Behavior

main.py:2: error: Argument 2 to "isinstance" has incompatible type "<typing special form>"; expected "_ClassInfo"  [arg-type]

https://mypy-play.net/?mypy=latest&python=3.13&gist=463e1edfbfc8cefc268fce8544b0b49b

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions