|
6 | 6 | """
|
7 | 7 |
|
8 | 8 | # NOTE: This module must support Python 2.7 in addition to Python 3.x
|
9 |
| -__all__ = ['TypedDict', 'AsyncGenerator'] |
10 | 9 |
|
11 | 10 | import sys
|
12 | 11 | # _type_check is NOT a part of public typing API, it is used here only to mimic
|
13 | 12 | # the (convenient) behavior of types provided by typing module.
|
14 | 13 | from typing import _type_check # type: ignore
|
15 | 14 |
|
16 |
| -if sys.version_info >= (3, 6): |
17 |
| - # if our typing version doesn't have https://github.com/python/typing/pull/346, emulate it |
18 |
| - try: |
19 |
| - from typing import AsyncGenerator |
20 |
| - except ImportError: |
21 |
| - import collections |
22 |
| - from typing import AsyncIterator, Generic, _generic_new, T_co, T_contra |
23 |
| - |
24 |
| - _AG_base = collections.AsyncGenerator |
25 |
| - |
26 |
| - # need exec because the class keyword arg is a syntax error in 2.7 |
27 |
| - exec(""" |
28 |
| -class AsyncGenerator(AsyncIterator[T_co], Generic[T_co, T_contra], |
29 |
| - extra=_AG_base): |
30 |
| - __slots__ = () |
31 |
| -
|
32 |
| - def __new__(cls, *args, **kwds): |
33 |
| - if _geqv(cls, AsyncGenerator): |
34 |
| - raise TypeError("Type AsyncGenerator cannot be instantiated; " |
35 |
| - "create a subclass instead") |
36 |
| - return _generic_new(_AG_base, cls, *args, **kwds) |
37 |
| -""") |
38 |
| - |
39 | 15 |
|
40 | 16 | def _check_fails(cls, other):
|
41 | 17 | try:
|
|
0 commit comments