Improve ast types; revert several "redundant numeric union" changes from #7906 (#9130)

* Adapt number types in ast

Since mypy  0.990 type promotions was limited.
This means that complex is not longer promoted to int/float, therefore
we should adapt the types to list all possible types

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: AlexWaygood <alex.waygood@gmail.com>
This commit is contained in:
kasium
2022-11-14 10:41:23 +01:00
committed by GitHub
parent 892bc0283a
commit f9cd5ee859
7 changed files with 10 additions and 8 deletions

View File

@@ -10,7 +10,7 @@ from google.protobuf.message import Message
_T = TypeVar("_T")
_K = TypeVar("_K", bound=bool | int | str)
_ScalarV = TypeVar("_ScalarV", bound=bool | float | str | bytes)
_ScalarV = TypeVar("_ScalarV", bound=bool | int | float | str | bytes)
_MessageV = TypeVar("_MessageV", bound=Message)
_M = TypeVar("_M")

View File

@@ -69,7 +69,7 @@ paMacCoreStreamInfo: PaMacCoreStreamInfo
# Auxiliary types
_ChannelMap: TypeAlias = Sequence[int]
_PaHostApiInfo: TypeAlias = Mapping[str, str | int]
_PaDeviceInfo: TypeAlias = Mapping[str, str | float]
_PaDeviceInfo: TypeAlias = Mapping[str, str | int | float]
_StreamCallback: TypeAlias = Callable[[bytes | None, int, Mapping[str, float], int], tuple[bytes | None, int]]
def get_format_from_width(width: int, unsigned: bool = ...) -> int: ...

View File

@@ -238,7 +238,7 @@ class Repr(expr):
value: expr
class Num(expr):
n: complex
n: int | float | complex
class Str(expr):
s: str | bytes

View File

@@ -257,7 +257,7 @@ class Call(expr):
keywords: list[keyword]
class Num(expr):
n: complex
n: int | float | complex
class Str(expr):
s: str