Skip to content

Makefile: Add lint-python which uses flake8#21952

Merged
refack merged 1 commit intonodejs:masterfrom
cclauss:add-flake8-to-testing
Oct 24, 2018
Merged

Makefile: Add lint-python which uses flake8#21952
refack merged 1 commit intonodejs:masterfrom
cclauss:add-flake8-to-testing

Conversation

@cclauss
Copy link
Copy Markdown
Contributor

@cclauss cclauss commented Jul 24, 2018

Add a lint-python section to Makefile which pip installs flake8 and then executes:

  • flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics

Based on the experimentation done at https://travis-ci.com/nodejs/node/builds/79706150 - #21942

These tests currently exclude several directories and files:

  • ./deps/npm/node_modules/node-gyp -- this repo currently has no automated testing
  • ./deps/v8 -- contains several Python 3 only features such as async def
  • ./src/noperfctr_macros.py -- contains "macros" which Python AST views as syntax errors
  • ./src/notrace_macros.py -- contains "macros" which Python AST views as syntax errors
  • ./tools -- contains "macros" which Python AST views as syntax errors

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.

  • F821: undefined name name
  • F822: undefined name name in __all__
  • F823: local variable name referenced before assignment
  • E901: SyntaxError or IndentationError
  • E999: SyntaxError -- failed to compile a file into an Abstract Syntax Tree
Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build Issues and PRs related to build files or the CI. python PRs and issues that require attention from people who are familiar with Python. tools Issues and PRs related to the tools directory.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants