transformers.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:async2rewrite 作者: TheTrain2000 项目源码 文件源码
def stateful_wait_for(self, call):
        if isinstance(call.func, ast.Attribute):
            if call.func.attr in ['wait_for_message', 'wait_for_reaction']:
                if self.interactive and not prompt_change(
                        'A possible change was found to change {} into wait_for.'.format(call.func.attr)
                ):
                    return call
                event = call.func.attr.split('_')[2]
                event = 'message' if event == 'message' else 'reaction_add'
                call.func.attr = 'wait_for'
                if call.args:
                    timeout = call.args[0]
                    call.args = []
                    call.keywords.append(ast.keyword(arg='timeout', value=timeout))

                call.args.insert(0, ast.Str(s=event))
                for kw in list(call.keywords):
                    if kw.arg != 'check' and kw.arg != 'timeout':
                        call.keywords.remove(kw)
                warnings.warn('wait_for change detected. Rewrite removes the author, channel, and content '
                              'keyword arguments from this method.')
                stats_counter['call_changes'] += 1
        return call
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号