Enable flake8-pyi's Y037 (#9686)

This commit is contained in:
Alex Waygood
2023-02-07 03:01:02 +00:00
committed by GitHub
parent c4c4bee8aa
commit 0ef9c3f8e8
38 changed files with 119 additions and 201 deletions

View File

@@ -1,6 +1,6 @@
from _typeshed import SupportsWrite
from collections.abc import Iterable, Iterator
from typing import Any, Union
from typing import Any
from typing_extensions import Literal, TypeAlias
__version__: str
@@ -27,7 +27,7 @@ class Dialect:
strict: bool
def __init__(self) -> None: ...
_DialectLike: TypeAlias = Union[str, Dialect, type[Dialect]]
_DialectLike: TypeAlias = str | Dialect | type[Dialect]
class _reader(Iterator[list[str]]):
@property

View File

@@ -3,11 +3,11 @@ import sys
from _typeshed import Self
from collections.abc import Container, Sequence
from types import TracebackType
from typing import Any, ClassVar, NamedTuple, Union, overload
from typing import Any, ClassVar, NamedTuple, overload
from typing_extensions import Literal, TypeAlias
_Decimal: TypeAlias = Decimal | int
_DecimalNew: TypeAlias = Union[Decimal, float, str, tuple[int, Sequence[int], int]]
_DecimalNew: TypeAlias = Decimal | float | str | tuple[int, Sequence[int], int]
_ComparableNum: TypeAlias = Decimal | float | numbers.Rational
__version__: str

View File

@@ -11,7 +11,7 @@ from collections.abc import Awaitable, Callable, Iterable, Set as AbstractSet
from dataclasses import Field
from os import PathLike
from types import FrameType, TracebackType
from typing import Any, AnyStr, ClassVar, Generic, Protocol, TypeVar, Union
from typing import Any, AnyStr, ClassVar, Generic, Protocol, TypeVar
from typing_extensions import Final, Literal, LiteralString, TypeAlias, final
_KT = TypeVar("_KT")
@@ -265,7 +265,7 @@ IndexableBuffer: TypeAlias = bytes | bytearray | memoryview | array.array[Any] |
# def __buffer__(self, __flags: int) -> memoryview: ...
ExcInfo: TypeAlias = tuple[type[BaseException], BaseException, TracebackType]
OptExcInfo: TypeAlias = Union[ExcInfo, tuple[None, None, None]]
OptExcInfo: TypeAlias = ExcInfo | tuple[None, None, None]
# stable
if sys.version_info >= (3, 10):

View File

@@ -1,9 +1,9 @@
from collections.abc import Callable, Hashable
from typing import Any, SupportsInt, TypeVar, Union
from typing import Any, SupportsInt, TypeVar
from typing_extensions import TypeAlias
_T = TypeVar("_T")
_Reduce: TypeAlias = Union[tuple[Callable[..., _T], tuple[Any, ...]], tuple[Callable[..., _T], tuple[Any, ...], Any | None]]
_Reduce: TypeAlias = tuple[Callable[..., _T], tuple[Any, ...]] | tuple[Callable[..., _T], tuple[Any, ...], Any | None]
__all__ = ["pickle", "constructor", "add_extension", "remove_extension", "clear_extension_cache"]

View File

@@ -3,7 +3,7 @@ from _ctypes import RTLD_GLOBAL as RTLD_GLOBAL, RTLD_LOCAL as RTLD_LOCAL
from _typeshed import ReadableBuffer, Self, WriteableBuffer
from abc import abstractmethod
from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence
from typing import Any, ClassVar, Generic, TypeVar, Union as _UnionT, overload
from typing import Any, ClassVar, Generic, TypeVar, overload
from typing_extensions import TypeAlias
if sys.version_info >= (3, 9):
@@ -91,7 +91,7 @@ class _CanCastTo(_CData): ...
class _PointerLike(_CanCastTo): ...
_ECT: TypeAlias = Callable[[type[_CData] | None, _FuncPointer, tuple[_CData, ...]], _CData]
_PF: TypeAlias = _UnionT[tuple[int], tuple[int, str], tuple[int, str, Any]]
_PF: TypeAlias = tuple[int] | tuple[int, str] | tuple[int, str, Any]
class _FuncPointer(_PointerLike, _CData):
restype: type[_CData] | Callable[[int], Any] | None

View File

