diff --git a/.flake8 b/.flake8 index b383bddb5496dcd92539efc18d9ddd0da6f250bf..48ec9ecf167942c8ea99f08e156c29083ac3eaf4 100644 --- a/.flake8 +++ b/.flake8 @@ -1,22 +1,30 @@ [flake8] select = C,E,F,W -exclude = ./build +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** ignore = # E, see https://pycodestyle.pycqa.org/en/latest/intro.html#error-codes - E101,E121,E122,E123,E124,E125,E126,E127,E128,E129,E131, - E201,E202,E203,E221,E225,E226,E228,E231,E241,E251,E261,E262,E265,E266,E271,E272,E275, + E121,E122,E123,E125,E126,E127,E128,E129,E131, + E201,E202,E203,E225,E226,E228,E231,E241,E251,E261,E262,E265,E266,E271,E272, E301,E302,E303,E305,E306, E401,E402, E501,E502, E701,E711,E712,E713,E714,E721,E722,E731,E741, # F, see https://flake8.pycqa.org/en/latest/user/error-codes.html - F401,F402,F403,F404,F405, - F522,F523,F524,F541, + F401,F402,F403,F405, + F522,F524,F541, F601,F631,F632, - F811,F821,F823,F841, + F811,F821,F841, # W, see https://pycodestyle.pycqa.org/en/latest/intro.html#error-codes - W191, W503,W504 W601,W605 +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 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 059630481e34e26fa6f7dd68ced3f1da3873a8bb..8ae7502684fc7461d56721fb3e59339152a5d2d4 100755 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,8 +1,10 @@ +# Exclude all third-party libraries globally exclude: | (?x)^( patches/.+| paddle/fluid/framework/fleet/heter_ps/cudf/.+| - paddle/fluid/distributed/ps/thirdparty/round_robin.h + paddle/fluid/distributed/ps/thirdparty/round_robin.h| + python/paddle/utils/gast/.+ )$ repos: - repo: https://github.com/Lucas-C/pre-commit-hooks.git @@ -12,6 +14,17 @@ repos: - id: remove-tabs files: \.(c|cc|cxx|cpp|cu|h|hpp|hxx|xpu|kps)$ args: [--whitespaces-count, '2'] + - id: remove-tabs + files: (.*\.(py|bzl)|BUILD|.*\.BUILD|WORKSPACE)$ + args: [--whitespaces-count, '4'] + # Exclude the fluid directory but keep the fluid/tests directory. + # And exclude some unit test files that require tabs. + exclude: | + (?x)^( + python/paddle/fluid/(?!tests).+| + python/paddle/fluid/tests/unittests/collective/fleet/test_hdfs1.py| + python/paddle/fluid/tests/unittests/dygraph_to_static/test_error.py + )$ - repo: https://github.com/google/yapf rev: v0.32.0 hooks: