mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-09 21:46:42 +08:00
Eliminated the use of "bare" TypeVars in stdlib stubs (#5041)
Eliminated the use of "bare" TypeVars (i.e. a TypeVar that appears only once) within generic methods. While not considered an error in PEP 484, these are a common source of bugs in code, and some type checkers (including pytype and pyright) flag them as errors. Co-authored-by: Eric Traut <erictr@microsoft.com>
This commit is contained in:
@@ -1,16 +1,13 @@
|
||||
from typing import Any, Callable, ContextManager, MutableMapping, Optional, TypeVar
|
||||
|
||||
_KT = TypeVar("_KT")
|
||||
_VT = TypeVar("_VT")
|
||||
_T = TypeVar("_T", bound=Callable[..., Any])
|
||||
_T_co = TypeVar("_T_co", covariant=True)
|
||||
_T_self = TypeVar("_T_self")
|
||||
|
||||
def cached(
|
||||
cache: Optional[MutableMapping[_KT, _VT]], key: Callable[..., _KT] = ..., lock: Optional[ContextManager[_T_co]] = ...
|
||||
cache: Optional[MutableMapping[_KT, Any]], key: Callable[..., _KT] = ..., lock: Optional[ContextManager[Any]] = ...
|
||||
) -> Callable[[_T], _T]: ...
|
||||
def cachedmethod(
|
||||
cache: Callable[[_T_self], Optional[MutableMapping[_KT, _VT]]],
|
||||
cache: Callable[[Any], Optional[MutableMapping[_KT, Any]]],
|
||||
key: Callable[..., _KT] = ...,
|
||||
lock: Optional[ContextManager[_T_co]] = ...,
|
||||
lock: Optional[ContextManager[Any]] = ...,
|
||||
) -> Callable[[_T], _T]: ...
|
||||
|
||||
Reference in New Issue
Block a user