diff --git a/stdlib/3/_collections_abc.pyi b/stdlib/3/_collections_abc.pyi new file mode 100644 index 000000000000..357c1f91a735 --- /dev/null +++ b/stdlib/3/_collections_abc.pyi @@ -0,0 +1,56 @@ +from typing import ( + AbstractSet as Set, + AsyncGenerator as AsyncGenerator, + AsyncIterable as AsyncIterable, + AsyncIterator as AsyncIterator, + Awaitable as Awaitable, + ByteString as ByteString, + Callable as Callable, + Collection as Collection, + Container as Container, + Coroutine as Coroutine, + Generator as Generator, + Hashable as Hashable, + ItemsView as ItemsView, + Iterable as Iterable, + Iterator as Iterator, + KeysView as KeysView, + Mapping as Mapping, + MappingView as MappingView, + MutableMapping as MutableMapping, + MutableSequence as MutableSequence, + MutableSet as MutableSet, + Reversible as Reversible, + Sequence as Sequence, + Sized as Sized, + ValuesView as ValuesView, +) + +# Without the real definition, mypy and pytest both think that __all__ is empty, so re-exports nothing +__all__ = [ + "Awaitable", + "Coroutine", + "AsyncIterable", + "AsyncIterator", + "AsyncGenerator", + "Hashable", + "Iterable", + "Iterator", + "Generator", + "Reversible", + "Sized", + "Container", + "Callable", + "Collection", + "Set", + "MutableSet", + "Mapping", + "MutableMapping", + "MappingView", + "KeysView", + "ItemsView", + "ValuesView", + "Sequence", + "MutableSequence", + "ByteString", +] diff --git a/stdlib/3/collections/__init__.pyi b/stdlib/3/collections/__init__.pyi index a321d71f7ac6..a667955db27b 100644 --- a/stdlib/3/collections/__init__.pyi +++ b/stdlib/3/collections/__init__.pyi @@ -1,44 +1,9 @@ import sys import typing -from typing import ( - AbstractSet, - Any, - AsyncGenerator as AsyncGenerator, - AsyncIterable as AsyncIterable, - AsyncIterator as AsyncIterator, - Awaitable as Awaitable, - ByteString as ByteString, - Callable as Callable, - Collection as Collection, - Container as Container, - Coroutine as Coroutine, - Dict, - Generator as Generator, - Generic, - Hashable as Hashable, - ItemsView as ItemsView, - Iterable as Iterable, - Iterator as Iterator, - KeysView as KeysView, - List, - Mapping as Mapping, - MappingView as MappingView, - MutableMapping as MutableMapping, - MutableSequence as MutableSequence, - MutableSet as MutableSet, - Optional, - Reversible as Reversible, - Sequence as Sequence, - Sized as Sized, - Tuple, - Type, - TypeVar, - Union, - ValuesView as ValuesView, - overload, -) +from typing import Any, Dict, Generic, List, Optional, Tuple, Type, TypeVar, Union, overload -Set = AbstractSet +if sys.version_info < (3, 10): + from _collections_abc import * _S = TypeVar("_S") _T = TypeVar("_T") diff --git a/stdlib/3/collections/abc.pyi b/stdlib/3/collections/abc.pyi index c9d69978afd2..3df2a1d9eb9b 100644 --- a/stdlib/3/collections/abc.pyi +++ b/stdlib/3/collections/abc.pyi @@ -1,27 +1,2 @@ -from . import ( - AsyncGenerator as AsyncGenerator, - AsyncIterable as AsyncIterable, - AsyncIterator as AsyncIterator, - Awaitable as Awaitable, - ByteString as ByteString, - Callable as Callable, - Collection as Collection, - Container as Container, - Coroutine as Coroutine, - Generator as Generator, - Hashable as Hashable, - ItemsView as ItemsView, - Iterable as Iterable, - Iterator as Iterator, - KeysView as KeysView, - Mapping as Mapping, - MappingView as MappingView, - MutableMapping as MutableMapping, - MutableSequence as MutableSequence, - MutableSet as MutableSet, - Reversible as Reversible, - Sequence as Sequence, - Set as Set, - Sized as Sized, - ValuesView as ValuesView, -) +from _collections_abc import * +from _collections_abc import __all__ as __all__ diff --git a/tests/stubtest_whitelists/py36.txt b/tests/stubtest_whitelists/py36.txt index bd8eb34d9f8e..fc9c18b6dcd8 100644 --- a/tests/stubtest_whitelists/py36.txt +++ b/tests/stubtest_whitelists/py36.txt @@ -1,3 +1,7 @@ +_collections_abc.AsyncGenerator.ag_await +_collections_abc.AsyncGenerator.ag_code +_collections_abc.AsyncGenerator.ag_frame +_collections_abc.AsyncGenerator.ag_running asyncio.Future.__init__ asyncio.exceptions # Added in Python 3.8 asyncio.format_helpers # Added in Python 3.7 @@ -15,10 +19,6 @@ collections.AsyncGenerator.ag_code collections.AsyncGenerator.ag_frame collections.AsyncGenerator.ag_running collections.UserString.maketrans -collections.abc.AsyncGenerator.ag_await -collections.abc.AsyncGenerator.ag_code -collections.abc.AsyncGenerator.ag_frame -collections.abc.AsyncGenerator.ag_running contextlib._GeneratorContextManager.__init__ copy.PyStringMap ctypes.CDLL.__init__ diff --git a/tests/stubtest_whitelists/py37.txt b/tests/stubtest_whitelists/py37.txt index 9622ccc3b275..fd15c7dc5c5a 100644 --- a/tests/stubtest_whitelists/py37.txt +++ b/tests/stubtest_whitelists/py37.txt @@ -1,3 +1,7 @@ +_collections_abc.AsyncGenerator.ag_await +_collections_abc.AsyncGenerator.ag_code +_collections_abc.AsyncGenerator.ag_frame +_collections_abc.AsyncGenerator.ag_running asyncio.AbstractEventLoop.sock_sendfile asyncio.compat # Removed in 3.7 asyncio.Future.__init__ @@ -21,6 +25,7 @@ collections.abc.AsyncGenerator.ag_await collections.abc.AsyncGenerator.ag_code collections.abc.AsyncGenerator.ag_frame collections.abc.AsyncGenerator.ag_running +concurrent.futures.ProcessPoolExecutor.map contextvars.Context.__init__ contextvars.Context.get contextvars.ContextVar.get diff --git a/tests/stubtest_whitelists/py38.txt b/tests/stubtest_whitelists/py38.txt index 3842f0f34660..8f3423dc807b 100644 --- a/tests/stubtest_whitelists/py38.txt +++ b/tests/stubtest_whitelists/py38.txt @@ -1,3 +1,12 @@ +_collections_abc.AsyncGenerator.ag_await +_collections_abc.AsyncGenerator.ag_code +_collections_abc.AsyncGenerator.ag_frame +_collections_abc.AsyncGenerator.ag_running +_collections_abc.ItemsView.__reversed__ +_collections_abc.KeysView.__reversed__ +_collections_abc.ValuesView.__reversed__ +_thread.ExceptHookArgs +_thread._ExceptHookArgs ast.Bytes.__new__ ast.Ellipsis.__new__ ast.NameConstant.__new__ @@ -29,6 +38,7 @@ collections.abc.AsyncGenerator.ag_running collections.abc.ItemsView.__reversed__ collections.abc.KeysView.__reversed__ collections.abc.ValuesView.__reversed__ +concurrent.futures.ProcessPoolExecutor.map contextvars.Context.__init__ contextvars.Context.get copy.PyStringMap diff --git a/tests/stubtest_whitelists/py39.txt b/tests/stubtest_whitelists/py39.txt index 0b83d2ca2105..9f4afe54d248 100644 --- a/tests/stubtest_whitelists/py39.txt +++ b/tests/stubtest_whitelists/py39.txt @@ -1,4 +1,18 @@ _ast.ImportFrom.level +_collections_abc.AsyncGenerator.ag_await +_collections_abc.AsyncGenerator.ag_code +_collections_abc.AsyncGenerator.ag_frame +_collections_abc.AsyncGenerator.ag_running +_collections_abc.AsyncGenerator.asend +_collections_abc.AsyncGenerator.athrow +_collections_abc.Container.__contains__ +_collections_abc.Coroutine.send +_collections_abc.Coroutine.throw +_collections_abc.Generator.send +_collections_abc.Generator.throw +_collections_abc.ItemsView.__reversed__ +_collections_abc.KeysView.__reversed__ +_collections_abc.ValuesView.__reversed__ _dummy_thread ast.Bytes.__new__ ast.Ellipsis.__new__ diff --git a/tests/stubtest_whitelists/py3_common.txt b/tests/stubtest_whitelists/py3_common.txt index 39db6ad245a0..9f49cd6cf60c 100644 --- a/tests/stubtest_whitelists/py3_common.txt +++ b/tests/stubtest_whitelists/py3_common.txt @@ -1,4 +1,26 @@ __future__._Feature.__init__ +_collections_abc.Callable +_collections_abc.Coroutine.cr_await +_collections_abc.Coroutine.cr_code +_collections_abc.Coroutine.cr_frame +_collections_abc.Coroutine.cr_running +_collections_abc.Generator.gi_code +_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 _csv.Dialect.__init__ _dummy_threading _importlib_modulespec @@ -84,6 +106,7 @@ collections.Generator.gi_running collections.Generator.gi_yieldfrom collections.Mapping.get collections.Sequence.index +collections.Set.isdisjoint collections.abc.Callable collections.abc.Coroutine.cr_await collections.abc.Coroutine.cr_code @@ -431,6 +454,7 @@ builtins.quit # Builtins that mypy pretends exist builtins.reveal_locals builtins.reveal_type +collections.abc.* # Types are re-exported from _collections_abc, so errors should be fixed there # Various classes in typing aren't types at runtime. In addition, mypy thinks some special forms are tautologically defined. typing.[A-Z]\w+ # We can't distinguish not having a default value from having a default value of inspect.Parameter.empty