diff --git a/mypy/checker.py b/mypy/checker.py index 5aa1741a03f6..976eee749653 100644 --- a/mypy/checker.py +++ b/mypy/checker.py @@ -4674,7 +4674,6 @@ def refine_parent_types(self, def replay_lookup(new_parent_type: ProperType) -> Optional[Type]: msg_copy = self.msg.clean_copy() - msg_copy.disable_count = 0 member_type = analyze_member_access( name=member_name, typ=new_parent_type, diff --git a/mypy/checkexpr.py b/mypy/checkexpr.py index 623776f8e48e..51ab7bcdf1f3 100644 --- a/mypy/checkexpr.py +++ b/mypy/checkexpr.py @@ -2486,12 +2486,6 @@ def check_op_reversible(self, right_expr: Expression, context: Context, msg: MessageBuilder) -> Tuple[Type, Type]: - def make_local_errors() -> MessageBuilder: - """Creates a new MessageBuilder object.""" - local_errors = msg.clean_copy() - local_errors.disable_count = 0 - return local_errors - def lookup_operator(op_name: str, base_type: Type) -> Optional[Type]: """Looks up the given operator and returns the corresponding type, if it exists.""" @@ -2503,7 +2497,7 @@ def lookup_operator(op_name: str, base_type: Type) -> Optional[Type]: if not self.has_member(base_type, op_name): return None - local_errors = make_local_errors() + local_errors = msg.clean_copy() member = analyze_member_access( name=op_name, @@ -2634,7 +2628,7 @@ def lookup_definer(typ: Instance, attr_name: str) -> Optional[str]: errors = [] results = [] for method, obj, arg in variants: - local_errors = make_local_errors() + local_errors = msg.clean_copy() result = self.check_method_call( op_name, obj, method, [arg], [ARG_POS], context, local_errors) if local_errors.is_errors(): @@ -2656,7 +2650,7 @@ def lookup_definer(typ: Instance, attr_name: str) -> Optional[str]: # call the __op__ method (even though it's missing). if not variants: - local_errors = make_local_errors() + local_errors = msg.clean_copy() result = self.check_method_call_by_name( op_name, left_type, [right_expr], [ARG_POS], context, local_errors) @@ -2703,7 +2697,6 @@ def check_op(self, method: str, base_type: Type, # just the left ones. (Mypy can sometimes perform some more precise inference # if we leave the right operands a union -- see testOperatorWithEmptyListAndSum.) msg = self.msg.clean_copy() - msg.disable_count = 0 all_results = [] all_inferred = [] @@ -2738,11 +2731,13 @@ def check_op(self, method: str, base_type: Type, right_variants = [(right_type, arg)] right_type = get_proper_type(right_type) if isinstance(right_type, UnionType): - right_variants = [(item, TempNode(item, context=context)) - for item in flatten_nested_unions(right_type.relevant_items(), - handle_type_alias_type=True)] + right_variants = [ + (item, TempNode(item, context=context)) + for item in flatten_nested_unions(right_type.relevant_items(), + handle_type_alias_type=True) + ] + msg = self.msg.clean_copy() - msg.disable_count = 0 all_results = [] all_inferred = []