mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-02-20 16:48:27 +08:00
Enable --disallow-any-generics for stubs (#3288)
This commit is contained in:
committed by
Jelle Zijlstra
parent
23b353303b
commit
c32e1e2280
@@ -47,16 +47,27 @@ _VT = TypeVar('_VT')
|
||||
|
||||
# namedtuple is special-cased in the type checker; the initializer is ignored.
|
||||
if sys.version_info >= (3, 7):
|
||||
def namedtuple(typename: str, field_names: Union[str, Iterable[str]], *,
|
||||
rename: bool = ..., module: Optional[str] = ..., defaults: Optional[Iterable[Any]] = ...) -> Type[tuple]: ...
|
||||
def namedtuple(
|
||||
typename: str,
|
||||
field_names: Union[str, Iterable[str]],
|
||||
*,
|
||||
rename: bool = ...,
|
||||
module: Optional[str] = ...,
|
||||
defaults: Optional[Iterable[Any]] = ...,
|
||||
) -> Type[Tuple[Any, ...]]: ...
|
||||
elif sys.version_info >= (3, 6):
|
||||
def namedtuple(typename: str, field_names: Union[str, Iterable[str]], *,
|
||||
verbose: bool = ..., rename: bool = ..., module: Optional[str] = ...) -> Type[tuple]: ...
|
||||
def namedtuple(
|
||||
typename: str,
|
||||
field_names: Union[str, Iterable[str]],
|
||||
*,
|
||||
verbose: bool = ...,
|
||||
rename: bool = ...,
|
||||
module: Optional[str] = ...,
|
||||
) -> Type[Tuple[Any, ...]]: ...
|
||||
else:
|
||||
def namedtuple(typename: str, field_names: Union[str, Iterable[str]],
|
||||
verbose: bool = ..., rename: bool = ...) -> Type[tuple]: ...
|
||||
|
||||
_UserDictT = TypeVar('_UserDictT', bound=UserDict)
|
||||
def namedtuple(
|
||||
typename: str, field_names: Union[str, Iterable[str]], verbose: bool = ..., rename: bool = ...,
|
||||
) -> Type[Tuple[Any, ...]]: ...
|
||||
|
||||
class UserDict(MutableMapping[_KT, _VT]):
|
||||
data: Dict[_KT, _VT]
|
||||
@@ -67,11 +78,9 @@ class UserDict(MutableMapping[_KT, _VT]):
|
||||
def __delitem__(self, key: _KT) -> None: ...
|
||||
def __iter__(self) -> Iterator[_KT]: ...
|
||||
def __contains__(self, key: object) -> bool: ...
|
||||
def copy(self: _UserDictT) -> _UserDictT: ...
|
||||
def copy(self: _S) -> _S: ...
|
||||
@classmethod
|
||||
def fromkeys(cls: Type[_UserDictT], iterable: Iterable[_KT], value: Optional[_VT] = ...) -> _UserDictT: ...
|
||||
|
||||
_UserListT = TypeVar('_UserListT', bound=UserList)
|
||||
def fromkeys(cls: Type[_S], iterable: Iterable[_KT], value: Optional[_VT] = ...) -> _S: ...
|
||||
|
||||
class UserList(MutableSequence[_T]):
|
||||
data: List[_T]
|
||||
@@ -91,16 +100,16 @@ class UserList(MutableSequence[_T]):
|
||||
@overload
|
||||
def __setitem__(self, i: slice, o: Iterable[_T]) -> None: ...
|
||||
def __delitem__(self, i: Union[int, slice]) -> None: ...
|
||||
def __add__(self: _UserListT, other: Iterable[_T]) -> _UserListT: ...
|
||||
def __iadd__(self: _UserListT, other: Iterable[_T]) -> _UserListT: ...
|
||||
def __mul__(self: _UserListT, n: int) -> _UserListT: ...
|
||||
def __imul__(self: _UserListT, n: int) -> _UserListT: ...
|
||||
def __add__(self: _S, other: Iterable[_T]) -> _S: ...
|
||||
def __iadd__(self: _S, other: Iterable[_T]) -> _S: ...
|
||||
def __mul__(self: _S, n: int) -> _S: ...
|
||||
def __imul__(self: _S, n: int) -> _S: ...
|
||||
def append(self, item: _T) -> None: ...
|
||||
def insert(self, i: int, item: _T) -> None: ...
|
||||
def pop(self, i: int = ...) -> _T: ...
|
||||
def remove(self, item: _T) -> None: ...
|
||||
def clear(self) -> None: ...
|
||||
def copy(self: _UserListT) -> _UserListT: ...
|
||||
def copy(self: _S) -> _S: ...
|
||||
def count(self, item: _T) -> int: ...
|
||||
def index(self, item: _T, *args: Any) -> int: ...
|
||||
def reverse(self) -> None: ...
|
||||
@@ -233,8 +242,6 @@ class deque(MutableSequence[_T], Generic[_T]):
|
||||
def __mul__(self, other: int) -> deque[_T]: ...
|
||||
def __imul__(self, other: int) -> None: ...
|
||||
|
||||
_CounterT = TypeVar('_CounterT', bound=Counter)
|
||||
|
||||
class Counter(Dict[_T, int], Generic[_T]):
|
||||
@overload
|
||||
def __init__(self, **kwargs: int) -> None: ...
|
||||
@@ -242,7 +249,7 @@ class Counter(Dict[_T, int], Generic[_T]):
|
||||
def __init__(self, mapping: Mapping[_T, int]) -> None: ...
|
||||
@overload
|
||||
def __init__(self, iterable: Iterable[_T]) -> None: ...
|
||||
def copy(self: _CounterT) -> _CounterT: ...
|
||||
def copy(self: _S) -> _S: ...
|
||||
def elements(self) -> Iterator[_T]: ...
|
||||
|
||||
def most_common(self, n: Optional[int] = ...) -> List[Tuple[_T, int]]: ...
|
||||
@@ -275,8 +282,6 @@ class Counter(Dict[_T, int], Generic[_T]):
|
||||
def __iand__(self, other: Counter[_T]) -> Counter[_T]: ...
|
||||
def __ior__(self, other: Counter[_T]) -> Counter[_T]: ...
|
||||
|
||||
_OrderedDictT = TypeVar('_OrderedDictT', bound=OrderedDict)
|
||||
|
||||
class _OrderedDictKeysView(KeysView[_KT], Reversible[_KT]):
|
||||
def __reversed__(self) -> Iterator[_KT]: ...
|
||||
class _OrderedDictItemsView(ItemsView[_KT, _VT], Reversible[Tuple[_KT, _VT]]):
|
||||
@@ -287,14 +292,12 @@ class _OrderedDictValuesView(ValuesView[_VT], Reversible[_VT]):
|
||||
class OrderedDict(Dict[_KT, _VT], Reversible[_KT], Generic[_KT, _VT]):
|
||||
def popitem(self, last: bool = ...) -> Tuple[_KT, _VT]: ...
|
||||
def move_to_end(self, key: _KT, last: bool = ...) -> None: ...
|
||||
def copy(self: _OrderedDictT) -> _OrderedDictT: ...
|
||||
def copy(self: _S) -> _S: ...
|
||||
def __reversed__(self) -> Iterator[_KT]: ...
|
||||
def keys(self) -> _OrderedDictKeysView[_KT]: ...
|
||||
def items(self) -> _OrderedDictItemsView[_KT, _VT]: ...
|
||||
def values(self) -> _OrderedDictValuesView[_VT]: ...
|
||||
|
||||
_DefaultDictT = TypeVar('_DefaultDictT', bound=defaultdict)
|
||||
|
||||
class defaultdict(Dict[_KT, _VT], Generic[_KT, _VT]):
|
||||
default_factory: Optional[Callable[[], _VT]]
|
||||
|
||||
@@ -318,7 +321,7 @@ class defaultdict(Dict[_KT, _VT], Generic[_KT, _VT]):
|
||||
iterable: Iterable[Tuple[_KT, _VT]], **kwargs: _VT) -> None: ...
|
||||
def __missing__(self, key: _KT) -> _VT: ...
|
||||
# TODO __reversed__
|
||||
def copy(self: _DefaultDictT) -> _DefaultDictT: ...
|
||||
def copy(self: _S) -> _S: ...
|
||||
|
||||
class ChainMap(MutableMapping[_KT, _VT], Generic[_KT, _VT]):
|
||||
def __init__(self, *maps: Mapping[_KT, _VT]) -> None: ...
|
||||
|
||||
Reference in New Issue
Block a user