@@ -89,10 +89,13 @@ def __init__(self, node, ctx):
89
89
self ._node = node
90
90
self ._protocol_cache = set ()
91
91
self ._recursive_annots_cache = set ()
92
+ self ._error_subst = None
93
+ self ._reset_errors ()
94
+
95
+ def _reset_errors (self ):
92
96
self ._protocol_error = None
93
97
self ._noniterable_str_error = None
94
98
self ._typed_dict_error = None
95
- self ._error_subst = None
96
99
97
100
@contextlib .contextmanager
98
101
def _track_partially_matched_protocols (self ):
@@ -143,11 +146,10 @@ def compute_subst(self, formal_args, arg_dict, view, alias_map=None):
143
146
subst = datatypes .AliasingDict ()
144
147
if alias_map :
145
148
subst .uf = alias_map
146
- self ._protocol_error = None
147
- self ._noniterable_str_error = None
148
149
self ._error_subst = None
149
150
self_subst = None
150
151
for name , formal in formal_args :
152
+ self ._reset_errors ()
151
153
actual = arg_dict [name ]
152
154
subst = self ._match_value_against_type (actual , formal , subst , view )
153
155
if subst is None :
@@ -195,8 +197,6 @@ def bad_matches(self, var, other_type):
195
197
view = views .send (skip_future )
196
198
except StopIteration :
197
199
break
198
- self ._protocol_error = None
199
- self ._noniterable_str_error = None
200
200
if self .match_var_against_type (var , other_type , {}, view ) is None :
201
201
if self ._node .HasCombination (list (view .values ())):
202
202
bad .append ((view , self ._error_details ()))
@@ -250,6 +250,7 @@ def match_from_mro(self, left, other_type, allow_compat_builtins=True):
250
250
251
251
def match_var_against_type (self , var , other_type , subst , view ):
252
252
"""Match a variable against a type."""
253
+ self ._reset_errors ()
253
254
if var .bindings :
254
255
return self ._match_value_against_type (view [var ], other_type , subst , view )
255
256
else : # Empty set of values. The "nothing" type.
@@ -985,7 +986,6 @@ def _match_callable_instance(self, left, instance, other_type, subst, view):
985
986
986
987
def _match_dict_against_typed_dict (self , left , other_type ):
987
988
assert isinstance (other_type , typed_dict .TypedDictClass )
988
- self ._typed_dict_error = None
989
989
if not isinstance (left , abstract .Dict ):
990
990
return False
991
991
missing , extra = other_type .props .check_keys (left .pyval .keys ())
0 commit comments