Add typeshed aliases to the types accepted by int and float constructors (#10707)

Ref https://github.com/python/typeshed/pull/10630#discussion_r1321646168
This commit is contained in:
Ali Hamdan
2023-09-23 04:50:43 +02:00
committed by GitHub
parent 381fc572a8
commit 2b323bed50
3 changed files with 13 additions and 15 deletions

View File

@@ -5,6 +5,8 @@ import types
from _collections_abc import dict_items, dict_keys, dict_values
from _typeshed import (
AnyStr_co,
ConvertibleToFloat,
ConvertibleToInt,
FileDescriptorOrPath,
OpenBinaryMode,
OpenBinaryModeReading,
@@ -24,7 +26,6 @@ from _typeshed import (
SupportsRDivMod,
SupportsRichComparison,
SupportsRichComparisonT,
SupportsTrunc,
SupportsWrite,
)
from collections.abc import Awaitable, Callable, Iterable, Iterator, MutableSet, Reversible, Set as AbstractSet, Sized
@@ -48,7 +49,6 @@ from typing import ( # noqa: Y022
SupportsBytes,
SupportsComplex,
SupportsFloat,
SupportsInt,
TypeVar,
overload,
type_check_only,
@@ -221,7 +221,7 @@ _LiteralInteger = _PositiveInteger | _NegativeInteger | Literal[0] # noqa: Y026
class int:
@overload
def __new__(cls, __x: str | ReadableBuffer | SupportsInt | SupportsIndex | SupportsTrunc = ...) -> Self: ...
def __new__(cls, __x: ConvertibleToInt = ...) -> Self: ...
@overload
def __new__(cls, __x: str | bytes | bytearray, base: SupportsIndex) -> Self: ...
if sys.version_info >= (3, 8):
@@ -327,7 +327,7 @@ class int:
def __index__(self) -> int: ...
class float:
def __new__(cls, __x: SupportsFloat | SupportsIndex | str | ReadableBuffer = ...) -> Self: ...
def __new__(cls, __x: ConvertibleToFloat = ...) -> Self: ...
def as_integer_ratio(self) -> tuple[int, int]: ...
def hex(self) -> str: ...
def is_integer(self) -> bool: ...