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

Travis CI: lint Python for syntax errors and undefined names#147

Merged
animeshsingh merged 3 commits intoIBM:masterfrom
cclauss:patch-1
Nov 8, 2018
Merged

Travis CI: lint Python for syntax errors and undefined names#147
animeshsingh merged 3 commits intoIBM:masterfrom
cclauss:patch-1

Conversation

@cclauss
Copy link

@cclauss cclauss commented Oct 19, 2018

In Travis CI, add a Python linting step that runs flake8 to find syntax errors and undefined names.

flake8 testing of https://github.com/IBM/FfDL on Python 3.7.0

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

./etc/examples/c10d-onnx-mpi/model-files/train_dist_onnx_mpi.py:93:55: F821 undefined name 'bsz'
    num_batches = ceil(len(train_set.dataset) / float(bsz))
                                                      ^
./etc/examples/c10d-dist-onnx/model-files/train_dist_onnx.py:121:14: E999 SyntaxError: positional argument follows keyword argument
              ', epoch ', epoch, '. avg_loss: ',
             ^
1     E999 SyntaxError: positional argument follows keyword argument
1     F821 undefined name 'bsz'
2

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

Developer's Certificate of Origin 1.1

   By making a contribution to this project, I certify that:

   (a) The contribution was created in whole or in part by me and I
       have the right to submit it under the Apache License 2.0; or

   (b) The contribution is based upon previous work that, to the best
       of my knowledge, is covered under an appropriate open source
       license and I have the right under that license to submit that
       work with modifications, whether created in whole or in part
       by me, under the same open source license (unless I am
       permitted to submit under a different license), as indicated
       in the file; or

   (c) The contribution was provided directly to me by some other
       person who certified (a), (b) or (c) and I have not modified
       it.

   (d) I understand and agree that this project and the contribution
       are public and that a record of the contribution (including all
       personal information I submit with it, including my sign-off) is
       maintained indefinitely and may be redistributed consistent with
       this project or the open source license(s) involved.

cclauss added 3 commits October 19, 2018 16:53
In Travis CI, add a Python linting step that runs [flake8](http://flake8.pycqa.org) to find syntax errors and undefined names.

[flake8](http://flake8.pycqa.org) testing of https://github.com/IBM/FfDL on Python 3.7.0

$ __flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics__
```
./etc/examples/c10d-onnx-mpi/model-files/train_dist_onnx_mpi.py:93:55: F821 undefined name 'bsz'
    num_batches = ceil(len(train_set.dataset) / float(bsz))
                                                      ^
./etc/examples/c10d-dist-onnx/model-files/train_dist_onnx.py:121:14: E999 SyntaxError: positional argument follows keyword argument
              ', epoch ', epoch, '. avg_loss: ',
             ^
1     E999 SyntaxError: positional argument follows keyword argument
1     F821 undefined name 'bsz'
2
```

__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
Copy link
Contributor

@Tomcli Tomcli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@animeshsingh animeshsingh merged commit d0c8e70 into IBM:master Nov 8, 2018
@cclauss cclauss deleted the patch-1 branch November 8, 2018 17:54
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.

3 participants