diff --git a/mypy/checkexpr.py b/mypy/checkexpr.py index b6dec2834449..623776f8e48e 100644 --- a/mypy/checkexpr.py +++ b/mypy/checkexpr.py @@ -2230,10 +2230,15 @@ def visit_comparison_expr(self, e: ComparisonExpr) -> Type: # Keep track of whether we get type check errors (these won't be reported, they # are just to verify whether something is valid typing wise). - local_errors = self.msg.copy() - local_errors.disable_count = 0 + local_errors = self.msg.clean_copy() _, method_type = self.check_method_call_by_name( - '__contains__', right_type, [left], [ARG_POS], e, local_errors) + method='__contains__', + base_type=right_type, + args=[left], + arg_kinds=[ARG_POS], + context=e, + local_errors=local_errors, + ) sub_result = self.bool_type() # Container item type for strict type overlap checks. Note: we need to only # check for nominal type, because a usual "Unsupported operands for in"