Skip to content

Commit 7982761

Browse files
authored
Replace deprecated typing imports with collections.abc (#18336)
1 parent f2a77ea commit 7982761

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+173
-113
lines changed

misc/analyze_cache.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
import os
77
import os.path
88
from collections import Counter
9-
from typing import Any, Dict, Final, Iterable
9+
from collections.abc import Iterable
10+
from typing import Any, Dict, Final
1011
from typing_extensions import TypeAlias as _TypeAlias
1112

1213
ROOT: Final = ".mypy_cache/3.5"

misc/upload-pypi.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@
1616
import tarfile
1717
import tempfile
1818
import venv
19+
from collections.abc import Iterator
1920
from concurrent.futures import ThreadPoolExecutor
2021
from pathlib import Path
21-
from typing import Any, Iterator
22+
from typing import Any
2223
from urllib.request import urlopen
2324

2425
BASE = "https://api.github.com/repos"

mypy/applytype.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

3-
from typing import Callable, Iterable, Sequence
3+
from collections.abc import Iterable, Sequence
4+
from typing import Callable
45

56
import mypy.subtypes
67
from mypy.erasetype import erase_typevars

mypy/argmap.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
from __future__ import annotations
44

5-
from typing import TYPE_CHECKING, Callable, Sequence
5+
from collections.abc import Sequence
6+
from typing import TYPE_CHECKING, Callable
67

78
from mypy import nodes
89
from mypy.maptype import map_instance_to_supertype

mypy/binder.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
from __future__ import annotations
22

33
from collections import defaultdict
4+
from collections.abc import Iterator
45
from contextlib import contextmanager
5-
from typing import DefaultDict, Iterator, List, NamedTuple, Optional, Tuple, Union
6+
from typing import DefaultDict, List, NamedTuple, Optional, Tuple, Union
67
from typing_extensions import TypeAlias as _TypeAlias
78

89
from mypy.erasetype import remove_instance_last_known_values

mypy/build.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import sys
2626
import time
2727
import types
28+
from collections.abc import Iterator, Mapping, Sequence
2829
from typing import (
2930
TYPE_CHECKING,
3031
AbstractSet,
@@ -33,11 +34,8 @@
3334
ClassVar,
3435
Dict,
3536
Final,
36-
Iterator,
37-
Mapping,
3837
NamedTuple,
3938
NoReturn,
40-
Sequence,
4139
TextIO,
4240
)
4341
from typing_extensions import TypeAlias as _TypeAlias, TypedDict

mypy/checker.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,16 @@
44

55
import itertools
66
from collections import defaultdict
7+
from collections.abc import Iterable, Iterator, Mapping, Sequence
78
from contextlib import ExitStack, contextmanager
89
from typing import (
910
AbstractSet,
1011
Callable,
1112
Dict,
1213
Final,
1314
Generic,
14-
Iterable,
15-
Iterator,
16-
Mapping,
1715
NamedTuple,
1816
Optional,
19-
Sequence,
2017
Tuple,
2118
TypeVar,
2219
Union,

mypy/checkexpr.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
import itertools
77
import time
88
from collections import defaultdict
9+
from collections.abc import Iterable, Iterator, Sequence
910
from contextlib import contextmanager
10-
from typing import Callable, ClassVar, Final, Iterable, Iterator, List, Optional, Sequence, cast
11+
from typing import Callable, ClassVar, Final, List, Optional, cast
1112
from typing_extensions import TypeAlias as _TypeAlias, assert_never, overload
1213

1314
import mypy.checker

mypy/checkmember.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
from __future__ import annotations
44

5-
from typing import TYPE_CHECKING, Callable, Sequence, cast
5+
from collections.abc import Sequence
6+
from typing import TYPE_CHECKING, Callable, cast
67

78
from mypy import meet, message_registry, subtypes
89
from mypy.erasetype import erase_typevars

mypy/checkstrformat.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
from __future__ import annotations
1414

1515
import re
16-
from typing import TYPE_CHECKING, Callable, Dict, Final, Match, Pattern, Tuple, Union, cast
16+
from re import Match, Pattern
17+
from typing import TYPE_CHECKING, Callable, Dict, Final, Tuple, Union, cast
1718
from typing_extensions import TypeAlias as _TypeAlias
1819

1920
import mypy.errorcodes as codes

0 commit comments

Comments
 (0)