@@ -170,7 +170,7 @@ def _add(final):
170
170
if requested in self .function_arg_reserved_names ():
171
171
assert requested not in self .names_in_use ()
172
172
return _add (requested )
173
- if requested in self .all_reserved_names ( ):
173
+ if self .is_name_reserved ( requested ):
174
174
raise AssertionError (f"Cannot use '{ requested } ' as argument name as it is already in use" )
175
175
176
176
cleaned = cleanup_name (requested )
@@ -180,8 +180,6 @@ def _add(final):
180
180
# To avoid shadowing of global names in local scope, we
181
181
# take into account parent scope when assigning names.
182
182
183
- used = self .all_reserved_names ()
184
-
185
183
def _is_name_allowed (name : str ) -> bool :
186
184
# We need to also protect against using keywords ('class', 'def' etc.)
187
185
# i.e. count all keywords as 'used'.
@@ -190,7 +188,7 @@ def _is_name_allowed(name: str) -> bool:
190
188
if (not is_builtin ) and keyword .iskeyword (name ):
191
189
return False
192
190
193
- return name not in used
191
+ return not self . is_name_reserved ( name )
194
192
195
193
while not _is_name_allowed (attempt ):
196
194
attempt = cleaned + str (count )
@@ -207,7 +205,7 @@ def reserve_function_arg_name(self, name):
207
205
# To keep things simple, and the generated code predictable, we reserve
208
206
# names for all function arguments in a separate scope, and insist on
209
207
# the exact names
210
- if name in self .all_reserved_names ( ):
208
+ if self .is_name_reserved ( name ):
211
209
raise AssertionError (f"Can't reserve '{ name } ' as function arg name as it is already reserved" )
212
210
self ._function_arg_reserved_names .add (name )
213
211
0 commit comments