Skip to content

Commit 948d8f4

Browse files
committed
lint: Enable python linters via an array
This assures consistent recording of the enabled linters.
1 parent 978682b commit 948d8f4

File tree

1 file changed

+75
-73
lines changed

1 file changed

+75
-73
lines changed

test/lint/lint-python.sh

Lines changed: 75 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/usr/bin/env bash
22
#
33
# Copyright (c) 2017 The Bitcoin Core developers
44
# Distributed under the MIT software license, see the accompanying
@@ -8,77 +8,79 @@
88

99
export LC_ALL=C
1010

11-
# E101 indentation contains mixed spaces and tabs
12-
# E112 expected an indented block
13-
# E113 unexpected indentation
14-
# E115 expected an indented block (comment)
15-
# E116 unexpected indentation (comment)
16-
# E125 continuation line with same indent as next logical line
17-
# E129 visually indented line with same indent as next logical line
18-
# E131 continuation line unaligned for hanging indent
19-
# E133 closing bracket is missing indentation
20-
# E223 tab before operator
21-
# E224 tab after operator
22-
# E242 tab after ','
23-
# E266 too many leading '#' for block comment
24-
# E271 multiple spaces after keyword
25-
# E272 multiple spaces before keyword
26-
# E273 tab after keyword
27-
# E274 tab before keyword
28-
# E275 missing whitespace after keyword
29-
# E304 blank lines found after function decorator
30-
# E306 expected 1 blank line before a nested definition
31-
# E401 multiple imports on one line
32-
# E402 module level import not at top of file
33-
# F403 'from foo_module import *' used; unable to detect undefined names
34-
# F405 foo_function may be undefined, or defined from star imports: bar_module
35-
# E502 the backslash is redundant between brackets
36-
# E701 multiple statements on one line (colon)
37-
# E702 multiple statements on one line (semicolon)
38-
# E703 statement ends with a semicolon
39-
# E711 comparison to None should be 'if cond is None:'
40-
# E714 test for object identity should be "is not"
41-
# E721 do not compare types, use "isinstance()"
42-
# E741 do not use variables named "l", "O", or "I"
43-
# E742 do not define classes named "l", "O", or "I"
44-
# E743 do not define functions named "l", "O", or "I"
45-
# E901 SyntaxError: invalid syntax
46-
# E902 TokenError: EOF in multi-line string
47-
# F401 module imported but unused
48-
# F402 import module from line N shadowed by loop variable
49-
# F404 future import(s) name after other statements
50-
# F406 "from module import *" only allowed at module level
51-
# F407 an undefined __future__ feature name was imported
52-
# F601 dictionary key name repeated with different values
53-
# F602 dictionary key variable name repeated with different values
54-
# F621 too many expressions in an assignment with star-unpacking
55-
# F622 two or more starred expressions in an assignment (a, *b, *c = d)
56-
# F631 assertion test is a tuple, which are always True
57-
# F701 a break statement outside of a while or for loop
58-
# F702 a continue statement outside of a while or for loop
59-
# F703 a continue statement in a finally block in a loop
60-
# F704 a yield or yield from statement outside of a function
61-
# F705 a return statement with arguments inside a generator
62-
# F706 a return statement outside of a function/method
63-
# F707 an except: block as not the last exception handler
64-
# F811 redefinition of unused name from line N
65-
# F812 list comprehension redefines 'foo' from line N
66-
# F821 undefined name 'Foo'
67-
# F822 undefined name name in __all__
68-
# F823 local variable name … referenced before assignment
69-
# F831 duplicate argument name in function definition
70-
# F841 local variable 'foo' is assigned to but never used
71-
# W191 indentation contains tabs
72-
# W291 trailing whitespace
73-
# W292 no newline at end of file
74-
# W293 blank line contains whitespace
75-
# W504 line break after binary operator
76-
# W601 .has_key() is deprecated, use "in"
77-
# W602 deprecated form of raising exception
78-
# W603 "<>" is deprecated, use "!="
79-
# W604 backticks are deprecated, use "repr()"
80-
# W605 invalid escape sequence "x"
81-
# W606 'async' and 'await' are reserved keywords starting with Python 3.7
11+
enabled=(
12+
E101 # indentation contains mixed spaces and tabs
13+
E112 # expected an indented block
14+
E113 # unexpected indentation
15+
E115 # expected an indented block (comment)
16+
E116 # unexpected indentation (comment)
17+
E125 # continuation line with same indent as next logical line
18+
E129 # visually indented line with same indent as next logical line
19+
E131 # continuation line unaligned for hanging indent
20+
E133 # closing bracket is missing indentation
21+
E223 # tab before operator
22+
E224 # tab after operator
23+
E242 # tab after ','
24+
E266 # too many leading '#' for block comment
25+
E271 # multiple spaces after keyword
26+
E272 # multiple spaces before keyword
27+
E273 # tab after keyword
28+
E274 # tab before keyword
29+
E275 # missing whitespace after keyword
30+
E304 # blank lines found after function decorator
31+
E306 # expected 1 blank line before a nested definition
32+
E401 # multiple imports on one line
33+
E402 # module level import not at top of file
34+
E502 # the backslash is redundant between brackets
35+
E701 # multiple statements on one line (colon)
36+
E702 # multiple statements on one line (semicolon)
37+
E703 # statement ends with a semicolon
38+
E711 # comparison to None should be 'if cond is None:'
39+
E714 # test for object identity should be "is not"
40+
E721 # do not compare types, use "isinstance()"
41+
E741 # do not use variables named "l", "O", or "I"
42+
E742 # do not define classes named "l", "O", or "I"
43+
E743 # do not define functions named "l", "O", or "I"
44+
E901 # SyntaxError: invalid syntax
45+
E902 # TokenError: EOF in multi-line string
46+
F401 # module imported but unused
47+
F402 # import module from line N shadowed by loop variable
48+
F403 # 'from foo_module import *' used; unable to detect undefined names
49+
F404 # future import(s) name after other statements
50+
F405 # foo_function may be undefined, or defined from star imports: bar_module
51+
F406 # "from module import *" only allowed at module level
52+
F407 # an undefined __future__ feature name was imported
53+
F601 # dictionary key name repeated with different values
54+
F602 # dictionary key variable name repeated with different values
55+
F621 # too many expressions in an assignment with star-unpacking
56+
F622 # two or more starred expressions in an assignment (a, *b, *c = d)
57+
F631 # assertion test is a tuple, which are always True
58+
F701 # a break statement outside of a while or for loop
59+
F702 # a continue statement outside of a while or for loop
60+
F703 # a continue statement in a finally block in a loop
61+
F704 # a yield or yield from statement outside of a function
62+
F705 # a return statement with arguments inside a generator
63+
F706 # a return statement outside of a function/method
64+
F707 # an except: block as not the last exception handler
65+
F811 # redefinition of unused name from line N
66+
F812 # list comprehension redefines 'foo' from line N
67+
F821 # undefined name 'Foo'
68+
F822 # undefined name name in __all__
69+
F823 # local variable name … referenced before assignment
70+
F831 # duplicate argument name in function definition
71+
F841 # local variable 'foo' is assigned to but never used
72+
W191 # indentation contains tabs
73+
W291 # trailing whitespace
74+
W292 # no newline at end of file
75+
W293 # blank line contains whitespace
76+
W504 # line break after binary operator
77+
W601 # .has_key() is deprecated, use "in"
78+
W602 # deprecated form of raising exception
79+
W603 # "<>" is deprecated, use "!="
80+
W604 # backticks are deprecated, use "repr()"
81+
W605 # invalid escape sequence "x"
82+
W606 # 'async' and 'await' are reserved keywords starting with Python 3.7
83+
)
8284

8385
if ! command -v flake8 > /dev/null; then
8486
echo "Skipping Python linting since flake8 is not installed. Install by running \"pip3 install flake8\""
@@ -88,4 +90,4 @@ elif PYTHONWARNINGS="ignore" flake8 --version | grep -q "Python 2"; then
8890
exit 0
8991
fi
9092

91-
PYTHONWARNINGS="ignore" flake8 --ignore=B,C,E,F,I,N,W --select=E101,E112,E113,E115,E116,E125,E129,E131,E133,E223,E224,E242,E266,E271,E272,E273,E274,E275,E304,E306,E401,E402,E502,E701,E702,E703,E711,E714,E721,E741,E742,E743,E901,E902,F401,F402,F403,F404,F405,F406,F407,F601,F602,F621,F622,F631,F701,F702,F703,F704,F705,F706,F707,F811,F812,F821,F822,F823,F831,F841,W191,W291,W292,W293,W504,W601,W602,W603,W604,W605,W606 "${@:-.}"
93+
PYTHONWARNINGS="ignore" flake8 --ignore=B,C,E,F,I,N,W --select=$(IFS=","; echo "${enabled[*]}") "${@:-.}"

0 commit comments

Comments
 (0)