-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Open
Labels
bugmypy got something wrongmypy got something wrong
Description
This behaves as expected: https://mypy-play.net/?mypy=latest&python=3.12&gist=8718e96550599dc3ae48a13879005762
from typing import Mapping, Never
def upcast(d: dict[Never, Never]) -> Mapping[str, object]:
return d # E: [return-value] (✅ expected)
But it breaks here (due to caching?) https://mypy-play.net/?mypy=latest&python=3.12&gist=6199ba50b6b02e2350e70cb3a8ff4bba
from typing import Mapping, Never
def get[M: Mapping[str, object]](arg: M, /) -> M:
return arg
reveal_type(get({})) # dict[Never, Never] (❌ incorrect)
def upcast(d: dict[Never, Never]) -> Mapping[str, object]:
return d # <-- No error anymore 😱
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrong