Skip to content

Commit 520d9ba

Browse files
kumekaybrianignacio5
authored andcommitted
Python linting/formatting settings and python 3 support
1 parent 5645861 commit 520d9ba

File tree

5 files changed

+515
-549
lines changed

5 files changed

+515
-549
lines changed

.flake8

+161
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
[flake8]
2+
3+
select =
4+
# Full lists are given in order to suppress all errors from other plugins
5+
# Full list of pyflakes error codes:
6+
F401, # module imported but unused
7+
F402, # import module from line N shadowed by loop variable
8+
F403, # 'from module import *' used; unable to detect undefined names
9+
F404, # future import(s) name after other statements
10+
F405, # name may be undefined, or defined from star imports: module
11+
F406, # 'from module import *' only allowed at module level
12+
F407, # an undefined __future__ feature name was imported
13+
F601, # dictionary key name repeated with different values
14+
F602, # dictionary key variable name repeated with different values
15+
F621, # too many expressions in an assignment with star-unpacking
16+
F622, # two or more starred expressions in an assignment (a, *b, *c = d)
17+
F631, # assertion test is a tuple, which are always True
18+
F701, # a break statement outside of a while or for loop
19+
F702, # a continue statement outside of a while or for loop
20+
F703, # a continue statement in a finally block in a loop
21+
F704, # a yield or yield from statement outside of a function
22+
F705, # a return statement with arguments inside a generator
23+
F706, # a return statement outside of a function/method
24+
F707, # an except: block as not the last exception handler
25+
F721, F722, # doctest syntax error syntax error in forward type annotation
26+
F811, # redefinition of unused name from line N
27+
F812, # list comprehension redefines name from line N
28+
F821, # undefined name name
29+
F822, # undefined name name in __all__
30+
F823, # local variable name referenced before assignment
31+
F831, # duplicate argument name in function definition
32+
F841, # local variable name is assigned to but never used
33+
F901, # raise NotImplemented should be raise NotImplementedError
34+
35+
# Full list of pycodestyle violations:
36+
E101, # indentation contains mixed spaces and tabs
37+
E111, # indentation is not a multiple of four
38+
E112, # expected an indented block
39+
E113, # unexpected indentation
40+
E114, # indentation is not a multiple of four (comment)
41+
E115, # expected an indented block (comment)
42+
E116, # unexpected indentation (comment)
43+
E121, # continuation line under-indented for hanging indent
44+
E122, # continuation line missing indentation or outdented
45+
E123, # closing bracket does not match indentation of opening bracket's line
46+
E124, # closing bracket does not match visual indentation
47+
E125, # continuation line with same indent as next logical line
48+
E126, # continuation line over-indented for hanging indent
49+
E127, # continuation line over-indented for visual indent
50+
E128, # continuation line under-indented for visual indent
51+
E129, # visually indented line with same indent as next logical line
52+
E131, # continuation line unaligned for hanging indent
53+
E133, # closing bracket is missing indentation
54+
E201, # whitespace after '('
55+
E202, # whitespace before ')'
56+
E203, # whitespace before ':'
57+
E211, # whitespace before '('
58+
E221, # multiple spaces before operator
59+
E222, # multiple spaces after operator
60+
E223, # tab before operator
61+
E224, # tab after operator
62+
E225, # missing whitespace around operator
63+
E226, # missing whitespace around arithmetic operator
64+
E227, # missing whitespace around bitwise or shift operator
65+
E228, # missing whitespace around modulo operator
66+
E231, # missing whitespace after ',', ';', or ':'
67+
E241, # multiple spaces after ','
68+
E242, # tab after ','
69+
E251, # unexpected spaces around keyword / parameter equals
70+
E261, # at least two spaces before inline comment
71+
E262, # inline comment should start with '# '
72+
E265, # block comment should start with '# '
73+
E266, # too many leading '#' for block comment
74+
E271, # multiple spaces after keyword
75+
E272, # multiple spaces before keyword
76+
E273, # tab after keyword
77+
E274, # tab before keyword
78+
E275, # missing whitespace after keyword
79+
E301, # expected 1 blank line, found 0
80+
E302, # expected 2 blank lines, found 0
81+
E303, # too many blank lines
82+
E304, # blank lines found after function decorator
83+
E305, # expected 2 blank lines after end of function or class
84+
E306, # expected 1 blank line before a nested definition
85+
E401, # multiple imports on one line
86+
E402, # module level import not at top of file
87+
E501, # line too long (82 > 79 characters)
88+
E502, # the backslash is redundant between brackets
89+
E701, # multiple statements on one line (colon)
90+
E702, # multiple statements on one line (semicolon)
91+
E703, # statement ends with a semicolon
92+
E704, # multiple statements on one line (def)
93+
E711, # comparison to None should be 'if cond is None:'
94+
E712, # comparison to True should be 'if cond is True:' or 'if cond:'
95+
E713, # test for membership should be 'not in'
96+
E714, # test for object identity should be 'is not'
97+
E721, # do not compare types, use 'isinstance()'
98+
E722, # do not use bare except, specify exception instead
99+
E731, # do not assign a lambda expression, use a def
100+
E741, # do not use variables named 'l', 'O', or 'I'
101+
E742, # do not define classes named 'l', 'O', or 'I'
102+
E743, # do not define functions named 'l', 'O', or 'I'
103+
E901, # SyntaxError or IndentationError
104+
E902, # IOError
105+
W191, # indentation contains tabs
106+
W291, # trailing whitespace
107+
W292, # no newline at end of file
108+
W293, # blank line contains whitespace
109+
W391, # blank line at end of file
110+
W503, # line break before binary operator
111+
W504, # line break after binary operator
112+
W505, # doc line too long (82 > 79 characters)
113+
W601, # .has_key() is deprecated, use 'in'
114+
W602, # deprecated form of raising exception
115+
W603, # '<>' is deprecated, use '!='
116+
W604, # backticks are deprecated, use 'repr()'
117+
W605, # invalid escape sequence 'x'
118+
W606, # 'async' and 'await' are reserved keywords starting with Python 3.7
119+
120+
# Full list of flake8 violations
121+
E999, # failed to compile a file into an Abstract Syntax Tree for the plugins that require it
122+
123+
# Full list of mccabe violations
124+
C901 # complexity value provided by the user
125+
126+
ignore =
127+
E221, # multiple spaces before operator
128+
E231, # missing whitespace after ',', ';', or ':'
129+
E241, # multiple spaces after ','
130+
W503, # line break before binary operator
131+
W504 # line break after binary operator
132+
133+
max-line-length = 120
134+
135+
show_source = True
136+
137+
statistics = True
138+
139+
exclude =
140+
.git,
141+
__pycache__,
142+
# submodules
143+
components/esptool_py/esptool,
144+
components/bootloader/subproject/components/micro-ecc/micro-ecc,
145+
components/nghttp/nghttp2,
146+
components/libsodium/libsodium,
147+
components/json/cJSON,
148+
components/mbedtls/mbedtls,
149+
components/expat/expat,
150+
components/unity/unity,
151+
examples/build_system/cmake/import_lib/main/lib/tinyxml2
152+
# other third-party libraries
153+
tools/kconfig_new/kconfiglib.py,
154+
# autogenerated scripts
155+
components/protocomm/python/constants_pb2.py,
156+
components/protocomm/python/sec0_pb2.py,
157+
components/protocomm/python/sec1_pb2.py,
158+
components/protocomm/python/session_pb2.py,
159+
components/wifi_provisioning/python/wifi_config_pb2.py,
160+
components/wifi_provisioning/python/wifi_constants_pb2.py,
161+
examples/provisioning/custom_config/components/custom_provisioning/python/custom_config_pb2.py,

.gitlab-ci.yml

+19
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,25 @@ javascript_lint_test:
4646
- ./node_modules/.bin/eslint menuconfig/js/koCustomComponents.js
4747
- ./node_modules/.bin/eslint menuconfig/js/HtmlFormatter.js
4848

49+
python_lint_test:
50+
image: $CI_DOCKER_REGISTRY/ubuntu-test-env
51+
stage: lint
52+
tags:
53+
- build
54+
artifacts:
55+
when: on_failure
56+
paths:
57+
- flake8_output.txt
58+
- bandit_output.txt
59+
expire_in: 1 week
60+
before_script:
61+
- source /opt/pyenv/activate
62+
- pyenv global 2.7.15
63+
- python -m pip install bandit flake8
64+
script:
65+
- python -m bandit -r -f txt -o bandit_output.txt .
66+
- python -m flake8 --config=.flake8 --output-file=flake8_output.txt --tee
67+
4968
javascript_test:
5069
image: $CI_DOCKER_REGISTRY/electron_userland_builder:9
5170
stage: test

0 commit comments

Comments
 (0)