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

commit 时 flake8 报 E501 line too long #50982

Closed
1099255210 opened this issue Feb 27, 2023 · 9 comments · Fixed by #51012
Closed

commit 时 flake8 报 E501 line too long #50982

1099255210 opened this issue Feb 27, 2023 · 9 comments · Fixed by #51012
Assignees
Labels
status/close 已关闭 type/question 用户提问

Comments

@1099255210
Copy link
Contributor

请提出你的问题 Please ask your question

pre-commit 和 commit 时都报 flake8 Failed,显示 E501 line too long.

check for merge conflicts................................................Passed
check for broken symlinks............................(no files to check)Skipped
detect private key.......................................................Passed
fix end of files.........................................................Passed
sort simple yaml files...............................(no files to check)Skipped
trim trailing whitespace.................................................Passed
CRLF end-lines remover...................................................Passed
Tabs remover (C++)...................................(no files to check)Skipped
Tabs remover (Python)....................................................Passed
copyright_checker........................................................Passed
black....................................................................Passed
isort....................................................................Passed
flake8...................................................................Failed
- hook id: flake8
- exit code: 1

python/paddle/nn/initializer/Bilinear.py:63:80: E501 line too long (80 > 79 characters)
python/paddle/nn/initializer/Bilinear.py:64:80: E501 line too long (80 > 79 characters)
python/paddle/autograd/py_layer.py:31:80: E501 line too long (106 > 79 characters)
python/paddle/autograd/py_layer.py:36:80: E501 line too long (112 > 79 characters)
python/paddle/autograd/py_layer.py:56:80: E501 line too long (87 > 79 characters)
......```
@zoooo0820
Copy link
Contributor

文件会自动修改吧,将修改后的文件add后再提交commit呢

@1099255210
Copy link
Contributor Author

文件会自动修改吧,将修改后的文件add后再提交commit呢

文件没有自动修改,反复pre-commit没有效果

@SigureMo
Copy link
Member

请问是 Windows 系统嘛?以及 Shell 环境是(如 git bash、powershell、cmd)?

@SigureMo SigureMo self-assigned this Feb 28, 2023
@1099255210
Copy link
Contributor Author

请问是 Windows 系统嘛?以及 Shell 环境是(如 git bash、powershell、cmd)?

不好意思忘记提供信息了。
系统是 windows 10,使用的是 powershell

@SigureMo
Copy link
Member

我这边没有相关的测试条件,可以麻烦帮忙测试一些可能的修复方案吗?非常感谢!

修改项目根目录 .flake8 文件内容如下:

[flake8]
select = C,E,F,W
exclude =
    ./build,
    # A trick to exclude fluid/ but keep fluid/tests/, see more at
    # https://github.com/PaddlePaddle/Paddle/pull/46290#discussion_r976392010
    ./python/paddle/fluid/[!t]**,
    ./python/paddle/fluid/tra**,
    # Exclude third-party libraries
    ./python/paddle/utils/gast/**,
    # Exclude files that will be removed in the future, see more at
    # https://github.com/PaddlePaddle/Paddle/pull/46782#issuecomment-1273033731
    ./python/paddle/fluid/tests/unittests/npu/**,
    ./python/paddle/fluid/tests/unittests/mlu/**
ignore =
    # Whitespace before ‘,’, ‘;’, or ‘:’, it is not compatible with black
    E203,
    # Module level import not at top of file
    E402,
    # Line too long (82 > 79 characters)
    E501,
    # Do not compare types, use `isinstance()`
    E721,
    # Do not use bare except, specify exception instead
    E722,
    # Do not assign a lambda expression, use a def
    E731,
    # Do not use variables named ‘l’, ‘O’, or ‘I’
    E741,
    # `name` may be undefined, or defined from star imports: `module`
    F405,
    # Local variable name is assigned to but never used
    F841,
    # Line break before binary operator, it is not compatible with black
    W503
per-file-ignores =
    # These files need tabs for testing.
    python/paddle/fluid/tests/unittests/dygraph_to_static/test_error.py:E101,W191
    python/paddle/fluid/tests/unittests/collective/fleet/test_hdfs1.py:E101,W191
    # Ignore unused imports in __init__.py
    __init__.py: F401
    # Ignore undefined variables in CMake config and some dygraph_to_static tests
    .cmake-format.py: F821
    python/paddle/fluid/tests/unittests/dygraph_to_static/test_loop.py: F821
    python/paddle/fluid/tests/unittests/dygraph_to_static/test_closure_analysis.py: F821

修改项目根目录 .pre-commit-config.yaml flake8 配置项内容如下

-   repo: https://github.com/PyCQA/flake8
    rev: 5.0.4
    hooks:
    -   id: flake8
        args: ["--config=.flake8"]

之后运行 pre-commit run flake8 python/paddle/nn/initializer/Bilinear.py 检查是否还存在该问题~

@engineer1109
Copy link
Contributor

CodeStyle不符合规范,一行代码不要超过80个

@SigureMo
Copy link
Member

一些额外的信息:本问题在上周收到 @Liyulingyue 的反馈以及请 @Ainavo 的帮忙测试时都复现了,已经可以确定本问题应该是存在的(均在 Windows 下),问题是 flake8 无法发现项目根目录下的 .flake8 配置,但之前在我个人的 Windows 下测试是无法复现的,因此现在没办法调试具体的原因 😂

CodeStyle不符合规范,一行代码不要超过80个

相关存量暂时不需要修改,这个已经在 config 里 ignore 了,目前的问题是无法读取 config

@1099255210 如果是做 Hackathon 等框架开发任务的话,可以尝试申请 AI Studio 框架开发功能~可参考 #45347

@1099255210
Copy link
Contributor Author

一些额外的信息:本问题在上周收到 @Liyulingyue 的反馈以及请 @Ainavo 的帮忙测试时都复现了,已经可以确定本问题应该是存在的(均在 Windows 下),问题是 flake8 无法发现项目根目录下的 .flake8 配置,但之前在我个人的 Windows 下测试是无法复现的,因此现在没办法调试具体的原因 😂

CodeStyle不符合规范,一行代码不要超过80个

相关存量暂时不需要修改,这个已经在 config 里 ignore 了,目前的问题是无法读取 config

@1099255210 如果是做 Hackathon 等框架开发任务的话,可以尝试申请 AI Studio 框架开发功能~可参考 #45347

好的,那我暂时不做修改
顺便,按照上面提到的修改 .pre-commit-config.yaml 中的配置的方法再次进行 pre-commit 就可以通过了 👍

@SigureMo
Copy link
Member

顺便,按照上面提到的修改 .pre-commit-config.yaml 中的配置的方法再次进行 pre-commit 就可以通过了 👍

非常感谢反馈!我会尽快提交修复 PR~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/close 已关闭 type/question 用户提问
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants