Skip to content

Commit 8107e53

Browse files
authored
Update black to 24.1.1 (#16847)
1 parent c3cd83a commit 8107e53

36 files changed

+126
-138
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ repos:
66
- id: trailing-whitespace
77
- id: end-of-file-fixer
88
- repo: https://github.com/psf/black-pre-commit-mirror
9-
rev: 23.9.1 # must match test-requirements.txt
9+
rev: 24.1.1 # must match test-requirements.txt
1010
hooks:
1111
- id: black
1212
exclude: '^(test-data/)'

mypy/build.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
99
The function build() is the main interface to this module.
1010
"""
11+
1112
# TODO: More consistent terminology, e.g. path/fnam, module/id, state/file
1213

1314
from __future__ import annotations

mypy/checker.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -526,12 +526,16 @@ def check_second_pass(
526526
# print("XXX in pass %d, class %s, function %s" %
527527
# (self.pass_num, type_name, node.fullname or node.name))
528528
done.add(node)
529-
with self.tscope.class_scope(
530-
active_typeinfo
531-
) if active_typeinfo else nullcontext():
532-
with self.scope.push_class(
533-
active_typeinfo
534-
) if active_typeinfo else nullcontext():
529+
with (
530+
self.tscope.class_scope(active_typeinfo)
531+
if active_typeinfo
532+
else nullcontext()
533+
):
534+
with (
535+
self.scope.push_class(active_typeinfo)
536+
if active_typeinfo
537+
else nullcontext()
538+
):
535539
self.check_partial(node)
536540
return True
537541

@@ -3802,9 +3806,11 @@ def check_multi_assignment_from_tuple(
38023806
if star_lv:
38033807
list_expr = ListExpr(
38043808
[
3805-
self.temp_node(rv_type, context)
3806-
if not isinstance(rv_type, UnpackType)
3807-
else StarExpr(self.temp_node(rv_type.type, context))
3809+
(
3810+
self.temp_node(rv_type, context)
3811+
if not isinstance(rv_type, UnpackType)
3812+
else StarExpr(self.temp_node(rv_type.type, context))
3813+
)
38083814
for rv_type in star_rv_types
38093815
]
38103816
)
@@ -6593,8 +6599,7 @@ def check_subtype(
65936599
notes: list[str] | None = None,
65946600
code: ErrorCode | None = None,
65956601
outer_context: Context | None = None,
6596-
) -> bool:
6597-
...
6602+
) -> bool: ...
65986603

65996604
@overload
66006605
def check_subtype(
@@ -6608,8 +6613,7 @@ def check_subtype(
66086613
*,
66096614
notes: list[str] | None = None,
66106615
outer_context: Context | None = None,
6611-
) -> bool:
6612-
...
6616+
) -> bool: ...
66136617

66146618
def check_subtype(
66156619
self,
@@ -7083,14 +7087,12 @@ def conditional_types_with_intersection(
70837087
type_ranges: list[TypeRange] | None,
70847088
ctx: Context,
70857089
default: None = None,
7086-
) -> tuple[Type | None, Type | None]:
7087-
...
7090+
) -> tuple[Type | None, Type | None]: ...
70887091

70897092
@overload
70907093
def conditional_types_with_intersection(
70917094
self, expr_type: Type, type_ranges: list[TypeRange] | None, ctx: Context, default: Type
7092-
) -> tuple[Type, Type]:
7093-
...
7095+
) -> tuple[Type, Type]: ...
70947096

70957097
def conditional_types_with_intersection(
70967098
self,
@@ -7348,15 +7350,13 @@ def visit_type_var(self, t: TypeVarType) -> None:
73487350
@overload
73497351
def conditional_types(
73507352
current_type: Type, proposed_type_ranges: list[TypeRange] | None, default: None = None
7351-
) -> tuple[Type | None, Type | None]:
7352-
...
7353+
) -> tuple[Type | None, Type | None]: ...
73537354

73547355

73557356
@overload
73567357
def conditional_types(
73577358
current_type: Type, proposed_type_ranges: list[TypeRange] | None, default: Type
7358-
) -> tuple[Type, Type]:
7359-
...
7359+
) -> tuple[Type, Type]: ...
73607360

73617361

73627362
def conditional_types(

mypy/checkexpr.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2132,11 +2132,13 @@ def infer_function_type_arguments(
21322132
unknown = UninhabitedType()
21332133
unknown.ambiguous = True
21342134
inferred_args = [
2135-
expand_type(
2136-
a, {v.id: unknown for v in list(callee_type.variables) + free_vars}
2135+
(
2136+
expand_type(
2137+
a, {v.id: unknown for v in list(callee_type.variables) + free_vars}
2138+
)
2139+
if a is not None
2140+
else None
21372141
)
2138-
if a is not None
2139-
else None
21402142
for a in poly_inferred_args
21412143
]
21422144
else:
@@ -6042,14 +6044,12 @@ def bool_type(self) -> Instance:
60426044
return self.named_type("builtins.bool")
60436045

60446046
@overload
6045-
def narrow_type_from_binder(self, expr: Expression, known_type: Type) -> Type:
6046-
...
6047+
def narrow_type_from_binder(self, expr: Expression, known_type: Type) -> Type: ...
60476048

60486049
@overload
60496050
def narrow_type_from_binder(
60506051
self, expr: Expression, known_type: Type, skip_non_overlapping: bool
6051-
) -> Type | None:
6052-
...
6052+
) -> Type | None: ...
60536053

60546054
def narrow_type_from_binder(
60556055
self, expr: Expression, known_type: Type, skip_non_overlapping: bool = False

mypy/checkpattern.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -305,11 +305,10 @@ def visit_sequence_pattern(self, o: SequencePattern) -> PatternType:
305305
narrowed_inner_types = []
306306
inner_rest_types = []
307307
for inner_type, new_inner_type in zip(inner_types, new_inner_types):
308-
(
309-
narrowed_inner_type,
310-
inner_rest_type,
311-
) = self.chk.conditional_types_with_intersection(
312-
new_inner_type, [get_type_range(inner_type)], o, default=new_inner_type
308+
(narrowed_inner_type, inner_rest_type) = (
309+
self.chk.conditional_types_with_intersection(
310+
new_inner_type, [get_type_range(inner_type)], o, default=new_inner_type
311+
)
313312
)
314313
narrowed_inner_types.append(narrowed_inner_type)
315314
inner_rest_types.append(inner_rest_type)

mypy/evalexpr.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
put it in a mypyc-compiled file.
77
88
"""
9+
910
import ast
1011
from typing import Final
1112

mypy/expandtype.py

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,15 @@
5050

5151

5252
@overload
53-
def expand_type(typ: CallableType, env: Mapping[TypeVarId, Type]) -> CallableType:
54-
...
53+
def expand_type(typ: CallableType, env: Mapping[TypeVarId, Type]) -> CallableType: ...
5554

5655

5756
@overload
58-
def expand_type(typ: ProperType, env: Mapping[TypeVarId, Type]) -> ProperType:
59-
...
57+
def expand_type(typ: ProperType, env: Mapping[TypeVarId, Type]) -> ProperType: ...
6058

6159

6260
@overload
63-
def expand_type(typ: Type, env: Mapping[TypeVarId, Type]) -> Type:
64-
...
61+
def expand_type(typ: Type, env: Mapping[TypeVarId, Type]) -> Type: ...
6562

6663

6764
def expand_type(typ: Type, env: Mapping[TypeVarId, Type]) -> Type:
@@ -72,18 +69,15 @@ def expand_type(typ: Type, env: Mapping[TypeVarId, Type]) -> Type:
7269

7370

7471
@overload
75-
def expand_type_by_instance(typ: CallableType, instance: Instance) -> CallableType:
76-
...
72+
def expand_type_by_instance(typ: CallableType, instance: Instance) -> CallableType: ...
7773

7874

7975
@overload
80-
def expand_type_by_instance(typ: ProperType, instance: Instance) -> ProperType:
81-
...
76+
def expand_type_by_instance(typ: ProperType, instance: Instance) -> ProperType: ...
8277

8378

8479
@overload
85-
def expand_type_by_instance(typ: Type, instance: Instance) -> Type:
86-
...
80+
def expand_type_by_instance(typ: Type, instance: Instance) -> Type: ...
8781

8882

8983
def expand_type_by_instance(typ: Type, instance: Instance) -> Type:
@@ -470,13 +464,11 @@ def expand_types(self, types: Iterable[Type]) -> list[Type]:
470464

471465

472466
@overload
473-
def expand_self_type(var: Var, typ: ProperType, replacement: ProperType) -> ProperType:
474-
...
467+
def expand_self_type(var: Var, typ: ProperType, replacement: ProperType) -> ProperType: ...
475468

476469

477470
@overload
478-
def expand_self_type(var: Var, typ: Type, replacement: Type) -> Type:
479-
...
471+
def expand_self_type(var: Var, typ: Type, replacement: Type) -> Type: ...
480472

481473

482474
def expand_self_type(var: Var, typ: Type, replacement: Type) -> Type:

mypy/fastparse.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -608,10 +608,9 @@ def fix_function_overloads(self, stmts: list[Statement]) -> list[Statement]:
608608
# Check IfStmt block to determine if function overloads can be merged
609609
if_overload_name = self._check_ifstmt_for_overloads(stmt, current_overload_name)
610610
if if_overload_name is not None:
611-
(
612-
if_block_with_overload,
613-
if_unknown_truth_value,
614-
) = self._get_executable_if_block_with_overloads(stmt)
611+
(if_block_with_overload, if_unknown_truth_value) = (
612+
self._get_executable_if_block_with_overloads(stmt)
613+
)
615614

616615
if (
617616
current_overload_name is not None
@@ -911,9 +910,11 @@ def do_func_def(
911910
# PEP 484 disallows both type annotations and type comments
912911
self.fail(message_registry.DUPLICATE_TYPE_SIGNATURES, lineno, n.col_offset)
913912
arg_types = [
914-
a.type_annotation
915-
if a.type_annotation is not None
916-
else AnyType(TypeOfAny.unannotated)
913+
(
914+
a.type_annotation
915+
if a.type_annotation is not None
916+
else AnyType(TypeOfAny.unannotated)
917+
)
917918
for a in args
918919
]
919920
else:
@@ -1790,12 +1791,10 @@ def invalid_type(self, node: AST, note: str | None = None) -> RawExpressionType:
17901791
)
17911792

17921793
@overload
1793-
def visit(self, node: ast3.expr) -> ProperType:
1794-
...
1794+
def visit(self, node: ast3.expr) -> ProperType: ...
17951795

17961796
@overload
1797-
def visit(self, node: AST | None) -> ProperType | None:
1798-
...
1797+
def visit(self, node: AST | None) -> ProperType | None: ...
17991798

18001799
def visit(self, node: AST | None) -> ProperType | None:
18011800
"""Modified visit -- keep track of the stack of nodes"""

mypy/join.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,13 +237,11 @@ def trivial_join(s: Type, t: Type) -> Type:
237237
@overload
238238
def join_types(
239239
s: ProperType, t: ProperType, instance_joiner: InstanceJoiner | None = None
240-
) -> ProperType:
241-
...
240+
) -> ProperType: ...
242241

243242

244243
@overload
245-
def join_types(s: Type, t: Type, instance_joiner: InstanceJoiner | None = None) -> Type:
246-
...
244+
def join_types(s: Type, t: Type, instance_joiner: InstanceJoiner | None = None) -> Type: ...
247245

248246

249247
def join_types(s: Type, t: Type, instance_joiner: InstanceJoiner | None = None) -> Type:

mypy/main.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,6 @@ def infer_python_executable(options: Options, special_opts: argparse.Namespace)
342342

343343

344344
class CapturableArgumentParser(argparse.ArgumentParser):
345-
346345
"""Override ArgumentParser methods that use sys.stdout/sys.stderr directly.
347346
348347
This is needed because hijacking sys.std* is not thread-safe,
@@ -396,7 +395,6 @@ def error(self, message: str) -> NoReturn:
396395

397396

398397
class CapturableVersionAction(argparse.Action):
399-
400398
"""Supplement CapturableArgumentParser to handle --version.
401399
402400
This is nearly identical to argparse._VersionAction except,

mypy/metastore.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,7 @@ def commit(self) -> None:
6363
"""
6464

6565
@abstractmethod
66-
def list_all(self) -> Iterable[str]:
67-
...
66+
def list_all(self) -> Iterable[str]: ...
6867

6968

7069
def random_string() -> str:

mypy/nodes.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3287,13 +3287,13 @@ def serialize(self) -> JsonDict:
32873287
"declared_metaclass": (
32883288
None if self.declared_metaclass is None else self.declared_metaclass.serialize()
32893289
),
3290-
"metaclass_type": None
3291-
if self.metaclass_type is None
3292-
else self.metaclass_type.serialize(),
3290+
"metaclass_type": (
3291+
None if self.metaclass_type is None else self.metaclass_type.serialize()
3292+
),
32933293
"tuple_type": None if self.tuple_type is None else self.tuple_type.serialize(),
3294-
"typeddict_type": None
3295-
if self.typeddict_type is None
3296-
else self.typeddict_type.serialize(),
3294+
"typeddict_type": (
3295+
None if self.typeddict_type is None else self.typeddict_type.serialize()
3296+
),
32973297
"flags": get_flags(self, TypeInfo.FLAGS),
32983298
"metadata": self.metadata,
32993299
"slots": sorted(self.slots) if self.slots is not None else None,

mypy/plugins/attrs.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,11 @@ def serialize(self) -> JsonDict:
185185
"init": self.init,
186186
"kw_only": self.kw_only,
187187
"has_converter": self.converter is not None,
188-
"converter_init_type": self.converter.init_type.serialize()
189-
if self.converter and self.converter.init_type
190-
else None,
188+
"converter_init_type": (
189+
self.converter.init_type.serialize()
190+
if self.converter and self.converter.init_type
191+
else None
192+
),
191193
"context_line": self.context.line,
192194
"context_column": self.context.column,
193195
"init_type": self.init_type.serialize() if self.init_type else None,
@@ -1073,9 +1075,11 @@ def _meet_fields(types: list[Mapping[str, Type]]) -> Mapping[str, Type]:
10731075
field_to_types[name].append(typ)
10741076

10751077
return {
1076-
name: get_proper_type(reduce(meet_types, f_types))
1077-
if len(f_types) == len(types)
1078-
else UninhabitedType()
1078+
name: (
1079+
get_proper_type(reduce(meet_types, f_types))
1080+
if len(f_types) == len(types)
1081+
else UninhabitedType()
1082+
)
10791083
for name, f_types in field_to_types.items()
10801084
}
10811085

mypy/plugins/enums.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
we actually bake some of it directly in to the semantic analysis layer (see
1111
semanal_enum.py).
1212
"""
13+
1314
from __future__ import annotations
1415

1516
from typing import Final, Iterable, Sequence, TypeVar, cast

mypy/plugins/functools.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Plugin for supporting the functools standard library module."""
2+
23
from __future__ import annotations
34

45
from typing import Final, NamedTuple

0 commit comments

Comments
 (0)