-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Open
Labels
bugmypy got something wrongmypy got something wrongtopic-match-statementPython 3.10's match statementPython 3.10's match statementtopic-runtime-semanticsmypy doesn't model runtime semantics correctlymypy doesn't model runtime semantics correctly
Description
from typing import Any, Callable, Protocol, runtime_checkable
class Proto(Protocol):
def foo(self, x: int, /) -> object: ...
def test_object(x: object) -> None:
match x:
case Proto() as y: # No Error
reveal_type(y) # N: Revealed type is "__main__.Proto"
if isinstance(x, Proto): # E: Only @runtime_checkable protocols ...
reveal_type(x) # N: Revealed type is "__main__.Proto"
https://mypy-play.net/?mypy=latest&python=3.12&gist=6e3f280e71d3cb4d6131e51496370f97
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongtopic-match-statementPython 3.10's match statementPython 3.10's match statementtopic-runtime-semanticsmypy doesn't model runtime semantics correctlymypy doesn't model runtime semantics correctly