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

@@ -7,8 +7,8 @@ from collections.abc import Awaitable, Callable, Iterable, Sequence, Set as Abst
from dataclasses import Field
from os import PathLike
from types import FrameType, TracebackType
from typing import Any, AnyStr, ClassVar, Generic, Protocol, TypeVar, overload
from typing_extensions import Buffer, Final, Literal, LiteralString, TypeAlias, final
from typing import Any, AnyStr, ClassVar, Generic, Protocol, SupportsFloat, SupportsInt, TypeVar, overload
from typing_extensions import Buffer, Final, Literal, LiteralString, SupportsIndex, TypeAlias, final
_KT = TypeVar("_KT")
_KT_co = TypeVar("_KT_co", covariant=True)
@@ -312,3 +312,7 @@ TraceFunction: TypeAlias = Callable[[FrameType, str, Any], TraceFunction | None]
# https://github.com/microsoft/pyright/issues/4339
class DataclassInstance(Protocol):
__dataclass_fields__: ClassVar[dict[str, Field[Any]]]
# Anything that can be passed to the int/float constructors
ConvertibleToInt: TypeAlias = str | ReadableBuffer | SupportsInt | SupportsIndex | SupportsTrunc
ConvertibleToFloat: TypeAlias = str | ReadableBuffer | SupportsFloat | SupportsIndex