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

DAOS-16865 cq: update flake8 to 7.1.1 (#15575) #15597

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion utils/cq/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pyenchant
## flake8 6 removed --diff option which breaks flake precommit hook.
## https://github.com/pycqa/flake8/issues/1389 https://github.com/PyCQA/flake8/pull/1720
flake8<6.0.0
flake8==7.1.1
isort==5.13.2
pylint==3.2.0
yamllint==1.35.1
Expand Down
29 changes: 16 additions & 13 deletions utils/githooks/pre-commit.d/71-flake.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,17 @@
set -ue

_print_githook_header "Flake8"
if ! command -v flake8 > /dev/null 2>&1; then
echo "flake8 not installed. Install flake8 command to improve pre-commit checks:"
echo " python3 -m pip install -r ./utils/cq/requirements.txt"
exit 0
fi

if flake8 --version | grep ^6\\.; then
echo "flake8 >= 6.x does not have the --diff option. Skipping."
py_files=$(_git_diff_cached_files "*.py SConstruct */SConscript")

if [ -z "$py_files" ]; then
echo "No python changes. Skipping"
exit 0
fi

if [ ! -f .flake8 ]; then
echo "No .flake8 config. Skipping"
if ! command -v flake8 > /dev/null 2>&1; then
echo "flake8 not installed. Install flake8 command to improve pre-commit checks:"
echo " python3 -m pip install -r ./utils/cq/requirements.txt"
exit 0
fi

Expand All @@ -47,12 +45,17 @@ if [ "$BRANCH" = "origin/master" ]; then
echo " Checking tree"
flake8 --statistics
else

# shellcheck disable=SC1091
rc=0

# non-scons
git diff "$TARGET" -U10 | flake8 --config .flake8 --diff
if ! echo "$py_files" | grep -vi scons | xargs flake8 --config .flake8; then
rc=1
fi

# scons
git diff "$TARGET" -U10 | flake8 --config .flake8-scons --diff
if ! echo "$py_files" | grep -i scons | xargs flake8 --config .flake8-scons; then
rc=1;
fi

exit "$rc"
fi
Loading