-
Notifications
You must be signed in to change notification settings - Fork 29.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Makefile: Add lint-python which uses flake8 #21952
Conversation
Is it not possible to bundle the linting library instead, like we do for eslint? That way we don't need to make system-wide changes (e.g. implicitly upgrading pip)? |
We could remove pip install —upgrade pip. |
@mscdex Does that last commit cover what you wanted or did I misunderstand your request? Is the automated testing actually doing a "make lint"? If so, how do I view the output? https://github.com/nodejs/node/runs/8932739 does not seem to contain the words "lint-python" or "flake8". |
Makefile
Outdated
# Flag the build if there are Python syntax errors or undefined names | ||
lint-python: lint-python | ||
@echo "Running Python linter on $(shell $(PYTHON) --version)..." | ||
@$(PYTHON) -m pip install --upgrade flake8 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't work on my system when not run as root:
OSError: [Errno 13] Permission denied: '/usr/lib/python2.7/site-packages/enum34-1.1.6.dist-info'
make[1]: *** [Makefile:1212: lint-python] Error 2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please try to add --user to the command and let me know if that works?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌 It works with --user
Exclusions don't seem to work. I see many errors coming from |
You see these errors where? Locally or in server-based build log? |
Locally, with |
/cc @nodejs/python @nodejs/build-files |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Should split build code to a
lint-python-build
target, and add conditions (maypeif $(shell python -m flake8 --version)
- remove
@
for traceability - IMHO setting should go into
tox.ini
and not stored in the Makefile
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see comments
Hello @cclauss and thank you for the contribution 🥇 |
I implemented all suggestions except:
|
Makefile
Outdated
.PHONY: lint-python | ||
# Lints the Python code with flake8. | ||
# Flag the build if there are Python syntax errors or undefined names | ||
lint-python: lint-python |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lint-python: lint-python-build
?
What I meant was include the 'flake8' module in the repo, like we do with eslint for js files, to avoid having to install it system/user-wide (which I would find to be unexpected behavior). |
What's the status on this one? |
a4f0ae4
to
4458162
Compare
That is lots of approval... https://blog.github.com/2018-10-21-october21-incident-report |
@nodejs/build-files @nodejs/python PTAL |
4458162
to
a1b6029
Compare
a1b6029
to
604890b
Compare
604890b
to
9a690c3
Compare
PR-URL: nodejs#21952 Reviewed-By: Refael Ackermann <refack@gmail.com>
9a690c3
to
0c39290
Compare
PR-URL: #21952 Reviewed-By: Refael Ackermann <refack@gmail.com>
PR-URL: #21952 Reviewed-By: Refael Ackermann <refack@gmail.com>
PR-URL: #21952 Reviewed-By: Refael Ackermann <refack@gmail.com>
PR-URL: #21952 Reviewed-By: Refael Ackermann <refack@gmail.com>
PR-URL: #21952 Reviewed-By: Refael Ackermann <refack@gmail.com>
Add a lint-python section to Makefile which pip installs flake8 and then executes:
Based on the experimentation done at https://travis-ci.com/nodejs/node/builds/79706150 - #21942
These tests currently exclude several directories and files:
Hopefully this list can be reduced in future PRs with code modifications or the use of # noqa
E901,E999,F821,F822,F823 are the "showstopper" flake8 issues that can halt the runtime with a SyntaxError, NameError, etc. Most other flake8 issues are merely "style violations" -- useful for readability but they do not effect runtime safety.
name
name
in__all__
name
referenced before assignmentChecklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes