From c50ad36a4dee737d0819c069423d28b80279b006 Mon Sep 17 00:00:00 2001 From: hauntsaninja <> Date: Sun, 3 Jan 2021 16:22:51 -0800 Subject: [PATCH 1/8] _MessageType to _MessageT --- stdlib/2and3/mailbox.pyi | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/stdlib/2and3/mailbox.pyi b/stdlib/2and3/mailbox.pyi index 27377f8c58b4..e22788d21517 100644 --- a/stdlib/2and3/mailbox.pyi +++ b/stdlib/2and3/mailbox.pyi @@ -29,7 +29,7 @@ if sys.version_info >= (3, 9): from types import GenericAlias _T = TypeVar("_T") -_MessageType = TypeVar("_MessageType", bound=Message) +_MessageT = TypeVar("_MessageT", bound=Message) _MessageData = Union[email.message.Message, bytes, str, IO[str], IO[bytes]] class _HasIteritems(Protocol): @@ -40,41 +40,41 @@ class _HasItems(Protocol): linesep: bytes -class Mailbox(Generic[_MessageType]): +class Mailbox(Generic[_MessageT]): _path: Union[bytes, str] # undocumented - _factory: Optional[Callable[[IO[Any]], _MessageType]] # undocumented - def __init__(self, path: AnyPath, factory: Optional[Callable[[IO[Any]], _MessageType]] = ..., create: bool = ...) -> None: ... + _factory: Optional[Callable[[IO[Any]], _MessageT]] # undocumented + def __init__(self, path: AnyPath, factory: Optional[Callable[[IO[Any]], _MessageT]] = ..., create: bool = ...) -> None: ... def add(self, message: _MessageData) -> str: ... def remove(self, key: str) -> None: ... def __delitem__(self, key: str) -> None: ... def discard(self, key: str) -> None: ... def __setitem__(self, key: str, message: _MessageData) -> None: ... @overload - def get(self, key: str, default: None = ...) -> Optional[_MessageType]: ... + def get(self, key: str, default: None = ...) -> Optional[_MessageT]: ... @overload - def get(self, key: str, default: _T) -> Union[_MessageType, _T]: ... - def __getitem__(self, key: str) -> _MessageType: ... - def get_message(self, key: str) -> _MessageType: ... + def get(self, key: str, default: _T) -> Union[_MessageT, _T]: ... + def __getitem__(self, key: str) -> _MessageT: ... + def get_message(self, key: str) -> _MessageT: ... def get_string(self, key: str) -> str: ... def get_bytes(self, key: str) -> bytes: ... # As '_ProxyFile' doesn't implement the full IO spec, and BytesIO is incompatible with it, get_file return is Any here def get_file(self, key: str) -> Any: ... def iterkeys(self) -> Iterator[str]: ... def keys(self) -> List[str]: ... - def itervalues(self) -> Iterator[_MessageType]: ... - def __iter__(self) -> Iterator[_MessageType]: ... - def values(self) -> List[_MessageType]: ... - def iteritems(self) -> Iterator[Tuple[str, _MessageType]]: ... - def items(self) -> List[Tuple[str, _MessageType]]: ... + def itervalues(self) -> Iterator[_MessageT]: ... + def __iter__(self) -> Iterator[_MessageT]: ... + def values(self) -> List[_MessageT]: ... + def iteritems(self) -> Iterator[Tuple[str, _MessageT]]: ... + def items(self) -> List[Tuple[str, _MessageT]]: ... def __contains__(self, key: str) -> bool: ... def __len__(self) -> int: ... def clear(self) -> None: ... @overload - def pop(self, key: str, default: None = ...) -> Optional[_MessageType]: ... + def pop(self, key: str, default: None = ...) -> Optional[_MessageT]: ... @overload - def pop(self, key: str, default: _T = ...) -> Union[_MessageType, _T]: ... - def popitem(self) -> Tuple[str, _MessageType]: ... + def pop(self, key: str, default: _T = ...) -> Union[_MessageT, _T]: ... + def popitem(self) -> Tuple[str, _MessageT]: ... def update(self, arg: Optional[Union[_HasIteritems, _HasItems, Iterable[Tuple[str, _MessageData]]]] = ...) -> None: ... def flush(self) -> None: ... def lock(self) -> None: ... @@ -97,9 +97,9 @@ class Maildir(Mailbox[MaildirMessage]): def clean(self) -> None: ... def next(self) -> Optional[str]: ... -class _singlefileMailbox(Mailbox[_MessageType]): ... +class _singlefileMailbox(Mailbox[_MessageT]): ... -class _mboxMMDF(_singlefileMailbox[_MessageType]): +class _mboxMMDF(_singlefileMailbox[_MessageT]): def get_file(self, key: str) -> _PartialFile[bytes]: ... class mbox(_mboxMMDF[mboxMessage]): From 161844e5761873318919d1215a4ef87d9589ee55 Mon Sep 17 00:00:00 2001 From: hauntsaninja <> Date: Sun, 3 Jan 2021 16:24:45 -0800 Subject: [PATCH 2/8] _default to _T --- stdlib/2and3/unicodedata.pyi | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/stdlib/2and3/unicodedata.pyi b/stdlib/2and3/unicodedata.pyi index 1aa9ffb96fa2..a83d79ff2ed0 100644 --- a/stdlib/2and3/unicodedata.pyi +++ b/stdlib/2and3/unicodedata.pyi @@ -5,14 +5,14 @@ ucd_3_2_0: UCD ucnhash_CAPI: Any unidata_version: str -_default = TypeVar("_default") +_T = TypeVar("_T") def bidirectional(__chr: Text) -> Text: ... def category(__chr: Text) -> Text: ... def combining(__chr: Text) -> int: ... -def decimal(__chr: Text, __default: _default = ...) -> Union[int, _default]: ... +def decimal(__chr: Text, __default: _T = ...) -> Union[int, _T]: ... def decomposition(__chr: Text) -> Text: ... -def digit(__chr: Text, __default: _default = ...) -> Union[int, _default]: ... +def digit(__chr: Text, __default: _T = ...) -> Union[int, _T]: ... def east_asian_width(__chr: Text) -> Text: ... if sys.version_info >= (3, 8): @@ -20,9 +20,9 @@ if sys.version_info >= (3, 8): def lookup(__name: Union[Text, bytes]) -> Text: ... def mirrored(__chr: Text) -> int: ... -def name(__chr: Text, __default: _default = ...) -> Union[Text, _default]: ... +def name(__chr: Text, __default: _T = ...) -> Union[Text, _T]: ... def normalize(__form: Text, __unistr: Text) -> Text: ... -def numeric(__chr: Text, __default: _default = ...) -> Union[float, _default]: ... +def numeric(__chr: Text, __default: _T = ...) -> Union[float, _T]: ... class UCD(object): # The methods below are constructed from the same array in C @@ -31,12 +31,12 @@ class UCD(object): def bidirectional(self, __chr: Text) -> str: ... def category(self, __chr: Text) -> str: ... def combining(self, __chr: Text) -> int: ... - def decimal(self, __chr: Text, __default: _default = ...) -> Union[int, _default]: ... + def decimal(self, __chr: Text, __default: _T = ...) -> Union[int, _T]: ... def decomposition(self, __chr: Text) -> str: ... - def digit(self, __chr: Text, __default: _default = ...) -> Union[int, _default]: ... + def digit(self, __chr: Text, __default: _T = ...) -> Union[int, _T]: ... def east_asian_width(self, __chr: Text) -> str: ... def lookup(self, __name: Union[Text, bytes]) -> Text: ... def mirrored(self, __chr: Text) -> int: ... - def name(self, __chr: Text, __default: _default = ...) -> Union[Text, _default]: ... + def name(self, __chr: Text, __default: _T = ...) -> Union[Text, _T]: ... def normalize(self, __form: Text, __unistr: Text) -> Text: ... - def numeric(self, __chr: Text, __default: _default = ...) -> Union[float, _default]: ... + def numeric(self, __chr: Text, __default: _T = ...) -> Union[float, _T]: ... From 3da8f026c118bc88867634f1b9e912e3b7bc60dd Mon Sep 17 00:00:00 2001 From: hauntsaninja <> Date: Sun, 3 Jan 2021 16:25:12 -0800 Subject: [PATCH 3/8] _TConnection to _ConnectionT, _TListener to _ListenerT --- stdlib/3/multiprocessing/dummy/connection.pyi | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/stdlib/3/multiprocessing/dummy/connection.pyi b/stdlib/3/multiprocessing/dummy/connection.pyi index 4f9f716959d4..01733e59c763 100644 --- a/stdlib/3/multiprocessing/dummy/connection.pyi +++ b/stdlib/3/multiprocessing/dummy/connection.pyi @@ -4,8 +4,8 @@ from typing import Any, List, Optional, Tuple, Type, TypeVar, Union families: List[None] -_TConnection = TypeVar("_TConnection", bound=Connection) -_TListener = TypeVar("_TListener", bound=Listener) +_ConnectionT = TypeVar("_ConnectionT", bound=Connection) +_ListenerT = TypeVar("_ListenerT", bound=Listener) _Address = Union[str, Tuple[str, int]] class Connection(object): @@ -15,7 +15,7 @@ class Connection(object): recv_bytes: Any send: Any send_bytes: Any - def __enter__(self: _TConnection) -> _TConnection: ... + def __enter__(self: _ConnectionT) -> _ConnectionT: ... def __exit__( self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] ) -> None: ... @@ -27,7 +27,7 @@ class Listener(object): _backlog_queue: Optional[Queue[Any]] @property def address(self) -> Optional[Queue[Any]]: ... - def __enter__(self: _TListener) -> _TListener: ... + def __enter__(self: _ListenerT) -> _ListenerT: ... def __exit__( self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] ) -> None: ... From e653883bf71a31caa2adf988749b1caf0b3b1ff3 Mon Sep 17 00:00:00 2001 From: hauntsaninja <> Date: Sun, 3 Jan 2021 16:26:15 -0800 Subject: [PATCH 4/8] _Number to _NumberT --- stdlib/3/statistics.pyi | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/stdlib/3/statistics.pyi b/stdlib/3/statistics.pyi index 8d6b8f920652..d842965247f5 100644 --- a/stdlib/3/statistics.pyi +++ b/stdlib/3/statistics.pyi @@ -6,7 +6,7 @@ from typing import Any, Hashable, Iterable, List, Optional, SupportsFloat, Type, _T = TypeVar("_T") # Most functions in this module accept homogeneous collections of one of these types -_Number = TypeVar("_Number", float, Decimal, Fraction) +_NumberT = TypeVar("_NumberT", float, Decimal, Fraction) # Used in mode, multimode _HashableT = TypeVar("_HashableT", bound=Hashable) @@ -17,25 +17,25 @@ if sys.version_info >= (3, 8): def fmean(data: Iterable[SupportsFloat]) -> float: ... def geometric_mean(data: Iterable[SupportsFloat]) -> float: ... -def mean(data: Iterable[_Number]) -> _Number: ... -def harmonic_mean(data: Iterable[_Number]) -> _Number: ... -def median(data: Iterable[_Number]) -> _Number: ... +def mean(data: Iterable[_NumberT]) -> _NumberT: ... +def harmonic_mean(data: Iterable[_NumberT]) -> _NumberT: ... +def median(data: Iterable[_NumberT]) -> _NumberT: ... def median_low(data: Iterable[SupportsLessThanT]) -> SupportsLessThanT: ... def median_high(data: Iterable[SupportsLessThanT]) -> SupportsLessThanT: ... -def median_grouped(data: Iterable[_Number], interval: _Number = ...) -> _Number: ... +def median_grouped(data: Iterable[_NumberT], interval: _NumberT = ...) -> _NumberT: ... def mode(data: Iterable[_HashableT]) -> _HashableT: ... if sys.version_info >= (3, 8): def multimode(data: Iterable[_HashableT]) -> List[_HashableT]: ... -def pstdev(data: Iterable[_Number], mu: Optional[_Number] = ...) -> _Number: ... -def pvariance(data: Iterable[_Number], mu: Optional[_Number] = ...) -> _Number: ... +def pstdev(data: Iterable[_NumberT], mu: Optional[_NumberT] = ...) -> _NumberT: ... +def pvariance(data: Iterable[_NumberT], mu: Optional[_NumberT] = ...) -> _NumberT: ... if sys.version_info >= (3, 8): - def quantiles(data: Iterable[_Number], *, n: int = ..., method: str = ...) -> List[_Number]: ... + def quantiles(data: Iterable[_NumberT], *, n: int = ..., method: str = ...) -> List[_NumberT]: ... -def stdev(data: Iterable[_Number], xbar: Optional[_Number] = ...) -> _Number: ... -def variance(data: Iterable[_Number], xbar: Optional[_Number] = ...) -> _Number: ... +def stdev(data: Iterable[_NumberT], xbar: Optional[_NumberT] = ...) -> _NumberT: ... +def variance(data: Iterable[_NumberT], xbar: Optional[_NumberT] = ...) -> _NumberT: ... if sys.version_info >= (3, 8): class NormalDist: From a467703fa26941b618cfc899903883f84e645845 Mon Sep 17 00:00:00 2001 From: hauntsaninja <> Date: Sun, 3 Jan 2021 16:27:06 -0800 Subject: [PATCH 5/8] _MessageVar to _MessageT --- third_party/2and3/google/protobuf/json_format.pyi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/third_party/2and3/google/protobuf/json_format.pyi b/third_party/2and3/google/protobuf/json_format.pyi index 8ccc905757a3..7a0fea05fd52 100644 --- a/third_party/2and3/google/protobuf/json_format.pyi +++ b/third_party/2and3/google/protobuf/json_format.pyi @@ -2,7 +2,7 @@ from typing import Any, Dict, Text, TypeVar, Union from google.protobuf.message import Message -_MessageVar = TypeVar("_MessageVar", bound=Message) +_MessageT = TypeVar("_MessageT", bound=Message) class Error(Exception): ... class ParseError(Error): ... @@ -22,5 +22,5 @@ def MessageToDict( preserving_proto_field_name: bool = ..., use_integers_for_enums: bool = ..., ) -> Dict[Text, Any]: ... -def Parse(text: Union[bytes, Text], message: _MessageVar, ignore_unknown_fields: bool = ...) -> _MessageVar: ... -def ParseDict(js_dict: Any, message: _MessageVar, ignore_unknown_fields: bool = ...) -> _MessageVar: ... +def Parse(text: Union[bytes, Text], message: _MessageT, ignore_unknown_fields: bool = ...) -> _MessageT: ... +def ParseDict(js_dict: Any, message: _MessageT, ignore_unknown_fields: bool = ...) -> _MessageT: ... From 11a207b229d52aecad559e595f886489f90b6ebf Mon Sep 17 00:00:00 2001 From: hauntsaninja <> Date: Sun, 3 Jan 2021 16:36:03 -0800 Subject: [PATCH 6/8] _Type to _TypeT --- stdlib/2/copy_reg.pyi | 12 ++++++------ stdlib/3/copyreg.pyi | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/stdlib/2/copy_reg.pyi b/stdlib/2/copy_reg.pyi index a41f5e419ed4..ea07ba410b6d 100644 --- a/stdlib/2/copy_reg.pyi +++ b/stdlib/2/copy_reg.pyi @@ -1,16 +1,16 @@ from typing import Any, Callable, Hashable, List, Optional, SupportsInt, Tuple, TypeVar, Union -_Type = TypeVar("_Type", bound=type) -_Reduce = Union[Tuple[Callable[..., _Type], Tuple[Any, ...]], Tuple[Callable[..., _Type], Tuple[Any, ...], Optional[Any]]] +_TypeT = TypeVar("_TypeT", bound=type) +_Reduce = Union[Tuple[Callable[..., _TypeT], Tuple[Any, ...]], Tuple[Callable[..., _TypeT], Tuple[Any, ...], Optional[Any]]] __all__: List[str] def pickle( - ob_type: _Type, - pickle_function: Callable[[_Type], Union[str, _Reduce[_Type]]], - constructor_ob: Optional[Callable[[_Reduce[_Type]], _Type]] = ..., + ob_type: _TypeT, + pickle_function: Callable[[_TypeT], Union[str, _Reduce[_TypeT]]], + constructor_ob: Optional[Callable[[_Reduce[_TypeT]], _TypeT]] = ..., ) -> None: ... -def constructor(object: Callable[[_Reduce[_Type]], _Type]) -> None: ... +def constructor(object: Callable[[_Reduce[_TypeT]], _TypeT]) -> None: ... def add_extension(module: Hashable, name: Hashable, code: SupportsInt) -> None: ... def remove_extension(module: Hashable, name: Hashable, code: int) -> None: ... def clear_extension_cache() -> None: ... diff --git a/stdlib/3/copyreg.pyi b/stdlib/3/copyreg.pyi index a41f5e419ed4..ea07ba410b6d 100644 --- a/stdlib/3/copyreg.pyi +++ b/stdlib/3/copyreg.pyi @@ -1,16 +1,16 @@ from typing import Any, Callable, Hashable, List, Optional, SupportsInt, Tuple, TypeVar, Union -_Type = TypeVar("_Type", bound=type) -_Reduce = Union[Tuple[Callable[..., _Type], Tuple[Any, ...]], Tuple[Callable[..., _Type], Tuple[Any, ...], Optional[Any]]] +_TypeT = TypeVar("_TypeT", bound=type) +_Reduce = Union[Tuple[Callable[..., _TypeT], Tuple[Any, ...]], Tuple[Callable[..., _TypeT], Tuple[Any, ...], Optional[Any]]] __all__: List[str] def pickle( - ob_type: _Type, - pickle_function: Callable[[_Type], Union[str, _Reduce[_Type]]], - constructor_ob: Optional[Callable[[_Reduce[_Type]], _Type]] = ..., + ob_type: _TypeT, + pickle_function: Callable[[_TypeT], Union[str, _Reduce[_TypeT]]], + constructor_ob: Optional[Callable[[_Reduce[_TypeT]], _TypeT]] = ..., ) -> None: ... -def constructor(object: Callable[[_Reduce[_Type]], _Type]) -> None: ... +def constructor(object: Callable[[_Reduce[_TypeT]], _TypeT]) -> None: ... def add_extension(module: Hashable, name: Hashable, code: SupportsInt) -> None: ... def remove_extension(module: Hashable, name: Hashable, code: int) -> None: ... def clear_extension_cache() -> None: ... From 64b6d225588e4b30bbb7efde11fa1b4f2f1aa25f Mon Sep 17 00:00:00 2001 From: hauntsaninja <> Date: Sun, 3 Jan 2021 16:37:27 -0800 Subject: [PATCH 7/8] _ArgType to _T --- stdlib/2/mutex.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stdlib/2/mutex.pyi b/stdlib/2/mutex.pyi index 532760e02865..e0931dc1188a 100644 --- a/stdlib/2/mutex.pyi +++ b/stdlib/2/mutex.pyi @@ -1,6 +1,6 @@ from typing import Any, Callable, Deque, TypeVar -_ArgType = TypeVar("_ArgType") +_T = TypeVar("_T") class mutex: locked: bool @@ -8,5 +8,5 @@ class mutex: def __init__(self) -> None: ... def test(self) -> bool: ... def testandset(self) -> bool: ... - def lock(self, function: Callable[[_ArgType], Any], argument: _ArgType) -> None: ... + def lock(self, function: Callable[[_T], Any], argument: _T) -> None: ... def unlock(self) -> None: ... From 25908f8bc89c593d591cf21118d7a3081654512e Mon Sep 17 00:00:00 2001 From: hauntsaninja <> Date: Sun, 3 Jan 2021 16:38:26 -0800 Subject: [PATCH 8/8] _Ch to _CharT --- stdlib/2and3/curses/ascii.pyi | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/stdlib/2and3/curses/ascii.pyi b/stdlib/2and3/curses/ascii.pyi index 2a076601c34e..10bab853adcf 100644 --- a/stdlib/2and3/curses/ascii.pyi +++ b/stdlib/2and3/curses/ascii.pyi @@ -1,6 +1,6 @@ from typing import List, TypeVar, Union -_Ch = TypeVar("_Ch", str, int) +_CharT = TypeVar("_CharT", str, int) NUL: int SOH: int @@ -56,7 +56,7 @@ def isupper(c: Union[str, int]) -> bool: ... def isxdigit(c: Union[str, int]) -> bool: ... def isctrl(c: Union[str, int]) -> bool: ... def ismeta(c: Union[str, int]) -> bool: ... -def ascii(c: _Ch) -> _Ch: ... -def ctrl(c: _Ch) -> _Ch: ... -def alt(c: _Ch) -> _Ch: ... +def ascii(c: _CharT) -> _CharT: ... +def ctrl(c: _CharT) -> _CharT: ... +def alt(c: _CharT) -> _CharT: ... def unctrl(c: Union[str, int]) -> str: ...