Closed LeeeeT closed 2 weeks ago
see #62
it's covariant because it's safe. the only case in which it would be unsafe is when someone writes a __getitem__
/get
, disables the error that mypy produces, and then additionally misuses the input value in an unsafe way:
thanks for looking into basedmypy, if you have any questions i'm happy to discuss. we also have a discord if your interested
Do I understand this correctly? Every time someone tries to write a __getitem__
/ get
mypy will produce an error (more like a warning) and if they are sure the usage is safe they can ignore the error in this case, right?
yes, that's correct. although it is most definitely an error (albeit with a lengthy note), we don't emit warnings yet
not entirely correct though, the author is entirely free to write a get
that does not use any type parameters and opt for object
if they wish. you won't receive an error in this case
Thanks for the explanation ❤️
Describe the problem
Why is
Mapping
s key type made covariant? This is already discussed and showed to be unsafe in https://github.com/python/typing/pull/273. This contradicts type theory.Gist to reproduce
No response
Severity
annoying but i can live with it
Your Environment
No response