Skip to content

Cannot combine iterables of Callable classes #19091

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
benjaminglass1 opened this issue May 15, 2025 · 0 comments
Open

Cannot combine iterables of Callable classes #19091

benjaminglass1 opened this issue May 15, 2025 · 0 comments
Labels
bug mypy got something wrong topic-join-v-union Using join vs. using unions

Comments

@benjaminglass1
Copy link

benjaminglass1 commented May 15, 2025

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.
@benjaminglass1 benjaminglass1 added the bug mypy got something wrong label May 15, 2025
@JelleZijlstra JelleZijlstra added the topic-join-v-union Using join vs. using unions label May 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong topic-join-v-union Using join vs. using unions
Projects
None yet
Development

No branches or pull requests

2 participants