@@ -1208,6 +1208,28 @@ lint-addon-docs: test/addons/.docbuildstamp
12081208cpplint : lint-cpp
12091209 @echo " Please use lint-cpp instead of cpplint"
12101210
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+
12111233.PHONY : lint
12121234.PHONY : lint-ci
12131235ifneq ("","$(wildcard tools/node_modules/eslint/) ")
@@ -1221,7 +1243,7 @@ lint: ## Run JS, C++, MD and doc linters.
12211243CONFLICT_RE =^>>>>>>> [0-9A-Fa-f]+|^<<<<<<< [A-Za-z]+
12221244
12231245# 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
12251247 @if ! ( grep -IEqrs " $( CONFLICT_RE) " benchmark deps doc lib src test tools ) \
12261248 && ! ( find . -maxdepth 1 -type f | xargs grep -IEqs " $( CONFLICT_RE) " ); then \
12271249 exit 0 ; \
0 commit comments