-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CodeStyle][UP006] use list instead of List for type annotations; #52061
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
@SigureMo 麻烦您了qaq |
emmm,还是不太准确,这里能够使用 list 是因为 PEP 563 在 Python 3.7 允许通过引入 另外这个 PR 还是没有修正 codestyle 问题吧, pre-commit run --files python/paddle/jit/api.py |
好的,谢谢qaq 麻烦了 |
@kk-2000 麻烦 re-run 下 PR-CI-Inference 流水线和 PR-CI-Coverage 流水线(无关单测挂掉了,rerun 下应该就没问题了) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
PR types
Others
PR changes
Others
Describe
UP006,在类型注解中使用
list
而非List
。原因如下:通过在Python 3.7中使用
from __future__ import annotations
引入注解 postponed evaluation 的功能,这样在注解里的代码不会在运行时抛出错误,就可以使用 Python 3.9 才支持的 list 泛型。并且List自3.9版本后弃用,以上修改可以支持对Python未来版本的兼容是否可以引入本 rule: 如上所述,可以引入
是否可引入自动修复: 转写后不会影响代码的语义,该规则可视为可靠的自动转写规则,可以引入
修复所使用的命令如下: