Skip to content

[CodeStyle][PLC3002][PLE1205] simplify lambda and add missing placeholder to logger template #52133

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

Merged
merged 6 commits into from
Mar 27, 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
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ select = [
# Pylint
# "PLC0414",
# "PLC1901",
# "PLC3002",
"PLC3002",
"PLE0100",
"PLE0101",
# "PLE0116",
Expand All @@ -128,7 +128,7 @@ select = [
"PLE0604",
"PLE0605",
"PLE1142",
# "PLE1205",
"PLE1205",
"PLE1206",
"PLE1307",
# "PLE1310",
Expand Down Expand Up @@ -166,3 +166,4 @@ unfixable = [
[tool.ruff.per-file-ignores]
"__init__.py" = ["F401"]
"setup.py" = ["UP036"]
"python/paddle/fluid/tests/unittests/dygraph_to_static/test_lambda.py" = ["PLC3002"]
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ def set_table_config(msg, config_name, configs, index=0):
getattr(msg, field.name), name, configs
)
else:
logger.debug("not message:", name)
Copy link
Member

Choose a reason for hiding this comment

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

该 rule 再多调研一下吧,如果调研结果合适可以引入

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

对日志输出优化

https://docs.python.org/3/howto/logging.html#optimization

这里并不是优化,而是避免出现错误的使用方式,目前代码里的使用方式是错误的

image

应引用文档 https://docs.python.org/3/howto/logging.html#logging-variable-data ,参数数量 > 占位符数量,会触发运行时错误

本 rule 可引入,可避免 bug
本 rule 无自动修复功能,需要开发者手动修复

logger.debug("not message: %s", name)
if name not in configs:
continue
if field.label == FieldDescriptor.LABEL_REPEATED:
Expand Down