@@ -2486,12 +2486,6 @@ def check_op_reversible(self,
2486
2486
right_expr : Expression ,
2487
2487
context : Context ,
2488
2488
msg : MessageBuilder ) -> Tuple [Type , Type ]:
2489
- def make_local_errors () -> MessageBuilder :
2490
- """Creates a new MessageBuilder object."""
2491
- local_errors = msg .clean_copy ()
2492
- local_errors .disable_count = 0
2493
- return local_errors
2494
-
2495
2489
def lookup_operator (op_name : str , base_type : Type ) -> Optional [Type ]:
2496
2490
"""Looks up the given operator and returns the corresponding type,
2497
2491
if it exists."""
@@ -2503,7 +2497,7 @@ def lookup_operator(op_name: str, base_type: Type) -> Optional[Type]:
2503
2497
if not self .has_member (base_type , op_name ):
2504
2498
return None
2505
2499
2506
- local_errors = make_local_errors ()
2500
+ local_errors = msg . clean_copy ()
2507
2501
2508
2502
member = analyze_member_access (
2509
2503
name = op_name ,
@@ -2634,7 +2628,7 @@ def lookup_definer(typ: Instance, attr_name: str) -> Optional[str]:
2634
2628
errors = []
2635
2629
results = []
2636
2630
for method , obj , arg in variants :
2637
- local_errors = make_local_errors ()
2631
+ local_errors = msg . clean_copy ()
2638
2632
result = self .check_method_call (
2639
2633
op_name , obj , method , [arg ], [ARG_POS ], context , local_errors )
2640
2634
if local_errors .is_errors ():
@@ -2656,7 +2650,7 @@ def lookup_definer(typ: Instance, attr_name: str) -> Optional[str]:
2656
2650
# call the __op__ method (even though it's missing).
2657
2651
2658
2652
if not variants :
2659
- local_errors = make_local_errors ()
2653
+ local_errors = msg . clean_copy ()
2660
2654
result = self .check_method_call_by_name (
2661
2655
op_name , left_type , [right_expr ], [ARG_POS ], context , local_errors )
2662
2656
@@ -2703,7 +2697,6 @@ def check_op(self, method: str, base_type: Type,
2703
2697
# just the left ones. (Mypy can sometimes perform some more precise inference
2704
2698
# if we leave the right operands a union -- see testOperatorWithEmptyListAndSum.)
2705
2699
msg = self .msg .clean_copy ()
2706
- msg .disable_count = 0
2707
2700
all_results = []
2708
2701
all_inferred = []
2709
2702
@@ -2738,11 +2731,13 @@ def check_op(self, method: str, base_type: Type,
2738
2731
right_variants = [(right_type , arg )]
2739
2732
right_type = get_proper_type (right_type )
2740
2733
if isinstance (right_type , UnionType ):
2741
- right_variants = [(item , TempNode (item , context = context ))
2742
- for item in flatten_nested_unions (right_type .relevant_items (),
2743
- handle_type_alias_type = True )]
2734
+ right_variants = [
2735
+ (item , TempNode (item , context = context ))
2736
+ for item in flatten_nested_unions (right_type .relevant_items (),
2737
+ handle_type_alias_type = True )
2738
+ ]
2739
+
2744
2740
msg = self .msg .clean_copy ()
2745
- msg .disable_count = 0
2746
2741
all_results = []
2747
2742
all_inferred = []
2748
2743
0 commit comments