From bd6e2dce50d7a1b08e6d7f0a57c062e1761474f0 Mon Sep 17 00:00:00 2001 From: Hugues Bruant Date: Fri, 29 Apr 2022 20:48:42 -0700 Subject: [PATCH] EXPERIMENT remove line/column param to make_simplified_union --- mypy/checkexpr.py | 4 +--- mypy/expandtype.py | 2 +- mypy/typeops.py | 9 ++++----- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/mypy/checkexpr.py b/mypy/checkexpr.py index 055aba8de08b..9208519f6698 100644 --- a/mypy/checkexpr.py +++ b/mypy/checkexpr.py @@ -1615,9 +1615,7 @@ def check_overload_call(self, # a union of inferred callables because for example a call # Union[int -> int, str -> str](Union[int, str]) is invalid and # we don't want to introduce internal inconsistencies. - unioned_result = (make_simplified_union(list(returns), - context.line, - context.column), + unioned_result = (make_simplified_union(list(returns)), self.combine_function_signatures(inferred_types)) # Step 3: We try checking each branch one-by-one. diff --git a/mypy/expandtype.py b/mypy/expandtype.py index ce43aeaeb6e5..844083b9c077 100644 --- a/mypy/expandtype.py +++ b/mypy/expandtype.py @@ -245,7 +245,7 @@ def visit_union_type(self, t: UnionType) -> Type: # After substituting for type variables in t.items, # some of the resulting types might be subtypes of others. from mypy.typeops import make_simplified_union # asdf - return make_simplified_union(self.expand_types(t.items), t.line, t.column) + return make_simplified_union(self.expand_types(t.items)) def visit_partial_type(self, t: PartialType) -> Type: return t diff --git a/mypy/typeops.py b/mypy/typeops.py index b47c3c246fd2..5eb418cad2c7 100644 --- a/mypy/typeops.py +++ b/mypy/typeops.py @@ -353,7 +353,6 @@ def is_simple_literal(t: ProperType) -> bool: def make_simplified_union(items: Sequence[Type], - line: int = -1, column: int = -1, *, keep_erased: bool = False, contract_literals: bool = True) -> ProperType: """Build union type with redundant union items removed. @@ -397,7 +396,7 @@ def make_simplified_union(items: Sequence[Type], if contract_literals and sum(isinstance(item, LiteralType) for item in simplified_set) > 1: simplified_set = try_contracting_literals_in_union(simplified_set) - return UnionType.make_union(simplified_set, line, column) + return UnionType.make_union(simplified_set) def _remove_redundant_union_items(items: List[ProperType], keep_erased: bool) -> List[ProperType]: @@ -495,7 +494,7 @@ def true_only(t: Type) -> ProperType: # The true version of a union type is the union of the true versions of its components new_items = [true_only(item) for item in t.items] can_be_true_items = [item for item in new_items if item.can_be_true] - return make_simplified_union(can_be_true_items, line=t.line, column=t.column) + return make_simplified_union(can_be_true_items) else: ret_type = _get_type_special_method_bool_ret_type(t) @@ -530,7 +529,7 @@ def false_only(t: Type) -> ProperType: # The false version of a union type is the union of the false versions of its components new_items = [false_only(item) for item in t.items] can_be_false_items = [item for item in new_items if item.can_be_false] - return make_simplified_union(can_be_false_items, line=t.line, column=t.column) + return make_simplified_union(can_be_false_items) else: ret_type = _get_type_special_method_bool_ret_type(t) @@ -552,7 +551,7 @@ def true_or_false(t: Type) -> ProperType: if isinstance(t, UnionType): new_items = [true_or_false(item) for item in t.items] - return make_simplified_union(new_items, line=t.line, column=t.column) + return make_simplified_union(new_items) new_t = copy_type(t) new_t.can_be_true = new_t.can_be_true_default()