mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-06 12:14:27 +08:00
builtins: int can accept __trunc__-able (#4665)
Refer to https://docs.python.org/3/reference/datamodel.html#object.__trunc__ Fixes https://github.com/python/mypy/issues/9588 Co-authored-by: hauntsaninja <>
This commit is contained in:
@@ -69,6 +69,9 @@ if sys.version_info >= (3, 9):
|
||||
class _SupportsIndex(Protocol):
|
||||
def __index__(self) -> int: ...
|
||||
|
||||
class _SupportsTrunc(Protocol):
|
||||
def __trunc__(self) -> int: ...
|
||||
|
||||
class _SupportsLessThan(Protocol):
|
||||
def __lt__(self, __other: Any) -> bool: ...
|
||||
|
||||
@@ -182,7 +185,7 @@ class super(object):
|
||||
|
||||
class int:
|
||||
@overload
|
||||
def __new__(cls: Type[_T], x: Union[Text, bytes, SupportsInt, _SupportsIndex] = ...) -> _T: ...
|
||||
def __new__(cls: Type[_T], x: Union[Text, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc] = ...) -> _T: ...
|
||||
@overload
|
||||
def __new__(cls: Type[_T], x: Union[Text, bytes, bytearray], base: int) -> _T: ...
|
||||
if sys.version_info >= (3, 8):
|
||||
|
||||
@@ -69,6 +69,9 @@ if sys.version_info >= (3, 9):
|
||||
class _SupportsIndex(Protocol):
|
||||
def __index__(self) -> int: ...
|
||||
|
||||
class _SupportsTrunc(Protocol):
|
||||
def __trunc__(self) -> int: ...
|
||||
|
||||
class _SupportsLessThan(Protocol):
|
||||
def __lt__(self, __other: Any) -> bool: ...
|
||||
|
||||
@@ -182,7 +185,7 @@ class super(object):
|
||||
|
||||
class int:
|
||||
@overload
|
||||
def __new__(cls: Type[_T], x: Union[Text, bytes, SupportsInt, _SupportsIndex] = ...) -> _T: ...
|
||||
def __new__(cls: Type[_T], x: Union[Text, bytes, SupportsInt, _SupportsIndex, _SupportsTrunc] = ...) -> _T: ...
|
||||
@overload
|
||||
def __new__(cls: Type[_T], x: Union[Text, bytes, bytearray], base: int) -> _T: ...
|
||||
if sys.version_info >= (3, 8):
|
||||
|
||||
Reference in New Issue
Block a user