Allow math.trunc to only accept __trunc__-supporting objects (#6003)

Add SupportsTrunc protocol
This commit is contained in:
Bas van Beek
2021-09-04 18:16:53 +02:00
committed by GitHub
parent 3819f8e6ff
commit d599a535b2
2 changed files with 5 additions and 1 deletions

View File

@@ -41,6 +41,9 @@ class SupportsLenAndGetItem(Protocol[_T_co]):
def __len__(self) -> int: ...
def __getitem__(self, __k: int) -> _T_co: ...
class SupportsTrunc(Protocol):
def __trunc__(self) -> int: ...
# Mapping-like protocols
# stable