Skip to content

Simplify and correct many numeric unions #7906

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions stdlib/distutils/filelist.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -17,34 +17,34 @@ class FileList:
def process_template_line(self, line: str) -> None: ...
@overload
def include_pattern(
self, pattern: str, anchor: int | bool = ..., prefix: str | None = ..., is_regex: Literal[0, False] = ...
self, pattern: str, anchor: bool | Literal[0, 1] = ..., prefix: str | None = ..., is_regex: Literal[0, False] = ...
) -> bool: ...
@overload
def include_pattern(self, pattern: str | Pattern[str], *, is_regex: Literal[True, 1] = ...) -> bool: ...
@overload
def include_pattern(
self, pattern: str | Pattern[str], anchor: int | bool = ..., prefix: str | None = ..., is_regex: int | bool = ...
self, pattern: str | Pattern[str], anchor: bool | Literal[0, 1] = ..., prefix: str | None = ..., is_regex: int = ...
) -> bool: ...
@overload
def exclude_pattern(
self, pattern: str, anchor: int | bool = ..., prefix: str | None = ..., is_regex: Literal[0, False] = ...
self, pattern: str, anchor: bool | Literal[0, 1] = ..., prefix: str | None = ..., is_regex: Literal[0, False] = ...
) -> bool: ...
@overload
def exclude_pattern(self, pattern: str | Pattern[str], *, is_regex: Literal[True, 1] = ...) -> bool: ...
@overload
def exclude_pattern(
self, pattern: str | Pattern[str], anchor: int | bool = ..., prefix: str | None = ..., is_regex: int | bool = ...
self, pattern: str | Pattern[str], anchor: bool | Literal[0, 1] = ..., prefix: str | None = ..., is_regex: int = ...
) -> bool: ...

def findall(dir: str = ...) -> list[str]: ...
def glob_to_re(pattern: str) -> str: ...
@overload
def translate_pattern(
pattern: str, anchor: int | bool = ..., prefix: str | None = ..., is_regex: Literal[False, 0] = ...
pattern: str, anchor: bool | Literal[0, 1] = ..., prefix: str | None = ..., is_regex: Literal[False, 0] = ...
) -> Pattern[str]: ...
@overload
def translate_pattern(pattern: str | Pattern[str], *, is_regex: Literal[True, 1] = ...) -> Pattern[str]: ...
@overload
def translate_pattern(
pattern: str | Pattern[str], anchor: int | bool = ..., prefix: str | None = ..., is_regex: int | bool = ...
pattern: str | Pattern[str], anchor: bool | Literal[0, 1] = ..., prefix: str | None = ..., is_regex: int = ...
) -> Pattern[str]: ...
4 changes: 2 additions & 2 deletions stdlib/filecmp.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ __all__ = ["clear_cache", "cmp", "dircmp", "cmpfiles", "DEFAULT_IGNORES"]
DEFAULT_IGNORES: list[str]
BUFSIZE: Literal[8192]

def cmp(f1: StrOrBytesPath, f2: StrOrBytesPath, shallow: int | bool = ...) -> bool: ...
def cmp(f1: StrOrBytesPath, f2: StrOrBytesPath, shallow: bool | Literal[0, 1] = ...) -> bool: ...
def cmpfiles(
a: AnyStr | PathLike[AnyStr],
b: AnyStr | PathLike[AnyStr],
common: Iterable[AnyStr | PathLike[AnyStr]],
shallow: int | bool = ...,
shallow: bool | Literal[0, 1] = ...,
) -> tuple[list[AnyStr], list[AnyStr], list[AnyStr]]: ...

