Skip to content

Commit 1c427e7

Browse files
authored
Update typing_extensions imports for Python 3.9 (#18383)
1 parent 80e5e8b commit 1c427e7

File tree

12 files changed

+42
-31
lines changed

12 files changed

+42
-31
lines changed

mypy/build.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,18 @@
2626
import time
2727
import types
2828
from collections.abc import Iterator, Mapping, Sequence, Set as AbstractSet
29-
from typing import TYPE_CHECKING, Any, Callable, ClassVar, Final, NamedTuple, NoReturn, TextIO
30-
from typing_extensions import TypeAlias as _TypeAlias, TypedDict
29+
from typing import (
30+
TYPE_CHECKING,
31+
Any,
32+
Callable,
33+
ClassVar,
34+
Final,
35+
NamedTuple,
36+
NoReturn,
37+
TextIO,
38+
TypedDict,
39+
)
40+
from typing_extensions import TypeAlias as _TypeAlias
3141

3242
import mypy.semanal_main
3343
from mypy.checker import TypeChecker

mypy/checkexpr.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
from collections import defaultdict
99
from collections.abc import Iterable, Iterator, Sequence
1010
from contextlib import contextmanager
11-
from typing import Callable, ClassVar, Final, Optional, cast
12-
from typing_extensions import TypeAlias as _TypeAlias, assert_never, overload
11+
from typing import Callable, ClassVar, Final, Optional, cast, overload
12+
from typing_extensions import TypeAlias as _TypeAlias, assert_never
1313

1414
import mypy.checker
1515
import mypy.errorcodes as codes

mypy/fastparse.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
import sys
55
import warnings
66
from collections.abc import Sequence
7-
from typing import Any, Callable, Final, Optional, TypeVar, Union, cast
8-
from typing_extensions import Literal, overload
7+
from typing import Any, Callable, Final, Literal, Optional, TypeVar, Union, cast, overload
98

109
from mypy import defaults, errorcodes as codes, message_registry
1110
from mypy.errors import Errors

mypy/plugins/attrs.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
from collections import defaultdict
66
from collections.abc import Iterable, Mapping
77
from functools import reduce
8-
from typing import Final, cast
9-
from typing_extensions import Literal
8+
from typing import Final, Literal, cast
109

1110
import mypy.plugin # To avoid circular imports.
1211
from mypy.applytype import apply_generic_arguments

mypy/semanal_shared.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
from __future__ import annotations
44

55
from abc import abstractmethod
6-
from typing import Callable, Final, overload
7-
from typing_extensions import Literal, Protocol
6+
from typing import Callable, Final, Literal, Protocol, overload
87

98
from mypy_extensions import trait
109

mypy/stubtest.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
from contextlib import redirect_stderr, redirect_stdout
3030
from functools import singledispatch
3131
from pathlib import Path
32-
from typing import Any, Generic, TypeVar, Union
32+
from typing import Any, Final, Generic, TypeVar, Union
3333
from typing_extensions import get_origin, is_typeddict
3434

3535
import mypy.build
@@ -52,7 +52,7 @@ def __repr__(self) -> str:
5252
return "MISSING"
5353

5454

55-
MISSING: typing_extensions.Final = Missing()
55+
MISSING: Final = Missing()
5656

5757
T = TypeVar("T")
5858
MaybeMissing: typing_extensions.TypeAlias = Union[T, Missing]
@@ -65,10 +65,10 @@ def __repr__(self) -> str:
6565
return "<unrepresentable>"
6666

6767

68-
UNREPRESENTABLE: typing_extensions.Final = Unrepresentable()
68+
UNREPRESENTABLE: Final = Unrepresentable()
6969

7070

71-
_formatter: typing_extensions.Final = FancyFormatter(sys.stdout, sys.stderr, False)
71+
_formatter: Final = FancyFormatter(sys.stdout, sys.stderr, False)
7272

7373

7474
def _style(message: str, **kwargs: Any) -> str:
@@ -1447,7 +1447,7 @@ def verify_typealias(
14471447
# ====================
14481448

14491449

1450-
IGNORED_MODULE_DUNDERS: typing_extensions.Final = frozenset(
1450+
IGNORED_MODULE_DUNDERS: Final = frozenset(
14511451
{
14521452
"__file__",
14531453
"__doc__",
@@ -1469,7 +1469,7 @@ def verify_typealias(
14691469
}
14701470
)
14711471

1472-
IGNORABLE_CLASS_DUNDERS: typing_extensions.Final = frozenset(
1472+
IGNORABLE_CLASS_DUNDERS: Final = frozenset(
14731473
{
14741474
# Special attributes
14751475
"__dict__",
@@ -1915,9 +1915,7 @@ class _Arguments:
19151915

19161916

19171917
# typeshed added a stub for __main__, but that causes stubtest to check itself
1918-
ANNOYING_STDLIB_MODULES: typing_extensions.Final = frozenset(
1919-
{"antigravity", "this", "__main__", "_ios_support"}
1920-
)
1918+
ANNOYING_STDLIB_MODULES: Final = frozenset({"antigravity", "this", "__main__", "_ios_support"})
19211919

19221920

19231921
def test_stubs(args: _Arguments, use_builtins_fixtures: bool = False) -> int:

mypy/stubutil.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
from collections import defaultdict
1111
from collections.abc import Iterable, Iterator, Mapping
1212
from contextlib import contextmanager
13-
from typing import Final
14-
from typing_extensions import overload
13+
from typing import Final, overload
1514

1615
from mypy_extensions import mypyc_attr
1716

mypy/suggestions.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@
2929
import os
3030
from collections.abc import Iterator
3131
from contextlib import contextmanager
32-
from typing import Callable, NamedTuple, TypeVar, cast
33-
from typing_extensions import TypedDict
32+
from typing import Callable, NamedTuple, TypedDict, TypeVar, cast
3433

3534
from mypy.argmap import map_actuals_to_formals
3635
from mypy.build import Graph, State

mypy/typeanal.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
import itertools
66
from collections.abc import Iterable, Iterator, Sequence
77
from contextlib import contextmanager
8-
from typing import Callable, Final, TypeVar
9-
from typing_extensions import Protocol
8+
from typing import Callable, Final, Protocol, TypeVar
109

1110
from mypy import errorcodes as codes, message_registry, nodes
1211
from mypy.errorcodes import ErrorCode

mypy/types.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,19 @@
55
import sys
66
from abc import abstractmethod
77
from collections.abc import Iterable, Sequence
8-
from typing import TYPE_CHECKING, Any, ClassVar, Final, NamedTuple, NewType, TypeVar, Union, cast
9-
from typing_extensions import Self, TypeAlias as _TypeAlias, TypeGuard, overload
8+
from typing import (
9+
TYPE_CHECKING,
10+
Any,
11+
ClassVar,
12+
Final,
13+
NamedTuple,
14+
NewType,
15+
TypeVar,
16+
Union,
17+
cast,
18+
overload,
19+
)
20+
from typing_extensions import Self, TypeAlias as _TypeAlias, TypeGuard
1021

1122
import mypy.nodes
1223
from mypy.bogus_type import Bogus

0 commit comments

Comments
 (0)