python / python/mypy

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

Open
#18,796 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
20.6k
Forks
3.3k
PR merge metrics
PR metrics pending

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the main.py reproducer and the linked mypy-play example, using Python 3.13 and the latest mypy version. Trace how isinstance() handles collections.abc.Callable and compare it with callable() type narrowing. Done means the example produces no arg-type error and narrows the value to a callable subtype.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
compilers, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.