d or {}
where d
is something other than builtin dict
gets errors about Never
for indexing and splatting
#17790
Labels
bug
mypy got something wrong
Bug Report
When using
d or {}
whered
is a subclass ofdict
or something that implements theSupportsKeysAndGetItem
protocol can lead to errors/different behaviour in downstream code than when it is adict
directly. There errors are things indicating theNever
key type of{}
is causing problem:This is potentially the same as #17684, but felt different.
(As always, thanks for Mypy!)
To Reproduce
https://mypy-play.net/?mypy=latest&python=3.12&gist=a7075c4918e6e95f4f9429bd261aa4c0
Expected Behavior
I'd expect the subclass and
SupportsKeysAndGetItem
-implementing type to behave the same as the normaldict
instance, where theNever
key arg is unified and/or ignored appropriately.Actual Behavior
Your Environment
mypy.ini
(and other config files): N/AThe text was updated successfully, but these errors were encountered: