-
Notifications
You must be signed in to change notification settings - Fork 219
Closed
astral-sh/ruff
#22836Labels
Description
Summary
Observed behavior:
ty correctly raises an invalid-argument-type error when using a Protocol in an isinstance() check, but doesn't raise the same error when an equivalent runtime check is done with match:
from dataclasses import dataclass
from typing import Any, Protocol
class Foo(Protocol):
foo: str
@dataclass
class ImplFoo:
foo: str = "bar"
def isinstance_check(input: Any) -> None:
if isinstance(input, Foo):
input.foo
def match_check(input: Any) -> None:
match input:
case Foo():
input.foo
isinstance_check(ImplFoo())
match_check(ImplFoo())In the above code, ty raises one error.
Expected Behavior:
ty should raise the same error on the match structure, since it raises the same runtime error. mypy misses this as well, but pyright catches it.
Version
0.0.10
Reactions are currently unavailable