forked from criteo-forks/mlflow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lint.sh
executable file
·49 lines (39 loc) · 1.4 KB
/
lint.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env bash
set -e
FWDIR="$(cd "`dirname $0`"; pwd)"
cd "$FWDIR"
# https://stackoverflow.com/a/17841619
function join {
local d=$1
shift
echo -n "$1"
shift
printf "%s" "${@/#/$d}"
}
include_dirs=(
"mlflow"
"tests"
)
exclude_dirs=(
"mlflow/protos"
"mlflow/server/js"
"mlflow/store/db_migrations"
"mlflow/temporary_db_migrations_for_pre_1_users"
)
# Exclude proto files because they are auto-generated
black --check --line-length=100 --exclude=mlflow/protos .
exclude=$(join "," "${exclude_dirs[@]}")
include=$(join " " "${include_dirs[@]}")
pycodestyle --max-line-length=100 --ignore=E203,W503 --exclude=$exclude -- $include
# pylint's `--ignore` option filters files based on their base names, not paths.
# see: http://pylint.pycqa.org/en/latest/user_guide/run.html#command-line-options
# This behavior might cause us to unintentionally ignore some files.
# To avoid this issue, select files to lint using `git ls-files` and `grep`.
# Another advantage of this approach is we can apply pylint to all python scripts
# without creating `__init__.py` in all directories.
exclude="^\($(join "\|" "${exclude_dirs[@]}")\)/.\+\.py$"
include="^\($(join "\|" "${include_dirs[@]}")\)/.\+\.py$"
msg_template="{path} ({line},{column}): [{msg_id} {symbol}] {msg}"
git ls-files | grep $include | grep -v $exclude | \
xargs pylint --msg-template="$msg_template" --rcfile="$FWDIR/pylintrc"
rstcheck README.rst