def remove_passcontext(self, n):
for d in n.decorator_list:
if not isinstance(d, ast.Call):
continue
for kw in list(d.keywords): # iterate over a copy of the list to avoid removing while iterating
if not isinstance(kw.value, ast.NameConstant):
continue
if kw.arg == 'pass_context': # if the pass_context kwarg is set to True
if self.interactive and not prompt_change(
'A possible change was found to remove the pass_context decorator from {}.'.format(n.name)
):
return n
d.keywords.remove(kw)
stats_counter['coro_changes'] += 1
return n
评论列表
文章目录