From 7994a3b17a41f2ae49eb2e64faf75ba0f830b52e Mon Sep 17 00:00:00 2001 From: Deborah Brouwer Date: Mon, 16 Dec 2024 15:45:42 -0800 Subject: [PATCH] ci: add .flake8 linting to ci scripts and tests Currently the ci scripts and tests don't have any linting checks. Add .flake8 linting to start adding some consistency to the scripts. Ignore most of the existing errors until they can be addressed on an individual basis. Part-of: --- .gitlab-ci/.flake8 | 33 +++++++++++++++++++++++++++++++++ .gitlab-ci/run-pytest.sh | 6 ++++++ bin/ci/requirements.txt | 4 ++++ 3 files changed, 43 insertions(+) create mode 100644 .gitlab-ci/.flake8 diff --git a/.gitlab-ci/.flake8 b/.gitlab-ci/.flake8 new file mode 100644 index 00000000000..95db896bc0b --- /dev/null +++ b/.gitlab-ci/.flake8 @@ -0,0 +1,33 @@ +[flake8] +exclude = .venv*, + +# PEP 8 Style Guide limits line length to 79 characters +max-line-length = 167 + +ignore = + # continuation line under-indented for hanging indent + E121 + # continuation line over-indented for hanging indent + E126, + # continuation line under-indented for visual indent + E128, + # whitespace before ':' + E203, + # missing whitespace around arithmetic operator + E226, + # missing whitespace after ',' + E231, + # expected 2 blank lines, found 1 + E302, + # too many blank lines + E303, + # imported but unused + F401, + # f-string is missing placeholders + F541, + # local variable assigned to but never used + F841, + # line break before binary operator + W503, + # line break after binary operator + W504, diff --git a/.gitlab-ci/run-pytest.sh b/.gitlab-ci/run-pytest.sh index 2225be59fec..91898ef948b 100755 --- a/.gitlab-ci/run-pytest.sh +++ b/.gitlab-ci/run-pytest.sh @@ -54,3 +54,9 @@ PYTHONPATH="${LIB_TEST_DIR}:${SCRIPT_TEST_DIR}:${PYTHONPATH:-}" python3 -m \ ${PYTEST_VERBOSE:-} section_end pytest + +section_start flake8 "flake8" +flake8 \ +--config "${CI_PROJECT_DIR}/.gitlab-ci/.flake8" \ +"${LIB_TEST_DIR}" "${SCRIPT_TEST_DIR}" +section_end flake8 diff --git a/bin/ci/requirements.txt b/bin/ci/requirements.txt index 81be9147bd4..40f4c5dd8a7 100644 --- a/bin/ci/requirements.txt +++ b/bin/ci/requirements.txt @@ -1,8 +1,12 @@ +# If you change these requirements, and you need these packages +# to be available in the debian/x86_64_pyutils container +# then bump the DEBIAN_PYUTILS_TAG PyYAML==6.* colorama==0.4.* filecache==0.81 filelock==3.* fire==0.5.0 +flake8==7.* gql==3.* kaleido==0.2.* lavacli==1.5.2