mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-07 04:34:28 +08:00
Simplify and correct many numeric unions (#7906)
Unblocks PyCQA/flake8-pyi#222
This commit is contained in:
@@ -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]: ...
|
||||
|
||||
@@ -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]):
|
||||
|
||||
@@ -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: ...
|
||||
|
||||
@@ -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: ...
|
||||
|
||||
@@ -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]
|
||||
|
||||
|
||||
@@ -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: ...
|
||||
|
||||
@@ -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]
|
||||
else:
|
||||
def seed(self, a: Any = ..., version: int = ...) -> None: ...
|
||||
|
||||
|
||||
@@ -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: ...
|
||||
|
||||
@@ -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: ...
|
||||
|
||||
@@ -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: ...
|
||||
|
||||
|
||||
@@ -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: ...
|
||||
|
||||
@@ -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")
|
||||
|
||||
|
||||
@@ -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]): ...
|
||||
|
||||
@@ -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: ...
|
||||
|
||||
@@ -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: ...
|
||||
|
||||
@@ -237,7 +237,7 @@ class Repr(expr):
|
||||
value: expr
|
||||
|
||||
class Num(expr):
|
||||
n: int | float | complex
|
||||
n: complex
|
||||
|
||||
class Str(expr):
|
||||
s: str | bytes
|
||||
|
||||
@@ -252,7 +252,7 @@ class Call(expr):
|
||||
keywords: list[keyword]
|
||||
|
||||
class Num(expr):
|
||||
n: float | int | complex
|
||||
n: complex
|
||||
|
||||
class Str(expr):
|
||||
s: str
|
||||
|
||||
Reference in New Issue
Block a user