Skip to content

Commit

Permalink
Now all .clean_copy() calls do not use .disable_count = 0 (#11459)
Browse files Browse the repository at this point in the history
Also remove unused function.
  • Loading branch information
sobolevn authored Nov 5, 2021
1 parent 045be82 commit 06cd503
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
1 change: 0 additions & 1 deletion mypy/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
23 changes: 9 additions & 14 deletions mypy/checkexpr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand All @@ -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,
Expand Down Expand Up @@ -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():
Expand All @@ -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)

Expand Down Expand Up @@ -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 = []

Expand Down Expand Up @@ -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 = []

Expand Down

0 comments on commit 06cd503

Please sign in to comment.