|
4 | 4 |
|
5 | 5 | import itertools |
6 | 6 | from collections import defaultdict |
7 | | -from collections.abc import Iterable, Iterator, Mapping, Sequence, Set as AbstractSet |
| 7 | +from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence, Set as AbstractSet |
8 | 8 | from contextlib import ExitStack, contextmanager |
9 | 9 | from typing import ( |
10 | | - Callable, |
11 | 10 | Final, |
12 | 11 | Generic, |
13 | 12 | Literal, |
14 | 13 | NamedTuple, |
15 | | - Optional, |
| 14 | + TypeAlias as _TypeAlias, |
| 15 | + TypeGuard, |
16 | 16 | TypeVar, |
17 | | - Union, |
18 | 17 | cast, |
19 | 18 | overload, |
20 | 19 | ) |
21 | | -from typing_extensions import TypeAlias as _TypeAlias, TypeGuard |
22 | 20 |
|
23 | 21 | import mypy.checkexpr |
24 | 22 | from mypy import errorcodes as codes, join, message_registry, nodes, operators |
|
247 | 245 | # Maximum length of fixed tuple types inferred when narrowing from variadic tuples. |
248 | 246 | MAX_PRECISE_TUPLE_SIZE: Final = 8 |
249 | 247 |
|
250 | | -DeferredNodeType: _TypeAlias = Union[FuncDef, OverloadedFuncDef, Decorator] |
251 | | -FineGrainedDeferredNodeType: _TypeAlias = Union[FuncDef, MypyFile, OverloadedFuncDef] |
| 248 | +DeferredNodeType: _TypeAlias = FuncDef | OverloadedFuncDef | Decorator |
| 249 | +FineGrainedDeferredNodeType: _TypeAlias = FuncDef | MypyFile | OverloadedFuncDef |
252 | 250 |
|
253 | 251 |
|
254 | 252 | # A node which is postponed to be processed during the next pass. |
@@ -281,7 +279,7 @@ class FineGrainedDeferredNode(NamedTuple): |
281 | 279 | # (such as two references to the same variable). TODO: it would |
282 | 280 | # probably be better to have the dict keyed by the nodes' literal_hash |
283 | 281 | # field instead. |
284 | | -TypeMap: _TypeAlias = Optional[dict[Expression, Type]] |
| 282 | +TypeMap: _TypeAlias = dict[Expression, Type] | None |
285 | 283 |
|
286 | 284 |
|
287 | 285 | # Keeps track of partial types in a single scope. In fine-grained incremental |
|
0 commit comments