class dircmp(Generic[AnyStr]):
Expand Down
2 changes: 1 addition & 1 deletion stdlib/fractions.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class Fraction(Rational):
@overload
def __pow__(self, b: complex) -> complex: ...
@overload
def __rpow__(self, a: int | float | Fraction) -> float: ...
def __rpow__(self, a: float | Fraction) -> float: ...
@overload
def __rpow__(self, a: complex) -> complex: ...
def __pos__(self) -> Fraction: ...
Expand Down
2 changes: 1 addition & 1 deletion stdlib/ftplib.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class FTP:
def getwelcome(self) -> str: ...
def set_debuglevel(self, level: int) -> None: ...
def debug(self, level: int) -> None: ...
def set_pasv(self, val: bool | int) -> None: ...
def set_pasv(self, val: bool | Literal[0, 1]) -> None: ...
def sanitize(self, s: str) -> str: ...
def putline(self, line: str) -> None: ...
def putcmd(self, line: str) -> None: ...
Expand Down
2 changes: 1 addition & 1 deletion stdlib/itertools.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ _T4 = TypeVar("_T4")
_T5 = TypeVar("_T5")
_T6 = TypeVar("_T6")

_Step: TypeAlias = int | float | SupportsFloat | SupportsInt | SupportsIndex | SupportsComplex
_Step: TypeAlias = SupportsFloat | SupportsInt | SupportsIndex | SupportsComplex

_Predicate: TypeAlias = Callable[[_T], object]

Expand Down
2 changes: 1 addition & 1 deletion stdlib/locale.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ if sys.version_info >= (3, 7):
else:
def format_string(f: _str, val: Any, grouping: bool = ...) -> _str: ...

def currency(val: int | float | Decimal, symbol: bool = ..., grouping: bool = ..., international: bool = ...) -> _str: ...
def currency(val: float | Decimal, symbol: bool = ..., grouping: bool = ..., international: bool = ...) -> _str: ...
def delocalize(string: _str) -> _str: ...
def atof(string: _str, func: Callable[[_str], float] = ...) -> float: ...
def atoi(string: _str) -> int: ...
Expand Down
2 changes: 1 addition & 1 deletion stdlib/random.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class Random(_random.Random):
def __init__(self, x: Any = ...) -> None: ...
# Using other `seed` types is deprecated since 3.9 and removed in 3.11
if sys.version_info >= (3, 9):
def seed(self, a: int | float | str | bytes | bytearray | None = ..., version: int = ...) -> None: ... # type: ignore[override]
def seed(self, a: float | str | bytes | bytearray | None = ..., version: int = ...) -> None: ... # type: ignore[override]
Copy link
Collaborator

@hauntsaninja hauntsaninja May 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one feels a little worse to me in terms of serving as documentation for random.seed, any objections to noqa?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, feel free to revert and add a noqa!

else:
def seed(self, a: Any = ..., version: int = ...) -> None: ...

Expand Down
6 changes: 5 additions & 1 deletion stdlib/turtle.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,11 @@ class _Screen(TurtleScreen):
def __init__(self) -> None: ...
# Note int and float are interpreted differently, hence the Union instead of just float
def setup(
self, width: int | float = ..., height: int | float = ..., startx: int | None = ..., starty: int | None = ...
self,
width: int | float = ..., # noqa: Y041
height: int | float = ..., # noqa: Y041
startx: int | None = ...,
starty: int | None = ...,
) -> None: ...
def title(self, titlestring: str) -> None: ...
def bye(self) -> None: ...
Expand Down
4 changes: 2 additions & 2 deletions stubs/filelock/filelock/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ class _Acquire_ReturnProxy:
) -> None: ...

class BaseFileLock:
def __init__(self, lock_file: str, timeout: float | int | str = ...) -> None: ...
def __init__(self, lock_file: str, timeout: float | str = ...) -> None: ...
@property
def lock_file(self) -> str: ...
@property
def timeout(self) -> float: ...
@timeout.setter
def timeout(self, value: int | str | float) -> None: ... # type: ignore
def timeout(self, value: str | float) -> None: ... # type: ignore
@property
def is_locked(self) -> bool: ...
def acquire(self, timeout: float | None = ..., poll_intervall: float = ...) -> _Acquire_ReturnProxy: ...
Expand Down
2 changes: 1 addition & 1 deletion stubs/opentracing/opentracing/mocktracer/span.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class MockSpan(Span):
@property
def context(self) -> SpanContext: ...
def set_operation_name(self: Self, operation_name: str) -> Self: ...
def set_tag(self: Self, key: str, value: str | bool | int | float) -> Self: ...
def set_tag(self: Self, key: str, value: str | bool | float) -> Self: ...
def log_kv(self: Self, key_values: dict[str, Any], timestamp: float | None = ...) -> Self: ...
def set_baggage_item(self: Self, key: str, value: str) -> Self: ...

