Skip to content
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][task 11] enable Ruff F403 rule in python/paddle/base/layers/__init__.py #57379

Merged
merged 4 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ ignore = [
"UP031",
"C408",
"UP030",
"F522",
"F403",
Comment on lines +111 to 112
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里是因为解决冲突写错了?不过 F522 出现概率很小,这两天应该不会出现增量,这个 PR 就这样吧,下个 PR 把 F522 和 F403 一并删掉

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是,当时拉取完没改回去🤣,下个pr改回来~

"B010",
"PLR1722",
Expand Down
10 changes: 5 additions & 5 deletions python/paddle/base/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,17 @@

# import all class inside framework into base module
from . import framework
from .framework import *
from .framework import * # noqa: F403

# import all class inside executor into base module
from . import executor
from .executor import *
from .executor import * # noqa: F403

from . import data_feed_desc
from .data_feed_desc import *
from .data_feed_desc import * # noqa: F403

from . import dataset
from .dataset import *
from .dataset import * # noqa: F403

from . import trainer_desc

Expand Down Expand Up @@ -72,7 +72,7 @@

from . import unique_name
from . import compiler
from .compiler import *
from .compiler import * # noqa: F403
from paddle.base.layers.math_op_patch import monkey_patch_variable
from .dygraph.base import enable_dygraph, disable_dygraph
from .dygraph.tensor_patch_methods import monkey_patch_tensor
Expand Down
4 changes: 2 additions & 2 deletions python/paddle/base/dygraph/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
# limitations under the License.

from . import base
from .base import *
from .base import * # noqa: F403

from . import tracer
from .tracer import *
from .tracer import * # noqa: F403


__all__ = []
Expand Down
3 changes: 0 additions & 3 deletions python/paddle/base/layers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@
# limitations under the License.

from . import io
from .io import *
from . import math_op_patch
from .math_op_patch import *
Copy link
Member

@SigureMo SigureMo Sep 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个 PR 可以在 F401 合入后开展,可以考虑一个一个来过 CI,我们首先看一下是否有代码会用这里的重导出,我们可以搜索 base.layers import,可以发现有几处,但是并不需要 .io 下和 .math_op_patch 下的 symbol,因此这两处重导出都可以直接删掉(应该,但不排除有其他用法)

甚至下面的 from ..layer_helper import LayerHelper 我们也可以规范一下,移除这里的重导出(这里重导出一个上层模块的 symbol 本就是不推荐的),搜索到的 from ...base.layers import LayerHelper 可以改为 from ...base.layer_helper import LayerHelper

可以先尝试改这一个文件,然后看看是否能够通过 CI,之后再改其他文件,慢慢来,F403 本就不是很容易改的,甚至可以考虑拆成多个 PR 慢慢做

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

paddle.base.layers.__init__.py修改已提交

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个 PR 是准备只做这一个文件嘛?是的话可以改一下标题

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是的是的,我改一下标题

from ..layer_helper import LayerHelper


__all__ = []
Expand Down
2 changes: 1 addition & 1 deletion python/paddle/nn/functional/pooling.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from paddle.base.framework import Variable, in_dygraph_mode

from ...base.data_feeder import check_type, check_variable_and_dtype
from ...base.layers import LayerHelper
from ...base.layer_helper import LayerHelper
from ...tensor.manipulation import squeeze, unsqueeze

# TODO: define pooling functions
Expand Down