|
1 | | -import abc |
2 | | -import collections |
3 | 1 | import contextlib |
| 2 | +import collections |
| 3 | +from collections import defaultdict |
| 4 | +from functools import lru_cache, wraps |
4 | 5 | import inspect |
5 | 6 | import itertools |
6 | 7 | import pickle |
7 | 8 | import re |
8 | 9 | import sys |
| 10 | +import warnings |
| 11 | +from unittest import TestCase, main, skipUnless, skip |
| 12 | +from unittest.mock import patch |
| 13 | +from copy import copy, deepcopy |
| 14 | + |
| 15 | +from typing import Any, NoReturn, Never, assert_never |
| 16 | +from typing import overload, get_overloads, clear_overloads |
| 17 | +from typing import TypeVar, TypeVarTuple, Unpack, AnyStr |
| 18 | +from typing import T, KT, VT # Not in __all__. |
| 19 | +from typing import Union, Optional, Literal |
| 20 | +from typing import Tuple, List, Dict, MutableMapping |
| 21 | +from typing import Callable |
| 22 | +from typing import Generic, ClassVar, Final, final, Protocol |
| 23 | +from typing import assert_type, cast, runtime_checkable |
| 24 | +from typing import get_type_hints |
| 25 | +from typing import get_origin, get_args |
| 26 | +from typing import override |
| 27 | +from typing import is_typeddict |
| 28 | +from typing import reveal_type |
| 29 | +from typing import dataclass_transform |
| 30 | +from typing import no_type_check, no_type_check_decorator |
| 31 | +from typing import Type |
| 32 | +from typing import NamedTuple, NotRequired, Required, TypedDict |
| 33 | +from typing import IO, TextIO, BinaryIO |
| 34 | +from typing import Pattern, Match |
| 35 | +from typing import Annotated, ForwardRef |
| 36 | +from typing import Self, LiteralString |
| 37 | +from typing import TypeAlias |
| 38 | +from typing import ParamSpec, Concatenate, ParamSpecArgs, ParamSpecKwargs |
| 39 | +from typing import TypeGuard |
| 40 | +import abc |
9 | 41 | import textwrap |
10 | | -import types |
11 | 42 | import typing |
12 | | -import warnings |
13 | 43 | import weakref |
14 | | -from collections import defaultdict |
15 | | -from copy import copy, deepcopy |
16 | | -from functools import lru_cache, wraps |
17 | | -from test import _typed_dict_helper, mod_generics_cache |
18 | | -from test.support import captured_stderr, cpython_only, import_helper |
19 | | -from typing import (IO, KT, VT, Annotated, Any, AnyStr, # Not in __all__. |
20 | | - BinaryIO, Callable, ClassVar, Concatenate, Dict, Final, |
21 | | - ForwardRef, Generic, List, Literal, LiteralString, Match, |
22 | | - MutableMapping, NamedTuple, Never, NoReturn, NotRequired, |
23 | | - Optional, ParamSpec, ParamSpecArgs, ParamSpecKwargs, |
24 | | - Pattern, Protocol, Required, Self, T, TextIO, Tuple, Type, |
25 | | - TypeAlias, TypedDict, TypeGuard, TypeVar, TypeVarTuple, |
26 | | - Union, Unpack, assert_never, assert_type, cast, |
27 | | - clear_overloads, dataclass_transform, final, get_args, |
28 | | - get_origin, get_overloads, get_type_hints, is_typeddict, |
29 | | - no_type_check, no_type_check_decorator, overload, override, |
30 | | - reveal_type, runtime_checkable) |
31 | | -from unittest import TestCase, main, skip, skipUnless |
32 | | -from unittest.mock import patch |
| 44 | +import types |
| 45 | + |
| 46 | +from test.support import import_helper, captured_stderr, cpython_only |
| 47 | +from test import mod_generics_cache |
| 48 | +from test import _typed_dict_helper |
| 49 | + |
33 | 50 |
|
34 | 51 | CANNOT_SUBCLASS_TYPE = 'Cannot subclass special typing classes' |
35 | 52 | NOT_A_BASE_TYPE = "type 'typing.%s' is not an acceptable base type" |
@@ -4734,7 +4751,6 @@ def test_errors(self): |
4734 | 4751 | # We need this to make sure that `@no_type_check` respects `__module__` attr: |
4735 | 4752 | from test import ann_module8 |
4736 | 4753 |
|
4737 | | - |
4738 | 4754 | @no_type_check |
4739 | 4755 | class NoTypeCheck_Outer: |
4740 | 4756 | Inner = ann_module8.NoTypeCheck_Outer.Inner |
@@ -7344,7 +7360,7 @@ def stuff(a: BinaryIO) -> bytes: |
7344 | 7360 | def test_io_submodule(self): |
7345 | 7361 | with warnings.catch_warnings(record=True) as w: |
7346 | 7362 | warnings.filterwarnings("default", category=DeprecationWarning) |
7347 | | - from typing.io import IO, BinaryIO, TextIO, __all__, __name__ |
| 7363 | + from typing.io import IO, TextIO, BinaryIO, __all__, __name__ |
7348 | 7364 | self.assertIs(IO, typing.IO) |
7349 | 7365 | self.assertIs(TextIO, typing.TextIO) |
7350 | 7366 | self.assertIs(BinaryIO, typing.BinaryIO) |
@@ -8568,7 +8584,6 @@ class AllTests(BaseTestCase): |
8568 | 8584 |
|
8569 | 8585 | def test_all(self): |
8570 | 8586 | from typing import __all__ as a |
8571 | | - |
8572 | 8587 | # Just spot-check the first and last of every category. |
8573 | 8588 | self.assertIn('AbstractSet', a) |
8574 | 8589 | self.assertIn('ValuesView', a) |
|
0 commit comments