Expand Down
2 changes: 1 addition & 1 deletion stubs/opentracing/opentracing/span.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Span:
def tracer(self) -> Tracer: ...
def set_operation_name(self: Self, operation_name: str) -> Self: ...
def finish(self, finish_time: float | None = ...) -> None: ...
def set_tag(self: Self, key: str, value: str | bool | int | float) -> Self: ...
def set_tag(self: Self, key: str, value: str | bool | float) -> Self: ...
def log_kv(self: Self, key_values: dict[str, Any], timestamp: float | None = ...) -> Self: ...
def set_baggage_item(self: Self, key: str, value: str) -> Self: ...
def get_baggage_item(self, key: str) -> str | None: ...
Expand Down
2 changes: 1 addition & 1 deletion stubs/protobuf/google/protobuf/internal/containers.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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 | int | float | str | bytes)
_ScalarV = TypeVar("_ScalarV", bound=bool | float | str | bytes)
_MessageV = TypeVar("_MessageV", bound=Message)
_M = TypeVar("_M")

Expand Down
2 changes: 1 addition & 1 deletion stubs/protobuf/google/protobuf/internal/extension_dict.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ from google.protobuf.message import Message
_ContainerMessageT = TypeVar("_ContainerMessageT", bound=Message)
_ExtenderMessageT = TypeVar(
"_ExtenderMessageT",
bound=Message | RepeatedScalarFieldContainer[Any] | RepeatedCompositeFieldContainer[Any] | bool | int | float | str | bytes,
bound=Message | RepeatedScalarFieldContainer[Any] | RepeatedCompositeFieldContainer[Any] | bool | float | str | bytes,
)

class _ExtensionFieldDescriptor(FieldDescriptor, Generic[_ContainerMessageT, _ExtenderMessageT]): ...
Expand Down
2 changes: 1 addition & 1 deletion stubs/pyaudio/pyaudio.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ paMacCoreStreamInfo: PaMacCoreStreamInfo
# Auxiliary types
_ChannelMap: TypeAlias = Sequence[int]
_PaHostApiInfo: TypeAlias = Mapping[str, str | int]
_PaDeviceInfo: TypeAlias = Mapping[str, str | int | float]
_PaDeviceInfo: TypeAlias = Mapping[str, str | 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: ...
Expand Down
6 changes: 3 additions & 3 deletions stubs/redis/redis/lock.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ class Lock:
self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None
) -> bool | None: ...
def acquire(
self, blocking: bool | None = ..., blocking_timeout: None | int | float = ..., token: str | bytes | None = ...
self, blocking: bool | None = ..., blocking_timeout: float | None = ..., token: str | bytes | None = ...
) -> bool: ...
def do_acquire(self, token: str | bytes) -> bool: ...
def locked(self) -> bool: ...
def owned(self) -> bool: ...
def release(self) -> None: ...
def do_release(self, expected_token: str | bytes) -> None: ...
def extend(self, additional_time: int | float, replace_ttl: bool = ...) -> bool: ...
def do_extend(self, additional_time: int | float, replace_ttl: bool) -> bool: ...
def extend(self, additional_time: float, replace_ttl: bool = ...) -> bool: ...
def do_extend(self, additional_time: float, replace_ttl: bool) -> bool: ...
def reacquire(self) -> bool: ...
def do_reacquire(self) -> bool: ...
2 changes: 1 addition & 1 deletion stubs/typed-ast/typed_ast/ast27.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ class Repr(expr):
value: expr

class Num(expr):
n: int | float | complex
n: complex

class Str(expr):
s: str | bytes
Expand Down
2 changes: 1 addition & 1 deletion stubs/typed-ast/typed_ast/ast3.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ class Call(expr):
keywords: list[keyword]

class Num(expr):
n: float | int | complex
n: complex

class Str(expr):
s: str
Expand Down