mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-09 21:46:42 +08:00
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:
@@ -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: ...
|
||||
|
||||
Reference in New Issue
Block a user