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
Mypy chokes on matching NamedTuple sub-objects in list[Any] member when using said objects: “Argument […] has incompatible type "K"; expected "K"”
#15299
Closed
Fiona-J-W opened this issue
May 24, 2023
· 0 comments
· Fixed by #18663
When matching a member-list that is declared to contain Any (I did not check other types here) with [Type() as value] where Type is a NamedTuple, using that value in a seemingly correct way, will state that the type is incompatible with the needed type, despite them being the same (mypy prints the same name!).
I would expect this to be accepted (which is what happens if you run the code and also what pyright says), but in the unlikely event that this is really intentional, I would expect a better error-message than the one given.
Actual Behavior
demo.py:13: error: Argument 1 to "add" of "set" has incompatible type "K"; expected "K" [arg-type]
Found 1 error in 1 file (checked 1 source file)
Your Environment
Mypy version used: 1.3
Mypy command-line flags: None or --strict (behavior is the same)
Mypy configuration options from mypy.ini (and other config files): None
Python version used: 3.11
The text was updated successfully, but these errors were encountered:
Bug Report
When matching a member-list that is declared to contain Any (I did not check other types here) with
[Type() as value]
whereType
is aNamedTuple
, using that value in a seemingly correct way, will state that the type is incompatible with the needed type, despite them being the same (mypy prints the same name!).To Reproduce
Playground Link
Expected Behavior
I would expect this to be accepted (which is what happens if you run the code and also what pyright says), but in the unlikely event that this is really intentional, I would expect a better error-message than the one given.
Actual Behavior
Your Environment
--strict
(behavior is the same)mypy.ini
(and other config files): NoneThe text was updated successfully, but these errors were encountered: