Skip to content
This repository was archived by the owner on Jan 3, 2026. It is now read-only.

Travis CI: flake8 tests to find Python syntax errors & undefined names - #22

Merged
whitequark merged 5 commits into
m-labs:masterfrom
cclauss:patch-2
Sep 2, 2018
Merged

Travis CI: flake8 tests to find Python syntax errors & undefined names#22
whitequark merged 5 commits into
m-labs:masterfrom
cclauss:patch-2

Conversation

@cclauss

@cclauss cclauss commented Sep 2, 2018

Copy link
Copy Markdown
Contributor

Add flake8 tests to find Python syntax errors and undefined names.

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

Undefined name: exception --> Exception

exception (lowercase 'e') is an undefined name in this context while Exception (uppercase 'e') is the superclass.

flake8 testing of https://github.com/m-labs/pythonparser on Python 2.7.14

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

./pythonparser/source.py:259:9: F821 undefined name 'exception'
        exception.__init__(self, "Ranges %s and %s overlap" % (repr(first), repr(second)))
        ^
1     F821 undefined name 'exception'
1

Fix indentation error in LongOnly.__ne__()

cclauss and others added 5 commits September 2, 2018 18:44
…d names

Add [flake8](http://flake8.pycqa.org) tests to find Python syntax errors and undefined names.

__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
exception (lowercase 'e') is an undefined name in this context while Exception (uppercase 'e') is the superclass.

flake8 testing of https://github.com/cclauss/pythonparser on Python 2.7.14

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

./pythonparser/source.py:259:9: F821 undefined name 'exception'
        exception.__init__(self, "Ranges %s and %s overlap" % (repr(first), repr(second)))
        ^
1     F821 undefined name 'exception'
1
Also follow Python porting best practice [__use feature detection instead of version detection__](https://docs.python.org/3/howto/pyporting.html#use-feature-detection-instead-of-version-detection).
@cclauss
cclauss deleted the patch-2 branch September 3, 2018 01:07
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants