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:
Eric Traut
2021-02-27 20:43:45 -07:00
committed by GitHub
parent 3c0f2acdf0
commit e2967a8bee
16 changed files with 34 additions and 37 deletions

View File

@@ -362,7 +362,7 @@ class MutableSet(AbstractSet[_T], Generic[_T]):
def __isub__(self, s: AbstractSet[Any]) -> MutableSet[_T]: ...
class MappingView(Sized):
def __init__(self, mapping: Mapping[_KT_co, _VT_co]) -> None: ... # undocumented
def __init__(self, mapping: Mapping[Any, Any]) -> None: ... # undocumented
def __len__(self) -> int: ...
class ItemsView(MappingView, AbstractSet[Tuple[_KT_co, _VT_co]], Generic[_KT_co, _VT_co]):
@@ -381,7 +381,7 @@ class ItemsView(MappingView, AbstractSet[Tuple[_KT_co, _VT_co]], Generic[_KT_co,
def __rxor__(self, o: Iterable[_T]) -> Set[Union[Tuple[_KT_co, _VT_co], _T]]: ...
class KeysView(MappingView, AbstractSet[_KT_co], Generic[_KT_co]):
def __init__(self, mapping: Mapping[_KT_co, _VT_co]) -> None: ... # undocumented
def __init__(self, mapping: Mapping[_KT_co, Any]) -> None: ... # undocumented
def __and__(self, o: Iterable[Any]) -> Set[_KT_co]: ...
def __rand__(self, o: Iterable[_T]) -> Set[_T]: ...
def __contains__(self, o: object) -> bool: ...
@@ -396,7 +396,7 @@ class KeysView(MappingView, AbstractSet[_KT_co], Generic[_KT_co]):
def __rxor__(self, o: Iterable[_T]) -> Set[Union[_KT_co, _T]]: ...
class ValuesView(MappingView, Iterable[_VT_co], Generic[_VT_co]):
def __init__(self, mapping: Mapping[_KT_co, _VT_co]) -> None: ... # undocumented
def __init__(self, mapping: Mapping[Any, _VT_co]) -> None: ... # undocumented
def __contains__(self, o: object) -> bool: ...
def __iter__(self) -> Iterator[_VT_co]: ...
if sys.version_info >= (3, 8):
@@ -661,7 +661,7 @@ class _TypedDict(Mapping[str, object], metaclass=ABCMeta):
# can go through.
def setdefault(self, k: NoReturn, default: object) -> object: ...
# Mypy plugin hook for 'pop' expects that 'default' has a type variable type.
def pop(self, k: NoReturn, default: _T = ...) -> object: ...
def pop(self, k: NoReturn, default: _T = ...) -> object: ... # type: ignore
def update(self: _T, __m: _T) -> None: ...
def __delitem__(self, k: NoReturn) -> None: ...
def items(self) -> ItemsView[str, object]: ...