Add _collections_abc module (#4000)

* Add _collections_abc module
* Rearrange collections.abc and collections to re-export from _collections_abc

Co-authored-by: Sebastian Rittau <srittau@rittau.biz>
This commit is contained in:
Rune Tynan
2021-01-23 10:17:57 -05:00
committed by GitHub
parent b85f46eb07
commit 6aa5cc691c
8 changed files with 118 additions and 69 deletions

View File

@@ -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",
]

View File

@@ -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")

View File

@@ -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__