@@ -1208,6 +1208,28 @@ lint-addon-docs: test/addons/.docbuildstamp
1208
1208
cpplint : lint-cpp
1209
1209
@echo " Please use lint-cpp instead of cpplint"
1210
1210
1211
+ .PHONY : lint-py-build
1212
+ # python -m pip install flake8
1213
+ # Try with '--system' is to overcome systems that blindly set '--user'
1214
+ lint-py-build :
1215
+ @echo " Pip installing flake8 linter on $( shell $( PYTHON) --version) ..."
1216
+ $(PYTHON ) -m pip install --upgrade -t tools/pip/site-packages flake8 || \
1217
+ $(PYTHON ) -m pip install --upgrade --system -t tools/pip/site-packages flake8
1218
+
1219
+ ifneq ("","$(wildcard tools/pip/site-packages) ")
1220
+ .PHONY : lint-py
1221
+ # Lints the Python code with flake8.
1222
+ # Flag the build if there are Python syntax errors or undefined names
1223
+ lint-py :
1224
+ PYTHONPATH=tools/pip $(PYTHON ) -m flake8 . \
1225
+ --count --show-source --statistics --select=E901,E999,F821,F822,F823 \
1226
+ --exclude=deps,lib,src,tools/* _macros.py,tools/gyp,tools/jinja2,tools/pip
1227
+ else
1228
+ lint-py :
1229
+ @echo " Python linting with flake8 is not avalible"
1230
+ @echo " Run 'make lint-py-build'"
1231
+ endif
1232
+
1211
1233
.PHONY : lint
1212
1234
.PHONY : lint-ci
1213
1235
ifneq ("","$(wildcard tools/node_modules/eslint/) ")
@@ -1221,7 +1243,7 @@ lint: ## Run JS, C++, MD and doc linters.
1221
1243
CONFLICT_RE =^>>>>>>> [0-9A-Fa-f]+|^<<<<<<< [A-Za-z]+
1222
1244
1223
1245
# Related CI job: node-test-linter
1224
- lint-ci : lint-js-ci lint-cpp lint-md lint-addon-docs
1246
+ lint-ci : lint-js-ci lint-cpp lint-py lint- md lint-addon-docs
1225
1247
@if ! ( grep -IEqrs " $( CONFLICT_RE) " benchmark deps doc lib src test tools ) \
1226
1248
&& ! ( find . -maxdepth 1 -type f | xargs grep -IEqs " $( CONFLICT_RE) " ); then \
1227
1249
exit 0 ; \
0 commit comments