Skip to content

Commit dcdcc60

Browse files
authored
Run pyupgrade --py38-plus on the source code (#15575)
1 parent 49d95cf commit dcdcc60

Some content is hidden

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

80 files changed

+137
-168
lines changed

misc/analyze_cache.py

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

1212
ROOT: Final = ".mypy_cache/3.5"
1313

misc/incremental_checker.py

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

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

mypy/build.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,15 @@
3131
Callable,
3232
ClassVar,
3333
Dict,
34+
Final,
3435
Iterator,
3536
Mapping,
3637
NamedTuple,
3738
NoReturn,
3839
Sequence,
3940
TextIO,
4041
)
41-
from typing_extensions import Final, TypeAlias as _TypeAlias, TypedDict
42+
from typing_extensions import TypeAlias as _TypeAlias, TypedDict
4243

4344
import mypy.semanal_main
4445
from mypy.checker import TypeChecker

mypy/checker.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
AbstractSet,
1010
Callable,
1111
Dict,
12+
Final,
1213
Generic,
1314
Iterable,
1415
Iterator,
@@ -22,7 +23,7 @@
2223
cast,
2324
overload,
2425
)
25-
from typing_extensions import Final, TypeAlias as _TypeAlias
26+
from typing_extensions import TypeAlias as _TypeAlias
2627

2728
import mypy.checkexpr
2829
from mypy import errorcodes as codes, message_registry, nodes, operators
@@ -1546,7 +1547,7 @@ def check_reverse_op_method(
15461547
if opt_meta is not None:
15471548
forward_inst = opt_meta
15481549

1549-
def has_readable_member(typ: Union[UnionType, Instance], name: str) -> bool:
1550+
def has_readable_member(typ: UnionType | Instance, name: str) -> bool:
15501551
# TODO: Deal with attributes of TupleType etc.
15511552
if isinstance(typ, Instance):
15521553
return typ.type.has_readable_member(name)

mypy/checkexpr.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
import time
77
from collections import defaultdict
88
from contextlib import contextmanager
9-
from typing import Callable, ClassVar, Iterable, Iterator, List, Optional, Sequence, cast
10-
from typing_extensions import Final, TypeAlias as _TypeAlias, overload
9+
from typing import Callable, ClassVar, Final, Iterable, Iterator, List, Optional, Sequence, cast
10+
from typing_extensions import TypeAlias as _TypeAlias, overload
1111

1212
import mypy.checker
1313
import mypy.errorcodes as codes
@@ -5581,7 +5581,7 @@ def replace_callable_return_type(c: CallableType, new_ret_type: Type) -> Callabl
55815581
return c.copy_modified(ret_type=new_ret_type)
55825582

55835583

5584-
def apply_poly(tp: CallableType, poly_tvars: Sequence[TypeVarLikeType]) -> Optional[CallableType]:
5584+
def apply_poly(tp: CallableType, poly_tvars: Sequence[TypeVarLikeType]) -> CallableType | None:
55855585
"""Make free type variables generic in the type if possible.
55865586
55875587
This will translate the type `tp` while trying to create valid bindings for

mypy/checkpattern.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 collections import defaultdict
6-
from typing import NamedTuple
7-
from typing_extensions import Final
6+
from typing import Final, NamedTuple
87

98
import mypy.checker
109
from mypy import message_registry

mypy/checkstrformat.py

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

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

1919
import mypy.errorcodes as codes
2020
from mypy.errors import Errors

mypy/config_parser.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
Any,
2020
Callable,
2121
Dict,
22+
Final,
2223
Iterable,
2324
List,
2425
Mapping,
@@ -28,7 +29,7 @@
2829
Tuple,
2930
Union,
3031
)
31-
from typing_extensions import Final, TypeAlias as _TypeAlias
32+
from typing_extensions import TypeAlias as _TypeAlias
3233

3334
from mypy import defaults
3435
from mypy.options import PER_MODULE_OPTIONS, Options

mypy/constant_fold.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55

66
from __future__ import annotations
77

8-
from typing import Union
9-
from typing_extensions import Final
8+
from typing import Final, Union
109

1110
from mypy.nodes import (
1211
ComplexExpr,

mypy/constraints.py

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

33
from __future__ import annotations
44

5-
from typing import TYPE_CHECKING, Iterable, List, Sequence, cast
6-
from typing_extensions import Final
5+
from typing import TYPE_CHECKING, Final, Iterable, List, Sequence, cast
76

87
import mypy.subtypes
98
import mypy.typeops

0 commit comments

Comments
 (0)