You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Seemingly erroneous incompatible type "list[int]"; expected "Iterable[Never]" #16788
Expected Behavior
I expected no errors. I expected [1, 2] to match Iterable[T] with T = int.
Actual Behavior
example.py:6: note: Revealed type is "Union[T`-1, typing.Iterable[T`-1]]"
example.py:11: error: Argument 1 to "coerce_list" has incompatible type "list[int]"; expected "Iterable[Never]" [arg-type]
Found 1 error in 1 file (checked 1 source file)
I'm confused why the revealed type of x looks to be correct (although I don't understand the -1 part), but the expected type of the parameter is Iterable[Never].
Your Environment
Mypy version used: mypy 1.8.0 (compiled: yes)
Mypy command-line flags: (none)
Mypy configuration options from mypy.ini (and other config files): (none)
Python version used: 3.11.2 (Debian 12)
Reacted by Dan Costello, Bin Fu, Roberto Fernández Iglesias, Guillaume Algis, Sadra Barikbin, Tom Howard, Máté Gyöngyösi, Alexis, Zev Isert, Wok and 2 more
Activity
AlejandroFrias commentedon Jan 31, 2026
I was having basically the exact same error for a very similar kind of function.
This type hinting helps it pass static type checks: