Skip to content

Conversation

SigureMo
Copy link
Member

@SigureMo SigureMo commented Nov 11, 2022

PR types

Others

PR changes

Others

Describe

本 PR 主需要修复一些因为 缺失的 import、拼写错误的变量名等一些根据短程上下文即可确定的 F821(undefined variable)问题,这些问题应该都是单测没有覆盖到的

本 PR 修复 F821 从 43 个 -> 21 个,共修复 22 个

Related links

@paddle-bot
Copy link

paddle-bot bot commented Nov 11, 2022

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@paddle-bot paddle-bot bot added contributor External developers status: proposed labels Nov 11, 2022
@SigureMo SigureMo changed the title [WIP][CodeStyle][F821] Fix undefined variables due to missing imports, misspelled variable names [WIP][CodeStyle][F821] fix undefined variables due to missing imports, misspelled variable names Nov 11, 2022
elif not isinstance(elem, int) and not isinstance(
elem, long
):
elif not isinstance(elem, int):
Copy link
Member Author

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] = []
Copy link
Member Author

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):
Copy link
Member Author

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

@SigureMo SigureMo changed the title [WIP][CodeStyle][F821] fix undefined variables due to missing imports, misspelled variable names [CodeStyle][F821] fix undefined variables due to missing imports, misspelled variable names Nov 11, 2022
@luotao1 luotao1 self-assigned this Nov 14, 2022
@luotao1
Copy link
Contributor

luotao1 commented Nov 14, 2022

本 PR 主需要修复一些因为 缺失的 import、拼写错误的变量名等一些根据短程上下文即可确定的 F821(undefined variable)问题,这些问题应该都是单测没有覆盖到的

😢😢,已豁免合入

@luotao1 luotao1 merged commit 05a47f3 into PaddlePaddle:develop Nov 14, 2022
@SigureMo SigureMo deleted the F821/fix/typos-and-missing-imports branch November 14, 2022 06:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor External developers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants