mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-10 14:01:55 +08:00
Suffix T to type variable names (#4898)
* _MessageType to _MessageT * _default to _T * _TConnection to _ConnectionT, _TListener to _ListenerT * _Number to _NumberT * _MessageVar to _MessageT * _Type to _TypeT * _ArgType to _T * _Ch to _CharT Co-authored-by: hauntsaninja <>
This commit is contained in:
@@ -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: ...
|
||||
|
||||
@@ -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: ...
|
||||
|
||||
@@ -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: ...
|
||||
|
||||
@@ -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]):
|
||||
|
||||
@@ -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]: ...
|
||||
|
||||
@@ -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: ...
|
||||
|
||||
@@ -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: ...
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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: ...
|
||||
|
||||
Reference in New Issue
Block a user