-
Notifications
You must be signed in to change notification settings - Fork 225
Closed
astral-sh/ruff
#20165Labels
Description
Summary
Wasn't able to find this, but apologies if it's already been brought up in another issue, but this is more or less a rehash of python/mypy#17421 for Ty.
In effect Ty doesn't raise a warning if you pass in an class implementation that enforces positional arguments on a method, for a protocol that does not.
Take this example, which should raise a warning but doesn't:
from typing import Protocol
class Readable(Protocol):
def read(self, n: int = -1) -> bytes: ...
class ActualReadable:
def read(self, n: int = -1, /) -> bytes:
return b""
def foo(readable: Readable) -> None:
readable.read(n=1)
foo(ActualReadable())This can lead to a runtime error if the protocol implementation is called using a key-word argument.
If this is simply the result of support for protocols not being finalized, feel free to close this.
Reactions are currently unavailable