Skip to content

Commit 68804c8

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent d9dbf19 commit 68804c8

Some content is hidden

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

107 files changed

+396
-387
lines changed

misc/analyze_cache.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
import os.path
88
from collections import Counter
99
from collections.abc import Iterable
10-
from typing import Any, Final
11-
from typing_extensions import TypeAlias as _TypeAlias
10+
from typing import Any, Final, TypeAlias as _TypeAlias
1211

1312
ROOT: Final = ".mypy_cache/3.5"
1413

misc/diff-cache.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ def load(cache: MetadataStore, s: str) -> Any:
4242
if "dependencies" in obj:
4343
all_deps = obj["dependencies"] + obj["suppressed"]
4444
num_deps = len(obj["dependencies"])
45-
thing = list(zip(all_deps, obj["dep_prios"], obj["dep_lines"]))
45+
thing = list(zip(all_deps, obj["dep_prios"], obj["dep_lines"], strict=False))
4646

4747
def unzip(x: Any) -> Any:
48-
return zip(*x) if x else ((), (), ())
48+
return zip(*x, strict=False) if x else ((), (), ())
4949

5050
obj["dependencies"], prios1, lines1 = unzip(sorted(thing[:num_deps]))
5151
obj["suppressed"], prios2, lines2 = unzip(sorted(thing[num_deps:]))

misc/incremental_checker.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@
4444
import textwrap
4545
import time
4646
from argparse import ArgumentParser, Namespace, RawDescriptionHelpFormatter
47-
from typing import Any, Final
48-
from typing_extensions import TypeAlias as _TypeAlias
47+
from typing import Any, Final, TypeAlias as _TypeAlias
4948

5049
CACHE_PATH: Final = ".incremental_checker_cache.json"
5150
MYPY_REPO_URL: Final = "https://github.com/python/mypy.git"

misc/perf_checker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import subprocess
99
import textwrap
1010
import time
11-
from typing import Callable
11+
from collections.abc import Callable
1212

1313

1414
class Command:

mypy/api.py

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

4848
import sys
49+
from collections.abc import Callable
4950
from io import StringIO
50-
from typing import Callable, TextIO
51+
from typing import TextIO
5152

5253

5354
def _run(main_wrapper: Callable[[TextIO, TextIO], None]) -> tuple[str, str, int]:

mypy/applytype.py

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

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

65
import mypy.subtypes
76
from mypy.erasetype import erase_typevars
@@ -108,7 +107,7 @@ def apply_generic_arguments(
108107
# Create a map from type variable id to target type.
109108
id_to_type: dict[TypeVarId, Type] = {}
110109

111-
for tvar, type in zip(tvars, orig_types):
110+
for tvar, type in zip(tvars, orig_types, strict=False):
112111
assert not isinstance(type, PartialType), "Internal error: must never apply partial type"
113112
if type is None:
114113
continue

mypy/argmap.py

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

33
from __future__ import annotations
44

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

88
from mypy import nodes
99
from mypy.maptype import map_instance_to_supertype

mypy/binder.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
from collections import defaultdict
44
from collections.abc import Iterator
55
from contextlib import contextmanager
6-
from typing import NamedTuple, Optional, Union
7-
from typing_extensions import TypeAlias as _TypeAlias
6+
from typing import NamedTuple, TypeAlias as _TypeAlias
87

98
from mypy.erasetype import remove_instance_last_known_values
109
from mypy.literals import Key, extract_var_from_literal_hash, literal, literal_hash, subkeys
@@ -39,7 +38,7 @@
3938
)
4039
from mypy.typevars import fill_typevars_with_any
4140

42-
BindableExpression: _TypeAlias = Union[IndexExpr, MemberExpr, NameExpr]
41+
BindableExpression: _TypeAlias = IndexExpr | MemberExpr | NameExpr
4342

4443

4544
class CurrentType(NamedTuple):
@@ -81,7 +80,7 @@ def __repr__(self) -> str:
8180
return f"Frame({self.id}, {self.types}, {self.unreachable}, {self.conditional_frame})"
8281

8382

84-
Assigns = defaultdict[Expression, list[tuple[Type, Optional[Type]]]]
83+
Assigns = defaultdict[Expression, list[tuple[Type, Type | None]]]
8584

8685

8786
class ConditionalTypeBinder:

mypy/build.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,17 @@
2424
import sys
2525
import time
2626
import types
27-
from collections.abc import Iterator, Mapping, Sequence, Set as AbstractSet
28-
from typing import TYPE_CHECKING, Any, Callable, ClassVar, Final, NoReturn, TextIO, TypedDict
29-
from typing_extensions import TypeAlias as _TypeAlias
27+
from collections.abc import Callable, Iterator, Mapping, Sequence, Set as AbstractSet
28+
from typing import (
29+
TYPE_CHECKING,
30+
Any,
31+
ClassVar,
32+
Final,
33+
NoReturn,
34+
TextIO,
35+
TypeAlias as _TypeAlias,
36+
TypedDict,
37+
)
3038

3139
import mypy.semanal_main
3240
from mypy.cache import Buffer, CacheMeta
@@ -1974,12 +1982,12 @@ def __init__(
19741982
self.suppressed_set = set(self.suppressed)
19751983
all_deps = self.dependencies + self.suppressed
19761984
assert len(all_deps) == len(self.meta.dep_prios)
1977-
self.priorities = {id: pri for id, pri in zip(all_deps, self.meta.dep_prios)}
1985+
self.priorities = {id: pri for id, pri in zip(all_deps, self.meta.dep_prios, strict=False)}
19781986
assert len(all_deps) == len(self.meta.dep_lines)
1979-
self.dep_line_map = {id: line for id, line in zip(all_deps, self.meta.dep_lines)}
1987+
self.dep_line_map = {id: line for id, line in zip(all_deps, self.meta.dep_lines, strict=False)}
19801988
assert len(self.meta.dep_hashes) == len(self.meta.dependencies)
19811989
self.dep_hashes = {
1982-
k: v for (k, v) in zip(self.meta.dependencies, self.meta.dep_hashes)
1990+
k: v for (k, v) in zip(self.meta.dependencies, self.meta.dep_hashes, strict=False)
19831991
}
19841992
self.error_lines = self.meta.error_lines
19851993
if temporary:

mypy/cache.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@
4545
from __future__ import annotations
4646

4747
from collections.abc import Sequence
48-
from typing import Any, Final, Union
49-
from typing_extensions import TypeAlias as _TypeAlias
48+
from typing import Any, Final, TypeAlias as _TypeAlias
5049

5150
from librt.internal import (
5251
Buffer as Buffer,
@@ -384,7 +383,7 @@ def write_str_opt_list(data: Buffer, value: list[str | None]) -> None:
384383
write_str_opt(data, item)
385384

386385

387-
JsonValue: _TypeAlias = Union[None, int, str, bool, list["JsonValue"], dict[str, "JsonValue"]]
386+
JsonValue: _TypeAlias = None | int | str | bool | list["JsonValue"] | dict[str, "JsonValue"]
388387

389388

390389
def read_json_value(data: Buffer) -> JsonValue:

0 commit comments

Comments
 (0)