mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
Check python code with flake8
Recently assert-on-tuple had been introduced in tests [1], let's prevent this. [1]: https://github.com/ClickHouse/ClickHouse/pull/56367#discussion_r1437098533 v2: pin flake8 to 4.0.1 (instead of originally 6.1) due to other dependencies, hope that it will find such errors Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
This commit is contained in:
parent
b2535d7f50
commit
11905682a9
@ -30,6 +30,7 @@ RUN pip3 install \
|
||||
mypy==1.8.0 \
|
||||
pylint==3.1.0 \
|
||||
python-magic==0.4.24 \
|
||||
flake8==4.0.1 \
|
||||
requests \
|
||||
thefuzz \
|
||||
types-requests \
|
||||
|
@ -9,6 +9,8 @@ echo "Check style" | ts
|
||||
./check-style -n |& tee /test_output/style_output.txt
|
||||
echo "Check python formatting with black" | ts
|
||||
./check-black -n |& tee /test_output/black_output.txt
|
||||
echo "Check python with flake8" | ts
|
||||
./check-flake8 |& tee /test_output/flake8_output.txt
|
||||
echo "Check python type hinting with mypy" | ts
|
||||
./check-mypy -n |& tee /test_output/mypy_output.txt
|
||||
echo "Check typos" | ts
|
||||
|
@ -91,6 +91,9 @@ cd ./utils/check-style
|
||||
# Check python type hinting with mypy
|
||||
./check-mypy
|
||||
|
||||
# Check python with flake8
|
||||
./check-flake8
|
||||
|
||||
# Check code with codespell
|
||||
./check-typos
|
||||
|
||||
|
55
utils/check-style/check-flake8
Executable file
55
utils/check-style/check-flake8
Executable file
@ -0,0 +1,55 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
function join_by() { local IFS="$1"; shift; echo "$*"; }
|
||||
|
||||
set -e
|
||||
|
||||
# We check only our code, that's why we skip contrib
|
||||
GIT_ROOT=$(git rev-parse --show-cdup)
|
||||
GIT_ROOT=${GIT_ROOT:-./}
|
||||
|
||||
# Find all *.py, *.python files and executable files without extension
|
||||
# that are determined as python scripts by 'file' util
|
||||
# in the repo except the contrib directory.
|
||||
find_cmd=(
|
||||
find "$GIT_ROOT" -type f -not -path "${GIT_ROOT}contrib/*"
|
||||
\(
|
||||
\(
|
||||
-name '*.py' -or -name "*.python" -or
|
||||
\(
|
||||
-executable -not -name "*.*" -exec sh -c 'file {} | grep -q "Python script"' \;
|
||||
\)
|
||||
\)
|
||||
# We skip modules generated by the protocol buffer compiler from *.proto files.
|
||||
-and -not -name '*_pb2.py' -and -not -name '*_pb2_grpc.py'
|
||||
\) -print0
|
||||
)
|
||||
|
||||
ignores=(
|
||||
E101 # Indentation contains mixed spaces and tabs
|
||||
E203 # Whitespace before ':'
|
||||
E226 # missing whitespace around arithmetic operator
|
||||
E266 # Too many leading '#' for block comment
|
||||
E401 # Multiple imports on one line
|
||||
E402 # Module level import not at top of file
|
||||
E501 # line too long
|
||||
E711 # Comparison to None should be 'cond is None:'
|
||||
E712 # Comparison to true should be 'if cond is true:' or 'if cond:'
|
||||
E713 # Test for membership should be 'not in'
|
||||
E714 # Test for object identity should be 'is not'
|
||||
E722 # Do not use bare except, specify exception instead
|
||||
E731 # Do not assign a lambda expression, use a def
|
||||
E741 # Do not use variables named 'I', 'O', or 'l'
|
||||
F401 # Module imported but unused
|
||||
F403 # 'from module import *' used; unable to detect undefined names
|
||||
F405 # Name may be undefined, or defined from star imports: module
|
||||
F522 # .format(...) unused named arguments
|
||||
F541 # f-string without any placeholders
|
||||
F811 # redefinition of unused name from line N
|
||||
F841 # local variable name is assigned to but never used
|
||||
W191 # Indentation contains tabs
|
||||
W291 # Trailing whitespace
|
||||
W293 # Blank line contains whitespace
|
||||
W503 # Line break occurred before a binary operator
|
||||
)
|
||||
"${find_cmd[@]}" | xargs -0 flake8 --ignore "$(join_by , "${ignores[@]}")"
|
@ -18,6 +18,7 @@ def process_result(result_folder):
|
||||
"style",
|
||||
"pylint",
|
||||
"black",
|
||||
"flake8",
|
||||
"mypy",
|
||||
"typos",
|
||||
"whitespaces",
|
||||
|
Loading…
Reference in New Issue
Block a user