Skip to content

Commit 06cd503

Browse files
authored
Now all .clean_copy() calls do not use .disable_count = 0 (#11459)
Also remove unused function.
1 parent 045be82 commit 06cd503

File tree

2 files changed

+9
-15
lines changed

2 files changed

+9
-15
lines changed

mypy/checker.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4674,7 +4674,6 @@ def refine_parent_types(self,
46744674

46754675
def replay_lookup(new_parent_type: ProperType) -> Optional[Type]:
46764676
msg_copy = self.msg.clean_copy()
4677-
msg_copy.disable_count = 0
46784677
member_type = analyze_member_access(
46794678
name=member_name,
46804679
typ=new_parent_type,

mypy/checkexpr.py

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2486,12 +2486,6 @@ def check_op_reversible(self,
24862486
right_expr: Expression,
24872487
context: Context,
24882488
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-
24952489
def lookup_operator(op_name: str, base_type: Type) -> Optional[Type]:
24962490
"""Looks up the given operator and returns the corresponding type,
24972491
if it exists."""
@@ -2503,7 +2497,7 @@ def lookup_operator(op_name: str, base_type: Type) -> Optional[Type]:
25032497
if not self.has_member(base_type, op_name):
25042498
return None
25052499

2506-
local_errors = make_local_errors()
2500+
local_errors = msg.clean_copy()
25072501

25082502
member = analyze_member_access(
25092503
name=op_name,
@@ -2634,7 +2628,7 @@ def lookup_definer(typ: Instance, attr_name: str) -> Optional[str]:
26342628
errors = []
26352629
results = []
26362630
for method, obj, arg in variants:
2637-
local_errors = make_local_errors()
2631+
local_errors = msg.clean_copy()
26382632
result = self.check_method_call(
26392633
op_name, obj, method, [arg], [ARG_POS], context, local_errors)
26402634
if local_errors.is_errors():
@@ -2656,7 +2650,7 @@ def lookup_definer(typ: Instance, attr_name: str) -> Optional[str]:
26562650
# call the __op__ method (even though it's missing).
26572651

26582652
if not variants:
2659-
local_errors = make_local_errors()
2653+
local_errors = msg.clean_copy()
26602654
result = self.check_method_call_by_name(
26612655
op_name, left_type, [right_expr], [ARG_POS], context, local_errors)
26622656

@@ -2703,7 +2697,6 @@ def check_op(self, method: str, base_type: Type,
27032697
# just the left ones. (Mypy can sometimes perform some more precise inference
27042698
# if we leave the right operands a union -- see testOperatorWithEmptyListAndSum.)
27052699
msg = self.msg.clean_copy()
2706-
msg.disable_count = 0
27072700
all_results = []
27082701
all_inferred = []
27092702

@@ -2738,11 +2731,13 @@ def check_op(self, method: str, base_type: Type,
27382731
right_variants = [(right_type, arg)]
27392732
right_type = get_proper_type(right_type)
27402733
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+
27442740
msg = self.msg.clean_copy()
2745-
msg.disable_count = 0
27462741
all_results = []
27472742
all_inferred = []
27482743

0 commit comments

Comments
 (0)