Skip to content

Commit 529df9f

Browse files
committed
EXPERIMENT remove line/column param to make_simplified_union
1 parent c6cf7cd commit 529df9f

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

mypy/checkexpr.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1612,9 +1612,7 @@ def check_overload_call(self,
16121612
# a union of inferred callables because for example a call
16131613
# Union[int -> int, str -> str](Union[int, str]) is invalid and
16141614
# we don't want to introduce internal inconsistencies.
1615-
unioned_result = (make_simplified_union(list(returns),
1616-
context.line,
1617-
context.column),
1615+
unioned_result = (make_simplified_union(list(returns)),
16181616
self.combine_function_signatures(inferred_types))
16191617

16201618
# Step 3: We try checking each branch one-by-one.

mypy/expandtype.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ def visit_union_type(self, t: UnionType) -> Type:
243243
# After substituting for type variables in t.items,
244244
# some of the resulting types might be subtypes of others.
245245
from mypy.typeops import make_simplified_union # asdf
246-
return make_simplified_union(self.expand_types(t.items), t.line, t.column)
246+
return make_simplified_union(self.expand_types(t.items))
247247

248248
def visit_partial_type(self, t: PartialType) -> Type:
249249
return t

mypy/typeops.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,6 @@ def is_simple_literal(t: ProperType) -> bool:
337337

338338

339339
def make_simplified_union(items: Sequence[Type],
340-
line: int = -1, column: int = -1,
341340
*, keep_erased: bool = False,
342341
contract_literals: bool = True) -> ProperType:
343342
"""Build union type with redundant union items removed.
@@ -381,7 +380,7 @@ def make_simplified_union(items: Sequence[Type],
381380
if contract_literals and sum(isinstance(item, LiteralType) for item in simplified_set) > 1:
382381
simplified_set = try_contracting_literals_in_union(simplified_set)
383382

384-
return UnionType.make_union(simplified_set, line, column)
383+
return UnionType.make_union(simplified_set)
385384

386385

387386
def _remove_redundant_union_items(items: List[ProperType], keep_erased: bool) -> List[ProperType]:
@@ -479,7 +478,7 @@ def true_only(t: Type) -> ProperType:
479478
# The true version of a union type is the union of the true versions of its components
480479
new_items = [true_only(item) for item in t.items]
481480
can_be_true_items = [item for item in new_items if item.can_be_true]
482-
return make_simplified_union(can_be_true_items, line=t.line, column=t.column)
481+
return make_simplified_union(can_be_true_items)
483482
else:
484483
ret_type = _get_type_special_method_bool_ret_type(t)
485484

@@ -514,7 +513,7 @@ def false_only(t: Type) -> ProperType:
514513
# The false version of a union type is the union of the false versions of its components
515514
new_items = [false_only(item) for item in t.items]
516515
can_be_false_items = [item for item in new_items if item.can_be_false]
517-
return make_simplified_union(can_be_false_items, line=t.line, column=t.column)
516+
return make_simplified_union(can_be_false_items)
518517
else:
519518
ret_type = _get_type_special_method_bool_ret_type(t)
520519

@@ -536,7 +535,7 @@ def true_or_false(t: Type) -> ProperType:
536535

537536
if isinstance(t, UnionType):
538537
new_items = [true_or_false(item) for item in t.items]
539-
return make_simplified_union(new_items, line=t.line, column=t.column)
538+
return make_simplified_union(new_items)
540539

541540
new_t = copy_type(t)
542541
new_t.can_be_true = new_t.can_be_true_default()

0 commit comments

Comments
 (0)