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
When the return type from dict.pop is incompatible with existing variable type, mypy gives an arg-type error when an assignment error seems more intuitive.
example.py:3: error: Incompatible types in assignment (expression has type "int | None", variable has type "int") [assignment]
Actual Behavior
example.py:3: error: Argument 2 to "pop" of "dict" has incompatible type "None"; expected "int" [arg-type]
Note: this is a lot more surprising if value has this type because it was unintentionally reused from some code further up, e.g. if you're using value in a loop or something; it can be very difficult to spot what the real error is. See #10152 (comment) for example.
Your Environment
Mypy version used: 1.13.0
Mypy command-line flags: None
Mypy configuration options from mypy.ini (and other config files): None
Python version used: 3.12.2
The text was updated successfully, but these errors were encountered:
Bug Report
When the return type from
dict.pop
is incompatible with existing variable type, mypy gives anarg-type
error when anassignment
error seems more intuitive.(Originally noted in #10152)
To Reproduce
https://gist.github.com/mypy-play/972f4514ebe5620ece42583192907f62
Expected Behavior
Actual Behavior
Note: this is a lot more surprising if
value
has this type because it was unintentionally reused from some code further up, e.g. if you're usingvalue
in a loop or something; it can be very difficult to spot what the real error is. See #10152 (comment) for example.Your Environment
mypy.ini
(and other config files): NoneThe text was updated successfully, but these errors were encountered: