From 3d656b5892433e6115c1a60cb417e0c65bb745fa Mon Sep 17 00:00:00 2001 From: Nyakku Shigure Date: Wed, 21 Sep 2022 14:25:39 +0800 Subject: [PATCH] [CodeStyle] init flake8 configs (#45943) --- .editorconfig | 29 +++++++++++++++++++++++++++++ .flake8 | 22 ++++++++++++++++++++++ .pre-commit-config.yaml | 4 ++++ 3 files changed, 55 insertions(+) create mode 100644 .editorconfig create mode 100644 .flake8 diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000000..7c31ee52398 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,29 @@ +# EditorConfig is a cross-editor configuration file +# that helps to unify code styles for multiple +# developers collaborative projects. +# See more at https://editorconfig.org/ + +root = true + +[*] +indent_style = space +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.{c,cc,cxx,cpp,cu,cuh,h,hpp,hxx,kps}] +indent_size = 2 + +[*.{py,java,r}] +indent_size = 4 + +[Dockerfile.*] +indent_size = 4 + +[.flake8] +indent_size = 4 + +[*.go] +indent_style = tab +indent_size = 4 diff --git a/.flake8 b/.flake8 new file mode 100644 index 00000000000..b383bddb549 --- /dev/null +++ b/.flake8 @@ -0,0 +1,22 @@ +[flake8] +select = C,E,F,W +exclude = ./build +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, + 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, + F601,F631,F632, + F811,F821,F823,F841, + + # W, see https://pycodestyle.pycqa.org/en/latest/intro.html#error-codes + W191, + W503,W504 + W601,W605 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c97d38d3040..059630481e3 100755 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,6 +22,10 @@ repos: python/paddle/fluid/tests/unittests/dygraph_to_static/test_error.py| python/paddle/fluid/tests/unittests/dygraph_to_static/test_origin_info.py )$ +- repo: https://github.com/PyCQA/flake8 + rev: 4.0.1 + hooks: + - id: flake8 - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.1.0 hooks: -- GitLab