mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-01-09 04:52:23 +08:00
Enable flake8-pyi's Y037 (#9686)
This commit is contained in:
@@ -2,7 +2,7 @@ from _typeshed import Incomplete, Self, SupportsRead, SupportsWrite
|
||||
from collections.abc import Callable, Iterable, Iterator, MutableMapping, Sequence
|
||||
from enum import IntEnum
|
||||
from pathlib import Path
|
||||
from typing import Any, ClassVar, Protocol, SupportsBytes, Union
|
||||
from typing import Any, ClassVar, Protocol, SupportsBytes
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
|
||||
from PIL.PyAccess import PyAccess
|
||||
@@ -22,13 +22,13 @@ _Resample: TypeAlias = Literal[0, 1, 2, 3, 4, 5]
|
||||
_Size: TypeAlias = tuple[int, int]
|
||||
_Box: TypeAlias = tuple[int, int, int, int]
|
||||
|
||||
_ConversionMatrix: TypeAlias = Union[
|
||||
tuple[float, float, float, float], tuple[float, float, float, float, float, float, float, float, float, float, float, float]
|
||||
]
|
||||
_ConversionMatrix: TypeAlias = (
|
||||
tuple[float, float, float, float] | tuple[float, float, float, float, float, float, float, float, float, float, float, float]
|
||||
)
|
||||
# `str` values are only accepted if mode="RGB" for an `Image` object
|
||||
# `float` values are only accepted for certain modes such as "F"
|
||||
# See https://pillow.readthedocs.io/en/stable/reference/Image.html#PIL.Image.new
|
||||
_Color: TypeAlias = Union[int, tuple[int], tuple[int, int, int], tuple[int, int, int, int], str, float, tuple[float]]
|
||||
_Color: TypeAlias = int | tuple[int] | tuple[int, int, int] | tuple[int, int, int, int] | str | float | tuple[float]
|
||||
|
||||
class _Writeable(SupportsWrite[bytes], Protocol):
|
||||
def seek(self, __offset: int) -> Any: ...
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
from typing import Union
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
_RGB: TypeAlias = Union[tuple[int, int, int], tuple[int, int, int, int]]
|
||||
_RGB: TypeAlias = tuple[int, int, int] | tuple[int, int, int, int]
|
||||
_Ink: TypeAlias = str | int | _RGB
|
||||
_GreyScale: TypeAlias = tuple[int, int]
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
from _typeshed import Incomplete
|
||||
from collections.abc import Iterable
|
||||
from typing import Protocol, Union
|
||||
from typing import Protocol
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
from .Image import Image, Resampling, _Resample, _Size
|
||||
from .ImageColor import _Ink
|
||||
|
||||
_Border: TypeAlias = Union[int, tuple[int, int], tuple[int, int, int, int]]
|
||||
_Border: TypeAlias = int | tuple[int, int] | tuple[int, int, int, int]
|
||||
|
||||
class _Deformer(Protocol):
|
||||
def getmesh(self, image: Image): ...
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from _typeshed import Incomplete
|
||||
from typing import Any, NamedTuple, Union
|
||||
from typing import Any, NamedTuple
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
|
||||
class _TagInfo(NamedTuple):
|
||||
@@ -37,7 +37,7 @@ DOUBLE: Literal[12]
|
||||
IFD: Literal[13]
|
||||
|
||||
_TagType: TypeAlias = Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
|
||||
_TagTuple: TypeAlias = Union[tuple[str, _TagType, int], tuple[str, _TagInfo, int, dict[str, int]]]
|
||||
_TagTuple: TypeAlias = tuple[str, _TagType, int] | tuple[str, _TagInfo, int, dict[str, int]]
|
||||
|
||||
TAGS_V2: dict[int, _TagTuple]
|
||||
TAGS_V2_GROUPS: dict[int, dict[int, _TagTuple]]
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
from collections.abc import Callable, Iterable
|
||||
from typing import TypeVar, Union
|
||||
from typing import TypeVar
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
_FormatCheckCallable: TypeAlias = Callable[[object], bool]
|
||||
_F = TypeVar("_F", bound=_FormatCheckCallable)
|
||||
_RaisesType: TypeAlias = Union[type[Exception], tuple[type[Exception], ...]]
|
||||
_RaisesType: TypeAlias = type[Exception] | tuple[type[Exception], ...]
|
||||
|
||||
class FormatChecker:
|
||||
checkers: dict[str, tuple[_FormatCheckCallable, _RaisesType]]
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
from collections.abc import Callable, Generator, Iterable, Sequence
|
||||
from queue import Queue
|
||||
from threading import Event as _UninterruptibleEvent
|
||||
from typing import Optional
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
from ._canonical_names import all_modifiers as all_modifiers, sided_modifiers as sided_modifiers
|
||||
@@ -10,7 +9,7 @@ from ._keyboard_event import KEY_DOWN as KEY_DOWN, KEY_UP as KEY_UP, KeyboardEve
|
||||
_Key: TypeAlias = int | str
|
||||
_ScanCodeList: TypeAlias = list[int] | tuple[int, ...]
|
||||
_ParseableHotkey: TypeAlias = _Key | list[int | _ScanCodeList] | tuple[int | _ScanCodeList, ...]
|
||||
_Callback: TypeAlias = Callable[[KeyboardEvent], Optional[bool]] | Callable[[], Optional[bool]]
|
||||
_Callback: TypeAlias = Callable[[KeyboardEvent], bool | None] | Callable[[], bool | None]
|
||||
# mypy doesn't support PEP 646's TypeVarTuple yet: https://github.com/python/mypy/issues/12280
|
||||
# _Ts = TypeVarTuple("_Ts")
|
||||
_Ts: TypeAlias = tuple[object, ...]
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from _typeshed import Incomplete, Self
|
||||
from abc import abstractmethod
|
||||
from collections.abc import Iterable, Iterator
|
||||
from typing import SupportsInt, Union, overload
|
||||
from typing import SupportsInt, overload
|
||||
from typing_extensions import Literal, SupportsIndex, TypeAlias
|
||||
|
||||
from netaddr.core import DictDotLookup
|
||||
@@ -38,7 +38,7 @@ class BaseIP:
|
||||
def version(self) -> Literal[4, 6]: ...
|
||||
|
||||
_IPAddressAddr: TypeAlias = BaseIP | int | str
|
||||
_IPNetworkAddr: TypeAlias = Union[IPNetwork, IPAddress, tuple[int, int], str]
|
||||
_IPNetworkAddr: TypeAlias = IPNetwork | IPAddress | tuple[int, int] | str
|
||||
|
||||
class IPAddress(BaseIP):
|
||||
def __init__(self, addr: _IPAddressAddr, version: Literal[4, 6] | None = ..., flags: int = ...) -> None: ...
|
||||
|
||||
@@ -5,7 +5,7 @@ import time
|
||||
import types
|
||||
from _typeshed import Incomplete
|
||||
from collections.abc import Callable
|
||||
from typing import Any, Optional, TypeVar
|
||||
from typing import Any, TypeVar
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
from .matcher import MQTTMatcher as MQTTMatcher
|
||||
@@ -92,7 +92,7 @@ _Payload: TypeAlias = str | bytes | bytearray | float
|
||||
_ExtraHeader: TypeAlias = dict[str, str] | Callable[[dict[str, str]], dict[str, str]]
|
||||
_OnLog: TypeAlias = Callable[[Client, _UserData, int, str], object]
|
||||
_OnConnect: TypeAlias = Callable[[Client, _UserData, dict[str, int], int], object]
|
||||
_OnConnectV5: TypeAlias = Callable[[Client, _UserData, dict[str, int], ReasonCodes, Optional[Properties]], object]
|
||||
_OnConnectV5: TypeAlias = Callable[[Client, _UserData, dict[str, int], ReasonCodes, Properties | None], object]
|
||||
_TOnConnect = TypeVar("_TOnConnect", _OnConnect, _OnConnectV5)
|
||||
_OnConnectFail: TypeAlias = Callable[[Client, _UserData], object]
|
||||
_OnSubscribe: TypeAlias = Callable[[Client, _UserData, int, tuple[int]], object]
|
||||
@@ -104,7 +104,7 @@ _OnUnsubscribe: TypeAlias = Callable[[Client, _UserData, int], object]
|
||||
_OnUnsubscribeV5: TypeAlias = Callable[[Client, _UserData, int, Properties, list[ReasonCodes] | ReasonCodes], object]
|
||||
_TOnUnsubscribe = TypeVar("_TOnUnsubscribe", _OnUnsubscribe, _OnUnsubscribeV5)
|
||||
_OnDisconnect: TypeAlias = Callable[[Client, _UserData, int], object]
|
||||
_OnDisconnectV5: TypeAlias = Callable[[Client, _UserData, Optional[ReasonCodes], Optional[Properties]], object]
|
||||
_OnDisconnectV5: TypeAlias = Callable[[Client, _UserData, ReasonCodes | None, Properties | None], object]
|
||||
_TOnDisconnect = TypeVar("_TOnDisconnect", _OnDisconnect, _OnDisconnectV5)
|
||||
_OnSocket: TypeAlias = Callable[[Client, _UserData, _Socket | WebsocketWrapper | None], object]
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import collections.abc
|
||||
from _typeshed import Self
|
||||
from collections.abc import Callable, Mapping
|
||||
from re import Pattern
|
||||
from typing import Any, Union
|
||||
from typing import Any
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
from parsimonious.exceptions import ParseError
|
||||
@@ -10,7 +10,7 @@ from parsimonious.grammar import Grammar
|
||||
from parsimonious.nodes import Node
|
||||
from parsimonious.utils import StrAndRepr
|
||||
|
||||
_CALLABLE_RETURN_TYPE: TypeAlias = Union[int, tuple[int, list[Node]], Node, None]
|
||||
_CALLABLE_RETURN_TYPE: TypeAlias = int | tuple[int, list[Node]] | Node | None
|
||||
_CALLABLE_TYPE: TypeAlias = (
|
||||
Callable[[str, int], _CALLABLE_RETURN_TYPE]
|
||||
| Callable[[str, int, Mapping[tuple[int, int], Node], ParseError, Grammar], _CALLABLE_RETURN_TYPE]
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
from _typeshed import FileDescriptor, StrOrBytesPath
|
||||
from collections.abc import Callable
|
||||
from typing import Optional, TypeVar
|
||||
from typing import TypeVar
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
from Xlib.error import XError
|
||||
from Xlib.protocol.rq import Request
|
||||
|
||||
_T = TypeVar("_T")
|
||||
ErrorHandler: TypeAlias = Callable[[XError, Optional[Request]], _T]
|
||||
ErrorHandler: TypeAlias = Callable[[XError, Request | None], _T]
|
||||
Unused: TypeAlias = object
|
||||
OpenFile: TypeAlias = StrOrBytesPath | FileDescriptor
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from collections.abc import Callable
|
||||
from typing import Any, Union
|
||||
from typing import Any
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
from Xlib._typing import ErrorHandler, Unused
|
||||
@@ -7,7 +7,7 @@ from Xlib.display import Display
|
||||
from Xlib.protocol import rq
|
||||
from Xlib.xobject import drawable, resource
|
||||
|
||||
_Update: TypeAlias = Callable[[Union[rq.DictWrapper, dict[str, Any]]], object]
|
||||
_Update: TypeAlias = Callable[[rq.DictWrapper | dict[str, Any]], object]
|
||||
|
||||
extname: str
|
||||
RedirectAutomatic: int
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from _typeshed import Incomplete, Self, SupportsItems, SupportsRead
|
||||
from collections.abc import Callable, Iterable, Mapping, MutableMapping
|
||||
from typing import Any, Union
|
||||
from typing import Any
|
||||
from typing_extensions import TypeAlias, TypedDict
|
||||
|
||||
from urllib3._collections import RecentlyUsedContainer
|
||||
@@ -77,8 +77,8 @@ _Data: TypeAlias = (
|
||||
| tuple[tuple[Any, Any], ...]
|
||||
| Mapping[Any, Any]
|
||||
)
|
||||
_Auth: TypeAlias = Union[tuple[str, str], _auth.AuthBase, Callable[[PreparedRequest], PreparedRequest]]
|
||||
_Cert: TypeAlias = Union[str, tuple[str, str]]
|
||||
_Auth: TypeAlias = tuple[str, str] | _auth.AuthBase | Callable[[PreparedRequest], PreparedRequest]
|
||||
_Cert: TypeAlias = str | tuple[str, str]
|
||||
# Files is passed to requests.utils.to_key_val_list()
|
||||
_FileName: TypeAlias = str | None
|
||||
_FileContent: TypeAlias = SupportsRead[str | bytes] | str | bytes
|
||||
@@ -94,15 +94,16 @@ _HooksInput: TypeAlias = Mapping[str, Iterable[_Hook] | _Hook]
|
||||
|
||||
_ParamsMappingKeyType: TypeAlias = str | bytes | int | float
|
||||
_ParamsMappingValueType: TypeAlias = str | bytes | int | float | Iterable[str | bytes | int | float] | None
|
||||
_Params: TypeAlias = Union[
|
||||
SupportsItems[_ParamsMappingKeyType, _ParamsMappingValueType],
|
||||
tuple[_ParamsMappingKeyType, _ParamsMappingValueType],
|
||||
Iterable[tuple[_ParamsMappingKeyType, _ParamsMappingValueType]],
|
||||
str | bytes,
|
||||
]
|
||||
_Params: TypeAlias = (
|
||||
SupportsItems[_ParamsMappingKeyType, _ParamsMappingValueType]
|
||||
| tuple[_ParamsMappingKeyType, _ParamsMappingValueType]
|
||||
| Iterable[tuple[_ParamsMappingKeyType, _ParamsMappingValueType]]
|
||||
| str
|
||||
| bytes
|
||||
)
|
||||
_TextMapping: TypeAlias = MutableMapping[str, str]
|
||||
_HeadersUpdateMapping: TypeAlias = Mapping[str, str | bytes | None]
|
||||
_Timeout: TypeAlias = Union[float, tuple[float, float], tuple[float, None]]
|
||||
_Timeout: TypeAlias = float | tuple[float, float] | tuple[float, None]
|
||||
_Verify: TypeAlias = bool | str
|
||||
|
||||
class _Settings(TypedDict):
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
from collections.abc import Callable, Mapping
|
||||
from typing import Any, Union
|
||||
from typing import Any
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
_FieldValue: TypeAlias = str | bytes
|
||||
_FieldValueTuple: TypeAlias = Union[_FieldValue, tuple[str, _FieldValue], tuple[str, _FieldValue, str]]
|
||||
_FieldValueTuple: TypeAlias = _FieldValue | tuple[str, _FieldValue] | tuple[str, _FieldValue, str]
|
||||
|
||||
def guess_content_type(filename: str | None, default: str = ...) -> str: ...
|
||||
def format_header_param_rfc2231(name: str, value: _FieldValue) -> str: ...
|
||||
|
||||
Reference in New Issue
Block a user