-
Notifications
You must be signed in to change notification settings - Fork 5.8k
[CodeStyle][F821] fix undefined variables due to missing imports, misspelled variable names #47899
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][F821] fix undefined variables due to missing imports, misspelled variable names #47899
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
elif not isinstance(elem, int) and not isinstance( | ||
elem, long | ||
): | ||
elif not isinstance(elem, int): |
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.
long 在 Python3 已经不存在了,int 即包含全部整型,因此 long 这里可以直接删掉
self._init_containers: List[Container] = [] | ||
self._containers: List[Container] = [] | ||
self._init_containers: list[Container] = [] | ||
self._containers: list[Container] = [] |
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.
虽然直接加 from typing import List
也没问题,但在 python3.7 及之后更推荐先 from __future__ import annotations
,之后就可以使用一些新版本才有的特性了(比如这里的 list 泛型原本在 Python 3.9 才能用),可以保证之后版本升级(退场)不需要重构这一部分代码,只需要在未来移除 from __future__ import annotations
即可
@@ -140,7 +140,7 @@ def ref_reduce_mean(x, axis=None, keepdim=False, reduce_all=False): | |||
return np.mean(x, axis=axis, keepdims=keepdim) | |||
|
|||
|
|||
def ref_reduce_mean_grad(x, axis, dtype): | |||
def ref_reduce_mean_grad(x, axis, dtype, reduce_all): |
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.
这里缺少传递参数 reduce_all,因为下面 193 行 else 分支无条件 return 了所以这里并没有报错,因此下面移除了 return
😢😢,已豁免合入 |
PR types
Others
PR changes
Others
Describe
本 PR 主需要修复一些因为 缺失的 import、拼写错误的变量名等一些根据短程上下文即可确定的 F821(undefined variable)问题,这些问题应该都是单测没有覆盖到的
本 PR 修复 F821 从 43 个 -> 21 个,共修复 22 个
Related links
name
cattidea/paddle-flake8-project#79parameterized
related code #47869