Skip to content

Commit 07bbafb

Browse files
committed
format
1 parent 45bd5c4 commit 07bbafb

File tree

4 files changed

+18
-22
lines changed

4 files changed

+18
-22
lines changed

mypy/applytype.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def apply_generic_arguments(
157157
assert False, "mypy bug: unhandled case applying unpack"
158158
else:
159159
callable = callable.copy_modified(
160-
arg_types = [expand_type(at, id_to_type) for at in callable.arg_types]
160+
arg_types=[expand_type(at, id_to_type) for at in callable.arg_types]
161161
)
162162

163163
# Apply arguments to TypeGuard if any.

mypy/checkexpr.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@
124124
LITERAL_TYPE_NAMES,
125125
TUPLE_LIKE_INSTANCE_NAMES,
126126
AnyType,
127-
UnpackType,
128127
CallableType,
129128
DeletedType,
130129
ErasedType,
@@ -150,6 +149,7 @@
150149
TypeVarType,
151150
UninhabitedType,
152151
UnionType,
152+
UnpackType,
153153
flatten_nested_unions,
154154
get_proper_type,
155155
get_proper_types,
@@ -2025,13 +2025,17 @@ def check_argument_types(
20252025
and isinstance(get_proper_type(first_actual_arg_type.items[0]), UnpackType)
20262026
):
20272027
# TODO: use walrus operator
2028-
actual_types = [first_actual_arg_type.items[0]] + [arg_types[a] for a in actuals[1:]]
2028+
actual_types = [first_actual_arg_type.items[0]] + [
2029+
arg_types[a] for a in actuals[1:]
2030+
]
20292031
actual_kinds = [nodes.ARG_STAR] + [nodes.ARG_POS] * (len(actuals) - 1)
20302032

20312033
assert isinstance(orig_callee_arg_type, TupleType)
20322034
assert orig_callee_arg_type.items
20332035
callee_arg_types = orig_callee_arg_type.items
2034-
callee_arg_kinds = [nodes.ARG_STAR] + [nodes.ARG_POS] * (len(orig_callee_arg_type.items) - 1)
2036+
callee_arg_kinds = [nodes.ARG_STAR] + [nodes.ARG_POS] * (
2037+
len(orig_callee_arg_type.items) - 1
2038+
)
20352039
expanded_tuple = True
20362040

20372041
if not expanded_tuple:
@@ -2059,7 +2063,9 @@ def check_argument_types(
20592063
assert len(callee_arg_types) == len(actual_types)
20602064
assert len(callee_arg_types) == len(actual_kinds)
20612065
assert len(callee_arg_types) == len(callee_arg_kinds)
2062-
for actual, actual_type, actual_kind, callee_arg_type, callee_arg_kind in zip(actuals, actual_types, actual_kinds, callee_arg_types, callee_arg_kinds):
2066+
for actual, actual_type, actual_kind, callee_arg_type, callee_arg_kind in zip(
2067+
actuals, actual_types, actual_kinds, callee_arg_types, callee_arg_kinds
2068+
):
20632069
if actual_type is None:
20642070
continue # Some kind of error was already reported.
20652071
# Check that a *arg is valid as varargs.

mypy/constraints.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,7 @@ def infer_constraints_for_callable(
135135

136136
unpacked_type = get_proper_type(unpack_type.type)
137137
if isinstance(unpacked_type, TypeVarTupleType):
138-
constraints.append(
139-
Constraint(unpacked_type, SUPERTYPE_OF, TypeList(actual_types))
140-
)
138+
constraints.append(Constraint(unpacked_type, SUPERTYPE_OF, TypeList(actual_types)))
141139
elif isinstance(unpacked_type, TupleType):
142140
# Prefixes get converted to positional args, so technically the only case we
143141
# should have here is like Tuple[Unpack[Ts], Y1, Y2, Y3]. If this turns out

mypy/typevartuples.py

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
from typing import Sequence, TypeVar
66

7-
from mypy.types import Instance, ProperType, Type, UnpackType, get_proper_type, CallableType
8-
from mypy.nodes import ARG_STAR, ARG_POS
7+
from mypy.nodes import ARG_POS, ARG_STAR
8+
from mypy.types import CallableType, Instance, ProperType, Type, UnpackType, get_proper_type
99

1010

1111
def find_unpack_in_list(items: Sequence[Type]) -> int | None:
@@ -155,24 +155,16 @@ def extract_unpack(types: Sequence[Type]) -> ProperType | None:
155155

156156
def replace_starargs(callable: CallableType, types: list[Type]) -> CallableType:
157157
star_index = callable.arg_kinds.index(ARG_STAR)
158-
arg_kinds = (
158+
arg_kinds = (
159159
callable.arg_kinds[:star_index]
160-
+ [ARG_POS] * len(types)
160+
+ [ARG_POS] * len(types)
161161
+ callable.arg_kinds[star_index + 1 :]
162162
)
163163
arg_names = (
164164
callable.arg_names[:star_index]
165165
+ [None] * len(types)
166166
+ callable.arg_names[star_index + 1 :]
167167
)
168-
arg_types = (
169-
callable.arg_types[:star_index]
170-
+ types
171-
+ callable.arg_types[star_index + 1 :]
172-
)
168+
arg_types = callable.arg_types[:star_index] + types + callable.arg_types[star_index + 1 :]
173169

174-
return callable.copy_modified(
175-
arg_types=arg_types,
176-
arg_names=arg_names,
177-
arg_kinds=arg_kinds,
178-
)
170+
return callable.copy_modified(arg_types=arg_types, arg_names=arg_names, arg_kinds=arg_kinds)

0 commit comments

Comments
 (0)