@@ -1,8 +1,8 @@
from collections.abc import Callable
from typing import Any, Union
from typing import Any
from typing_extensions import TypeAlias
_Macro: TypeAlias = Union[tuple[str], tuple[str, str | None]]
_Macro: TypeAlias = tuple[str] | tuple[str, str | None]
def gen_lib_options(
compiler: CCompiler, library_dirs: list[str], runtime_library_dirs: list[str], libraries: list[str]

View File

@@ -1,12 +1,12 @@
from collections.abc import Callable
from email.message import Message
from email.policy import Policy
from typing import IO, Union
from typing import IO
from typing_extensions import TypeAlias
# Definitions imported by multiple submodules in typeshed
_ParamType: TypeAlias = Union[str, tuple[str | None, str | None, str]] # noqa: Y047
_ParamsType: TypeAlias = Union[str, None, tuple[str, str | None, str]] # noqa: Y047
_ParamType: TypeAlias = str | tuple[str | None, str | None, str] # noqa: Y047
_ParamsType: TypeAlias = str | None | tuple[str, str | None, str] # noqa: Y047
def message_from_string(s: str, _class: Callable[[], Message] = ..., *, policy: Policy = ...) -> Message: ...
def message_from_bytes(s: bytes | bytearray, _class: Callable[[], Message] = ..., *, policy: Policy = ...) -> Message: ...

View File

@@ -25,7 +25,7 @@ from types import (
TracebackType,
WrapperDescriptorType,
)
from typing import Any, ClassVar, NamedTuple, Protocol, TypeVar, Union, overload
from typing import Any, ClassVar, NamedTuple, Protocol, TypeVar, overload
from typing_extensions import Literal, ParamSpec, TypeAlias, TypeGuard
if sys.version_info >= (3, 11):
@@ -264,9 +264,9 @@ def isdatadescriptor(object: object) -> TypeGuard[_SupportsSet[Any, Any] | _Supp
#
# Retrieving source code
#
_SourceObjectType: TypeAlias = Union[
ModuleType, type[Any], MethodType, FunctionType, TracebackType, FrameType, CodeType, Callable[..., Any]
]
_SourceObjectType: TypeAlias = (
ModuleType | type[Any] | MethodType | FunctionType | TracebackType | FrameType | CodeType | Callable[..., Any]
)
def findsource(object: _SourceObjectType) -> tuple[list[str], int]: ...
def getabsfile(object: _SourceObjectType, _filename: str | None = None) -> str: ...

View File

@@ -7,7 +7,7 @@ from re import Pattern
from string import Template
from time import struct_time
from types import FrameType, TracebackType
from typing import Any, ClassVar, Generic, TextIO, TypeVar, Union, overload
from typing import Any, ClassVar, Generic, TextIO, TypeVar, overload
from typing_extensions import Literal, TypeAlias
if sys.version_info >= (3, 11):
@@ -61,7 +61,7 @@ __all__ = [
if sys.version_info >= (3, 11):
__all__ += ["getLevelNamesMapping"]
_SysExcInfoType: TypeAlias = Union[tuple[type[BaseException], BaseException, TracebackType | None], tuple[None, None, None]]
_SysExcInfoType: TypeAlias = tuple[type[BaseException], BaseException, TracebackType | None] | tuple[None, None, None]
_ExcInfoType: TypeAlias = None | bool | _SysExcInfoType | BaseException
_ArgsType: TypeAlias = tuple[object, ...] | Mapping[str, object]
_FilterType: TypeAlias = Filter | Callable[[LogRecord], bool]

View File

@@ -1,31 +1,31 @@
import builtins
import types
from _typeshed import ReadableBuffer, SupportsRead, SupportsWrite
from typing import Any, Union
from typing import Any
from typing_extensions import TypeAlias
version: int
_Marshallable: TypeAlias = Union[
_Marshallable: TypeAlias = (
# handled in w_object() in marshal.c
None,
type[StopIteration],
builtins.ellipsis,
bool,
None
| type[StopIteration]
| builtins.ellipsis
| bool
# handled in w_complex_object() in marshal.c
int,
float,
complex,
bytes,
str,
tuple[_Marshallable, ...],
list[Any],
dict[Any, Any],
set[Any],
frozenset[_Marshallable],
types.CodeType,
ReadableBuffer,
]
| int
| float
| complex
| bytes
| str
| tuple[_Marshallable, ...]
| list[Any]
| dict[Any, Any]
| set[Any]
| frozenset[_Marshallable]
| types.CodeType
| ReadableBuffer
)
def dump(__value: _Marshallable, __file: SupportsWrite[bytes], __version: int = 4) -> None: ...
def load(__file: SupportsRead[bytes]) -> Any: ...

View File

@@ -3,13 +3,13 @@ import sys
import types
from _typeshed import ReadableBuffer, Self
from collections.abc import Iterable
from typing import Any, Union
from typing import Any
from typing_extensions import SupportsIndex, TypeAlias
__all__ = ["Client", "Listener", "Pipe", "wait"]
# https://docs.python.org/3/library/multiprocessing.html#address-formats
_Address: TypeAlias = Union[str, tuple[str, int]]
_Address: TypeAlias = str | tuple[str, int]
class _ConnectionBase:
def __init__(self, handle: SupportsIndex, readable: bool = True, writable: bool = True) -> None: ...

View File

@@ -1,14 +1,14 @@
from _typeshed import Self
from queue import Queue
from types import TracebackType
from typing import Any, Union
from typing import Any
from typing_extensions import TypeAlias
__all__ = ["Client", "Listener", "Pipe"]
families: list[None]
_Address: TypeAlias = Union[str, tuple[str, int]]
_Address: TypeAlias = str | tuple[str, int]
class Connection:
_in: Any

View File

@@ -1,7 +1,7 @@
import sys
from _typeshed import ReadableBuffer, SupportsWrite
from collections.abc import Callable, Iterable, Iterator, Mapping
from typing import Any, ClassVar, Protocol, SupportsBytes, Union
from typing import Any, ClassVar, Protocol, SupportsBytes
from typing_extensions import SupportsIndex, TypeAlias, final
__all__ = [
@@ -142,13 +142,13 @@ class PickleError(Exception): ...
class PicklingError(PickleError): ...
class UnpicklingError(PickleError): ...
_ReducedType: TypeAlias = Union[
str,
tuple[Callable[..., Any], tuple[Any, ...]],
tuple[Callable[..., Any], tuple[Any, ...], Any],
tuple[Callable[..., Any], tuple[Any, ...], Any, Iterator[Any] | None],
tuple[Callable[..., Any], tuple[Any, ...], Any, Iterator[Any] | None, Iterator[Any] | None],
]
_ReducedType: TypeAlias = (
str
| tuple[Callable[..., Any], tuple[Any, ...]]
| tuple[Callable[..., Any], tuple[Any, ...], Any]
| tuple[Callable[..., Any], tuple[Any, ...], Any, Iterator[Any] | None]
| tuple[Callable[..., Any], tuple[Any, ...], Any, Iterator[Any] | None, Iterator[Any] | None]
)
class Pickler:
fast: bool

View File

@@ -3,7 +3,7 @@ from _typeshed import structseq
from collections.abc import Callable, Iterable
from enum import IntEnum
from types import FrameType
from typing import Any, Union
from typing import Any
from typing_extensions import Final, Never, TypeAlias, final
NSIG: int
@@ -62,7 +62,7 @@ SIG_DFL: Handlers
SIG_IGN: Handlers
_SIGNUM: TypeAlias = int | Signals
_HANDLER: TypeAlias = Union[Callable[[int, FrameType | None], Any], int, Handlers, None]
_HANDLER: TypeAlias = Callable[[int, FrameType | None], Any] | int | Handlers | None
def default_int_handler(__signalnum: int, __frame: FrameType | None) -> Never: ...

View File

@@ -4,7 +4,7 @@ from _socket import _Address, _RetAddress
from _typeshed import ReadableBuffer, Self
from collections.abc import Callable
from socket import socket as _socket
from typing import Any, BinaryIO, ClassVar, Union
from typing import Any, BinaryIO, ClassVar
from typing_extensions import TypeAlias
__all__ = [
@@ -29,7 +29,7 @@ if sys.platform != "win32":
"UnixStreamServer",
]
_RequestType: TypeAlias = Union[_socket, tuple[bytes, _socket]]
_RequestType: TypeAlias = _socket | tuple[bytes, _socket]
_AfUnixAddress: TypeAlias = str | ReadableBuffer # adddress acceptable for an AF_UNIX socket
_AfInetAddress: TypeAlias = tuple[str | bytes | bytearray, int] # address acceptable for an AF_INET socket

View File

@@ -3,7 +3,7 @@ import socket
import sys
from _typeshed import ReadableBuffer, Self, StrOrBytesPath, WriteableBuffer
from collections.abc import Callable, Iterable
from typing import Any, NamedTuple, Union, overload
from typing import Any, NamedTuple, overload
from typing_extensions import Literal, TypeAlias, TypedDict, final
_PCTRTT: TypeAlias = tuple[tuple[str, str], ...]
@@ -11,7 +11,7 @@ _PCTRTTT: TypeAlias = tuple[_PCTRTT, ...]
_PeerCertRetDictType: TypeAlias = dict[str, str | _PCTRTTT | _PCTRTT]
_PeerCertRetType: TypeAlias = _PeerCertRetDictType | bytes | None
_EnumRetType: TypeAlias = list[tuple[bytes, str, set[str] | bool]]
_PasswordType: TypeAlias = Union[Callable[[], str | bytes | bytearray], str, bytes, bytearray]
_PasswordType: TypeAlias = Callable[[], str | bytes | bytearray] | str | bytes | bytearray
_SrvnmeCbType: TypeAlias = Callable[[SSLSocket | SSLObject, str | None, SSLSocket], int | None]

View File

@@ -6,7 +6,7 @@ from enum import Enum
from tkinter.constants import *
from tkinter.font import _FontDescription
from types import TracebackType
from typing import Any, Generic, NamedTuple, Protocol, TypeVar, Union, overload
from typing import Any, Generic, NamedTuple, Protocol, TypeVar, overload
from typing_extensions import Literal, TypeAlias, TypedDict
if sys.version_info >= (3, 9):
@@ -179,7 +179,7 @@ _CanvasItemId: TypeAlias = int
_Color: TypeAlias = str # typically '#rrggbb', '#rgb' or color names.
_Compound: TypeAlias = Literal["top", "left", "center", "right", "bottom", "none"] # -compound in manual page named 'options'
# manual page: Tk_GetCursor
_Cursor: TypeAlias = Union[str, tuple[str], tuple[str, str], tuple[str, str, str], tuple[str, str, str, str]]
_Cursor: TypeAlias = str | tuple[str] | tuple[str, str] | tuple[str, str, str] | tuple[str, str, str, str]
# example when it's sequence: entry['invalidcommand'] = [entry.register(print), '%P']
_EntryValidateCommand: TypeAlias = str | list[str] | tuple[str, ...] | Callable[[], bool]
_GridIndex: TypeAlias = int | str
@@ -188,7 +188,7 @@ _Relief: TypeAlias = Literal["raised", "sunken", "flat", "ridge", "solid", "groo
_ScreenUnits: TypeAlias = str | float # Often the right type instead of int. Manual page: Tk_GetPixels
# -xscrollcommand and -yscrollcommand in 'options' manual page
_XYScrollCommand: TypeAlias = str | Callable[[float, float], object]
_TakeFocusValue: TypeAlias = Union[int, Literal[""], Callable[[str], bool | None]] # -takefocus in manual page named 'options'
_TakeFocusValue: TypeAlias = int | Literal[""] | Callable[[str], bool | None] # -takefocus in manual page named 'options'
if sys.version_info >= (3, 11):
class _VersionInfoType(NamedTuple):

View File

@@ -4,7 +4,7 @@ import tkinter
from _typeshed import Incomplete
from collections.abc import Callable
from tkinter.font import _FontDescription
from typing import Any, Union, overload
from typing import Any, overload
from typing_extensions import Literal, TypeAlias, TypedDict
__all__ = [
@@ -38,13 +38,13 @@ __all__ = [
def tclobjs_to_py(adict: dict[Any, Any]) -> dict[Any, Any]: ...
def setup_master(master: Incomplete | None = None): ...
_Padding: TypeAlias = Union[
tkinter._ScreenUnits,
tuple[tkinter._ScreenUnits],
tuple[tkinter._ScreenUnits, tkinter._ScreenUnits],
tuple[tkinter._ScreenUnits, tkinter._ScreenUnits, tkinter._ScreenUnits],
tuple[tkinter._ScreenUnits, tkinter._ScreenUnits, tkinter._ScreenUnits, tkinter._ScreenUnits],
]
_Padding: TypeAlias = (
tkinter._ScreenUnits
| tuple[tkinter._ScreenUnits]
| tuple[tkinter._ScreenUnits, tkinter._ScreenUnits]
| tuple[tkinter._ScreenUnits, tkinter._ScreenUnits, tkinter._ScreenUnits]
| tuple[tkinter._ScreenUnits, tkinter._ScreenUnits, tkinter._ScreenUnits, tkinter._ScreenUnits]
)
# from ttk_widget (aka ttk::widget) manual page, differs from tkinter._Compound
_TtkCompound: TypeAlias = Literal["text", "image", tkinter._Compound]

View File

@@ -1,7 +1,7 @@
import sys
from _tracemalloc import *
from collections.abc import Sequence
from typing import Any, Union, overload
from typing import Any, overload
from typing_extensions import SupportsIndex, TypeAlias
def get_object_traceback(obj: object) -> Traceback | None: ...
@@ -67,7 +67,7 @@ class Frame:
def __le__(self, other: Frame, NotImplemented: Any = ...) -> bool: ...
if sys.version_info >= (3, 9):
_TraceTuple: TypeAlias = Union[tuple[int, int, Sequence[_FrameTuple], int | None], tuple[int, int, Sequence[_FrameTuple]]]
_TraceTuple: TypeAlias = tuple[int, int, Sequence[_FrameTuple], int | None] | tuple[int, int, Sequence[_FrameTuple]]
else:
_TraceTuple: TypeAlias = tuple[int, int, Sequence[_FrameTuple]]

View File

@@ -1,7 +1,7 @@
from _typeshed import Self
from collections.abc import Callable, Sequence
from tkinter import Canvas, Frame, Misc, PhotoImage, Scrollbar
from typing import Any, ClassVar, Union, overload
from typing import Any, ClassVar, overload
from typing_extensions import TypeAlias
__all__ = [
@@ -133,7 +133,7 @@ __all__ = [
# alias we use for return types. Really, these two aliases should be the
# same, but as per the "no union returns" typeshed policy, we'll return
# Any instead.
_Color: TypeAlias = Union[str, tuple[float, float, float]]
_Color: TypeAlias = str | tuple[float, float, float]
_AnyColor: TypeAlias = Any
# TODO: Replace this with a TypedDict once it becomes standardized.

View File

@@ -6,20 +6,7 @@ from collections.abc import Callable, Container, Iterable, Mapping, Sequence, Se
from contextlib import AbstractContextManager
from re import Pattern
from types import TracebackType
from typing import (
Any,
AnyStr,
ClassVar,
Generic,
NamedTuple,
NoReturn,
Protocol,
SupportsAbs,
SupportsRound,
TypeVar,
Union,
overload,
)
from typing import Any, AnyStr, ClassVar, Generic, NamedTuple, NoReturn, Protocol, SupportsAbs, SupportsRound, TypeVar, overload
from typing_extensions import ParamSpec, TypeAlias
from warnings import WarningMessage
@@ -82,9 +69,9 @@ class SkipTest(Exception):
class _SupportsAbsAndDunderGE(SupportsDunderGE[Any], SupportsAbs[Any], Protocol): ...
if sys.version_info >= (3, 10):
_IsInstanceClassInfo: TypeAlias = Union[type, UnionType, tuple[type | UnionType | tuple[Any, ...], ...]]
_IsInstanceClassInfo: TypeAlias = type | UnionType | tuple[type | UnionType | tuple[Any, ...], ...]
else:
_IsInstanceClassInfo: TypeAlias = Union[type, tuple[type | tuple[Any, ...], ...]]
_IsInstanceClassInfo: TypeAlias = type | tuple[type | tuple[Any, ...], ...]
class TestCase:
failureException: type[BaseException]

View File

@@ -7,7 +7,7 @@ from collections.abc import Callable, Iterable, Mapping
from datetime import datetime
from io import BytesIO
from types import TracebackType
from typing import Any, Protocol, Union, overload
from typing import Any, Protocol, overload
from typing_extensions import Literal, TypeAlias
class _SupportsTimeTuple(Protocol):
@@ -31,7 +31,7 @@ _Marshallable: TypeAlias = (
| Binary
)
_XMLDate: TypeAlias = int | datetime | tuple[int, ...] | time.struct_time
_HostType: TypeAlias = Union[tuple[str, dict[str, str]], str]
_HostType: TypeAlias = tuple[str, dict[str, str]] | str
def escape(s: str) -> str: ... # undocumented