Cannot combine iterables of Callable classes
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
Bug Report
Combining iterables of Callable classes fails type checking. Initially observed in PyTorch, see https://github.com/pytorch/pytorch/pull/153558/files#diff-f6db1b80859c6471ce6e5eb1fc0e31ec094d550e328eeec49076fd346439de91R88
To Reproduce
https://mypy-play.net/?mypy=latest&python=3.13&gist=f51186b431defd72652a9dd1c7ca0b48
Expected Behavior
All assignments in the repro should validate.
Actual Behavior
main.py:15: error: Incompatible types in assignment (expression has type "list[object]", variable has type "list[Callable[..., Any]]") [assignment]
main.py:20: error: Incompatible types in assignment (expression has type "list[object]", variable has type "list[Callable[..., Any]]") [assignment]
Found 2 errors in 1 file (checked 1 source file)
Your Environment
- Mypy version used: 1.15.0, also observed on 1.14.0.
- Python version used: 3.13, observed as far back as 3.9 locally.
- See mypy-play.net repro for any other environment questions.
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 by running the linked mypy-play.net reproduction with mypy 1.15.0 and compare its diagnostics with the expected behavior. Trace the type-checking path for combining iterables of Callable classes; done means all assignments in the reproduction validate without the reported list[object] errors.
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
- 38/100