`isinstance(_, Callable)` reports `[arg-type]`
Nobody has claimed this yet.
- 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
_: Tis 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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