From 4b898287e91fd7d2c8f32c503a47827a0de307cf Mon Sep 17 00:00:00 2001 From: proletarius101 Date: Thu, 4 May 2023 14:12:08 +0000 Subject: [PATCH] make linting and formatting rules consistent --- hooks/pre-commit | 23 +++-------------------- pyproject.toml | 20 ++++++++++++++++++++ setup.cfg | 4 ++-- 3 files changed, 25 insertions(+), 22 deletions(-) diff --git a/hooks/pre-commit b/hooks/pre-commit index 8007a3e2..0a96b808 100755 --- a/hooks/pre-commit +++ b/hooks/pre-commit @@ -52,20 +52,6 @@ else done fi -# We ignore the following PEP8 warnings -# * E123: closing bracket does not match indentation of opening bracket's line -# - Broken if multiple indentation levels start on a single line -# * E203: whitespace before ':' -# - E203 is not PEP 8 compliant and conflict with black -# * E501: line too long (82 > 79 characters) -# - Recommended for readability but not enforced -# - Some lines are awkward to wrap around a char limit -# * W503: line break before binary operator -# - Quite pedantic - - -PEP8_IGNORE="E123,E203,E501,W503" - err() { echo >&2 ERROR: "$@" exit 1 @@ -96,7 +82,7 @@ find_command() { DASH=$(find_command dash) PYDOCSTYLE=$(find_command pydocstyle) PYFLAKES=$(find_command pyflakes) -PEP8=$(find_command pycodestyle pep8) +PYCODESTYLE=$(find_command pycodestyle pep8) RUBY=$(find_command ruby) YAMLLINT=$(find_command yamllint) @@ -110,16 +96,13 @@ if [ "$PY_FILES $PY_TEST_FILES" != " " ]; then fi if [ "$PY_FILES" != "" ]; then - if ! $PEP8 --ignore=$PEP8_IGNORE $PY_FILES; then + if ! $PYCODESTYLE $PY_FILES; then err "pep8 tests failed!" fi fi -# The tests use a little hack in order to cleanly import the fdroidserver -# package locally like a regular package. pep8 doesn't see that, so this -# makes pep8 skip E402 on the test files that need that hack. if [ "$PY_TEST_FILES" != "" ]; then - if ! $PEP8 --ignore=$PEP8_IGNORE,E402 $PY_TEST_FILES; then + if ! $PYCODESTYLE $PY_TEST_FILES; then err "pep8 tests failed!" fi fi diff --git a/pyproject.toml b/pyproject.toml index 9702f4e5..dcfe865a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,23 @@ + +# We ignore the following PEP8 warnings +# * E123: closing bracket does not match indentation of opening bracket's line +# - Broken if multiple indentation levels start on a single line +# * E203: whitespace before ':' +# - E203 is not PEP 8 compliant and conflict with black +# * E402: module level import not at top of file +# - The tests use a little hack in order to cleanly import the +# fdroidserver package locally like a regular package. pep8 doesn't +# see that, so this makes pep8 skip E402 on the test files that need +# that hack. +# * E501: line too long (82 > 79 characters) +# - Recommended for readability but not enforced +# - Some lines are awkward to wrap around a char limit +# * W503: line break before binary operator +# - Quite pedantic + +[tool.autopep8] +ignore = "E123,E203,E402,E501,W503" + [tool.black] skip-string-normalization = true target-version = ["py38"] diff --git a/setup.cfg b/setup.cfg index e33cfbc3..bd613e73 100644 --- a/setup.cfg +++ b/setup.cfg @@ -40,11 +40,11 @@ domain = fdroidserver directory = locale [pycodestyle] -ignore = E203,W503 +ignore = E123,E203,E402,E501,W503 max-line-length = 88 [flake8] -ignore = E203,W503 +ignore = E123,E203,E402,E501,W503 max-line-length = 88 # Settings for docstrings linter