-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed as not planned
Labels
bugmypy got something wrongmypy got something wrong
Description
It seems that Mapping[k, v] is invariant to k, but not when a dict literal is passed.
To Reproduce
https://mypy-play.net/?mypy=latest&python=3.11&gist=4195e62f5ea8fa4b027988aa9174bb7c
main.py:25: error: Argument 1 to "test_map_key" has incompatible type "Mapping[str, int]"; expected "Mapping[str | int, Any]" [arg-type]
- Why is this an error? Mapping is immutable so it shouldn't matter that the passed key is more constrained that what is expected.
- Why does passing a dict literal work?
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrong