Skip to content

collections/typing: fix various arg names #4258

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions stdlib/3/typing.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -302,15 +302,15 @@ class Sequence(_Collection[_T_co], Reversible[_T_co], Generic[_T_co]):
@abstractmethod
def __getitem__(self, s: slice) -> Sequence[_T_co]: ...
# Mixin methods
def index(self, x: Any, start: int = ..., end: int = ...) -> int: ...
def count(self, x: Any) -> int: ...
def index(self, value: Any, start: int = ..., stop: int = ...) -> int: ...
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A lot of these should probably also be positional-only.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, yeah. Note that the actual classes in collections.abc don't use positional-only args though, so that would diverge from CPython

def count(self, value: Any) -> int: ...
def __contains__(self, x: object) -> bool: ...
def __iter__(self) -> Iterator[_T_co]: ...
def __reversed__(self) -> Iterator[_T_co]: ...

class MutableSequence(Sequence[_T], Generic[_T]):
@abstractmethod
def insert(self, index: int, object: _T) -> None: ...
def insert(self, index: int, value: _T) -> None: ...
@overload
@abstractmethod
def __getitem__(self, i: int) -> _T: ...
Expand All @@ -330,12 +330,12 @@ class MutableSequence(Sequence[_T], Generic[_T]):
@abstractmethod
def __delitem__(self, i: slice) -> None: ...
# Mixin methods
def append(self, object: _T) -> None: ...
def append(self, value: _T) -> None: ...
def clear(self) -> None: ...
def extend(self, iterable: Iterable[_T]) -> None: ...
def extend(self, values: Iterable[_T]) -> None: ...
def reverse(self) -> None: ...
def pop(self, index: int = ...) -> _T: ...
def remove(self, object: _T) -> None: ...
def remove(self, value: _T) -> None: ...
def __iadd__(self, x: Iterable[_T]) -> MutableSequence[_T]: ...

class AbstractSet(_Collection[_T_co], Generic[_T_co]):
Expand All @@ -350,17 +350,17 @@ class AbstractSet(_Collection[_T_co], Generic[_T_co]):
def __or__(self, s: AbstractSet[_T]) -> AbstractSet[Union[_T_co, _T]]: ...
def __sub__(self, s: AbstractSet[Any]) -> AbstractSet[_T_co]: ...
def __xor__(self, s: AbstractSet[_T]) -> AbstractSet[Union[_T_co, _T]]: ...
def isdisjoint(self, s: Iterable[Any]) -> bool: ...
def isdisjoint(self, other: Iterable[Any]) -> bool: ...

class MutableSet(AbstractSet[_T], Generic[_T]):
@abstractmethod
def add(self, x: _T) -> None: ...
def add(self, value: _T) -> None: ...
@abstractmethod
def discard(self, x: _T) -> None: ...
def discard(self, value: _T) -> None: ...
# Mixin methods
def clear(self) -> None: ...
def pop(self) -> _T: ...
def remove(self, element: _T) -> None: ...
def remove(self, value: _T) -> None: ...
def __ior__(self, s: AbstractSet[_S]) -> MutableSet[Union[_T, _S]]: ...
def __iand__(self, s: AbstractSet[Any]) -> MutableSet[_T]: ...
def __ixor__(self, s: AbstractSet[_S]) -> MutableSet[Union[_T, _S]]: ...
Expand Down Expand Up @@ -432,9 +432,9 @@ class Mapping(_Collection[_KT], Generic[_KT, _VT_co]):
...
# Mixin methods
@overload
def get(self, k: _KT) -> Optional[_VT_co]: ...
def get(self, key: _KT) -> Optional[_VT_co]: ...
@overload
def get(self, k: _KT, default: Union[_VT_co, _T]) -> Union[_VT_co, _T]: ...
def get(self, key: _KT, default: Union[_VT_co, _T]) -> Union[_VT_co, _T]: ...
def items(self) -> AbstractSet[Tuple[_KT, _VT_co]]: ...
def keys(self) -> AbstractSet[_KT]: ...
def values(self) -> ValuesView[_VT_co]: ...
Expand All @@ -448,11 +448,11 @@ class MutableMapping(Mapping[_KT, _VT], Generic[_KT, _VT]):

def clear(self) -> None: ...
@overload
def pop(self, k: _KT) -> _VT: ...
def pop(self, key: _KT) -> _VT: ...
@overload
def pop(self, k: _KT, default: Union[_VT, _T] = ...) -> Union[_VT, _T]: ...
def pop(self, key: _KT, default: Union[_VT, _T] = ...) -> Union[_VT, _T]: ...
def popitem(self) -> Tuple[_KT, _VT]: ...
def setdefault(self, k: _KT, default: _VT = ...) -> _VT: ...
def setdefault(self, key: _KT, default: _VT = ...) -> _VT: ...
# 'update' used to take a Union, but using overloading is better.
# The second overloaded type here is a bit too general, because
# Mapping[Tuple[_KT, _VT], W] is a subclass of Iterable[Tuple[_KT, _VT]],
Expand Down
11 changes: 0 additions & 11 deletions tests/stubtest_whitelists/py35.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ smtpd.SMTPChannel.__init__
smtpd.SMTPServer.__init__
sre_compile.dis
ssl.SSLSocket.__init__
typing.AbstractSet.isdisjoint
typing.Coroutine.cr_await
typing.Coroutine.cr_code
typing.Coroutine.cr_frame
Expand All @@ -61,20 +60,10 @@ typing.Generator.gi_yieldfrom
typing.GenericMeta.__new__
typing.IO.closed # Incorrect definition in CPython, fixed in bpo-39493
typing.Mapping.get
typing.MutableMapping.pop
typing.MutableMapping.setdefault
typing.MutableSequence.append
typing.MutableSequence.extend
typing.MutableSequence.insert
typing.MutableSequence.remove
typing.MutableSet.add
typing.MutableSet.discard
typing.MutableSet.remove
typing.NamedTuple.__new__
typing.NamedTuple._asdict
typing.NamedTuple._make
typing.NamedTuple._replace
typing.Sequence.count
typing.Sequence.index
typing.runtime_checkable
unittest.async_case # Added in Python 3.8
Expand Down
11 changes: 0 additions & 11 deletions tests/stubtest_whitelists/py36.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ secrets.SystemRandom.getstate
smtplib.SMTP.sendmail
sre_compile.dis
ssl.SSLSocket.__init__
typing.AbstractSet.isdisjoint
typing.AsyncGenerator.ag_await
typing.AsyncGenerator.ag_code
typing.AsyncGenerator.ag_frame
Expand All @@ -56,20 +55,10 @@ typing.Generator.gi_yieldfrom
typing.GenericMeta.__new__
typing.IO.closed # Incorrect definition in CPython, fixed in bpo-39493
typing.Mapping.get
typing.MutableMapping.pop
typing.MutableMapping.setdefault
typing.MutableSequence.append
typing.MutableSequence.extend
typing.MutableSequence.insert
typing.MutableSequence.remove
typing.MutableSet.add
typing.MutableSet.discard
typing.MutableSet.remove
typing.NamedTuple.__new__
typing.NamedTuple._asdict
typing.NamedTuple._make
typing.NamedTuple._replace
typing.Sequence.count
typing.Sequence.index
typing.runtime_checkable
unittest.async_case # Added in Python 3.8
Expand Down
29 changes: 1 addition & 28 deletions tests/stubtest_whitelists/py3_common.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ asyncio.tasks.Task.print_stack
builtins.bytearray.__float__
builtins.bytearray.__int__
builtins.bytearray.append
builtins.bytearray.extend
builtins.bytearray.maketrans
builtins.bytearray.remove
builtins.bytes.__float__
builtins.bytes.__int__
builtins.bytes.maketrans
Expand Down Expand Up @@ -79,7 +79,6 @@ collections.Callable
collections.ChainMap.get
collections.ChainMap.maps
collections.ChainMap.new_child
collections.ChainMap.pop
collections.Coroutine.cr_await
collections.Coroutine.cr_code
collections.Coroutine.cr_frame
Expand All @@ -90,18 +89,7 @@ collections.Generator.gi_frame
collections.Generator.gi_running
collections.Generator.gi_yieldfrom
collections.Mapping.get
collections.MutableMapping.pop
collections.MutableMapping.setdefault
collections.MutableSequence.append
collections.MutableSequence.extend
collections.MutableSequence.insert
collections.MutableSequence.remove
collections.MutableSet.add
collections.MutableSet.discard
collections.MutableSet.remove
collections.Sequence.count
collections.Sequence.index
collections.Set.isdisjoint
collections.abc.Callable
collections.abc.Coroutine.cr_await
collections.abc.Coroutine.cr_code
Expand All @@ -112,18 +100,7 @@ collections.abc.Generator.gi_frame
collections.abc.Generator.gi_running
collections.abc.Generator.gi_yieldfrom
collections.abc.Mapping.get
collections.abc.MutableMapping.pop
collections.abc.MutableMapping.setdefault
collections.abc.MutableSequence.append
collections.abc.MutableSequence.extend
collections.abc.MutableSequence.insert
collections.abc.MutableSequence.remove
collections.abc.MutableSet.add
collections.abc.MutableSet.discard
collections.abc.MutableSet.remove
collections.abc.Sequence.count
collections.abc.Sequence.index
collections.abc.Set.isdisjoint
collections.deque.__hash__
concurrent.futures.Executor.map
concurrent.futures._base.Executor.map
Expand Down Expand Up @@ -445,12 +422,8 @@ weakref.ProxyType.__getattr__
weakref.ReferenceType.__call__
weakref.WeakKeyDictionary.__init__
weakref.WeakKeyDictionary.get
weakref.WeakKeyDictionary.pop
weakref.WeakKeyDictionary.setdefault
weakref.WeakKeyDictionary.update
weakref.WeakValueDictionary.get
weakref.WeakValueDictionary.pop
weakref.WeakValueDictionary.setdefault
webbrowser.Mozilla.raise_opts
webbrowser.UnixBrowser.raise_opts
webbrowser.UnixBrowser.remote_action
Expand Down