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 2] enable Ruff F401 rule in python/paddle/base #57388

Merged
merged 14 commits into from
Sep 18, 2023

Conversation

zrr1999
Copy link
Member

@zrr1999 zrr1999 commented Sep 15, 2023

PR types

Others

PR changes

Others

Description

enable Ruff F401 rule in python/paddle/base

@paddle-bot
Copy link

paddle-bot bot commented Sep 15, 2023

你的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 the contributor External developers label Sep 15, 2023
@luotao1 luotao1 added the HappyOpenSource 快乐开源活动issue与PR label Sep 15, 2023
@zrr1999 zrr1999 force-pushed the F401 branch 2 times, most recently from f984d74 to 892b11d Compare September 16, 2023 07:48
Comment on lines 26 to 41
from .trainer_desc import (
MultiTrainer,
DistMultiTrainer,
PipelineTrainer,
HeterXpuTrainer,
PSGPUTrainer,
HeterPipelineTrainer,
MultiTrainer, # noqa: F401
DistMultiTrainer, # noqa: F401
PipelineTrainer, # noqa: F401
HeterXpuTrainer, # noqa: F401
PSGPUTrainer, # noqa: F401
HeterPipelineTrainer, # noqa: F401
)
from .device_worker import (
Hogwild,
DownpourSGD,
DownpourLite,
Section,
DownpourSGDOPT,
HeterSection,
Hogwild, # noqa: F401
DownpourSGD, # noqa: F401
DownpourLite, # noqa: F401
Section, # noqa: F401
DownpourSGDOPT, # noqa: F401
HeterSection, # noqa: F401
)
Copy link
Member

Choose a reason for hiding this comment

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

from xxx import ( # noqa: F401
    yyy,
    zzz
)

这样就可以了,如果每行一个的话,之后使用 isort 格式化会散开:

image

直接在 import 那行加一次 noqa 则不会:

image

Copy link
Member Author

Choose a reason for hiding this comment

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

done

pyproject.toml Outdated
"__init__.py" = ["F401"]
"python/paddle/base/core.py" = ["F401"]
Copy link
Member

Choose a reason for hiding this comment

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

不建议整个文件 ignore 掉,那个文件的 logging 明显是没有用的

可以参考上一条,将 libpaddle 的 import 改写为

from .libpaddle import ( # noqa: F401
    xxx,
    yyy,
    zzz,
)

这样就只需要加一个 noqa 了

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@SigureMo
Copy link
Member

image

这用法就离谱,可以直接改成 import logging……

@@ -66,6 +63,7 @@
'device_guard',
'set_flags',
'get_flags',
'data_feed_pb2',
Copy link
Member

Choose a reason for hiding this comment

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

这个直接 noqa 就行,加到 __all__ 会认为是公开 API 的

pyproject.toml Outdated
@@ -89,7 +89,7 @@ ignore = [
]

[tool.ruff.per-file-ignores]
# Ignore unused imports in __init__.py
# Ignore unused imports in some files
Copy link
Member

Choose a reason for hiding this comment

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

这里可以恢复一下

Copy link
Member

@SigureMo SigureMo left a comment

Choose a reason for hiding this comment

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

LGTMeow 🐾

@SigureMo SigureMo changed the title [CodeStyle][task 2] enable Ruff F401 rule in python/paddle/base [CodeStyle][task 2] enable Ruff F401 rule in python/paddle/base Sep 17, 2023
@luotao1 luotao1 merged commit 8620430 into PaddlePaddle:develop Sep 18, 2023
danleifeng pushed a commit to danleifeng/Paddle that referenced this pull request Nov 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor External developers HappyOpenSource 快乐开源活动issue与PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants