-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathpyauto
More file actions
executable file
·62 lines (50 loc) · 1.72 KB
/
pyauto
File metadata and controls
executable file
·62 lines (50 loc) · 1.72 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/sh
# pip install pyflakes autopep8 autoflake isort
path="${1-.}"
fns="$(find "$path" -name "*.py" -exec echo '"{}"' \;)"
autopep8_options='--max-line-length 120'
autoflake_options=''
if [ "$PYKIT_AGGRESIVE" = "1" ]; then
# --expand-star-imports
# expand wildcard star imports with undefined names;
# this only triggers if there is only one star import in
# the file; this is skipped if there are any uses of
# `__all__` or `del` in the file
# --remove-all-unused-imports
# remove all unused imports (not just those from the
# standard library)
# --remove-duplicate-keys
# remove all duplicate keys in objects
# --remove-unused-variables
# remove unused variables
autoflake_options='
--expand-star-imports
--remove-all-unused-imports
--remove-duplicate-keys
--remove-unused-variables
'
fi
die_if_strict()
{
[ "$PYKIT_SCRICT" = "1" ] && exit 1
}
die_if_changed()
{
White="$( tput bold; tput setaf 7)"
NC="$( tput sgr0)"
if [ "$PYKIT_SCRICT" = "1" ]; then
if git diff --name-only | grep -q "."; then
git status
echo "$White"
echo "#### Something is auto fixed."
echo "#### Please review and 'git add' them."
echo "$NC"
exit 1
fi
fi
}
eval autopep8 -i $autopep8_options $fns
eval autoflake -i $autoflake_options $fns
eval isort --force-single-line-imports $fns
eval pyflakes $fns || die_if_strict
die_if_changed