Skip to content

Commit 1c4e237

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

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

mypy/constraints.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -388,35 +388,35 @@ def _infer_constraints(
388388
if isinstance(template_proper, UnionType) and len(template_proper.items) == 2:
389389
type_var_items = []
390390
non_type_var_items = []
391-
391+
392392
for t_item in template_proper.items:
393393
t_item_proper = get_proper_type(t_item)
394394
if isinstance(t_item_proper, TypeVarType):
395395
type_var_items.append(t_item_proper)
396396
else:
397397
non_type_var_items.append(t_item_proper)
398-
398+
399399
if len(type_var_items) == 1 and len(non_type_var_items) == 1:
400400
# This is Union[T, X] vs Union[Y, Z] case
401401
type_var = type_var_items[0]
402402
non_type_var = non_type_var_items[0]
403-
403+
404404
# Check if any actual items are NOT subtypes of the non-type-var part
405405
compatible_items = []
406406
actual_proper = get_proper_type(actual)
407407
if isinstance(actual_proper, UnionType):
408408
for actual_item in actual_proper.items:
409409
if not mypy.subtypes.is_subtype(actual_item, non_type_var):
410410
compatible_items.append(actual_item)
411-
411+
412412
# If we have compatible items, create constraint for the type variable
413413
if compatible_items:
414414
if len(compatible_items) == 1:
415415
return [Constraint(type_var, SUBTYPE_OF, compatible_items[0])]
416416
else:
417417
union_type = UnionType.make_union(compatible_items)
418418
return [Constraint(type_var, SUBTYPE_OF, union_type)]
419-
419+
420420
res = []
421421
for a_item in actual.items:
422422
# `orig_template` has to be preserved intact in case it's recursive.

test-data/unit/check-typevar-union.test

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ T = TypeVar('T')
8888
class CreateProject:
8989
jsonFilePath: pathlib.Path
9090

91-
@dataclass
91+
@dataclass
9292
class LoadProject:
9393
jsonFilePath: pathlib.Path
9494

@@ -122,7 +122,7 @@ T = TypeVar('T')
122122
class CreateProject:
123123
jsonFilePath: pathlib.Path
124124

125-
@dataclass
125+
@dataclass
126126
class LoadProject:
127127
jsonFilePath: pathlib.Path
128128

@@ -142,4 +142,4 @@ def main() -> None:
142142
project: Project = reveal_type(value(maybeCancelled)) # N: Revealed type is "__main__.CreateProject | __main__.LoadProject | __main__.MigrateProject"
143143

144144
[builtins fixtures/tuple.pyi]
145-
[typing fixtures/typing-medium.pyi]
145+
[typing fixtures/typing-medium.pyi]

0 commit comments

Comments
 (0)