-
Notifications
You must be signed in to change notification settings - Fork 21
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
Reformat and lint files with black and flake8 #168
Conversation
Format with black; fix many, many defects identified with pylint
Python prefers snake_case for script and module names and this fixes pylint complaining about this
black target will reformat all Python scripts flake8 will run linter on all Python scripts
Passes flake8 (required) and most of pylint (recommended)
Pass flake8 (required) and most of pylint (recommended)
black should be used for formatting scripts must be error free with flake8
pylint checks pushed an implementation where most code was inside the main() function, however this caused a problem with unittest that will only run tests in the global namespace, but use of globals is rather nasty This reimplementaion keeps the argument parsing and test case generation in a main-ish function, but returns the test case and then invokes unittest.main() which is a much nicer implementation
Only need to run flake8 on one platform
The urlopen() call in these tests is to the http server that was setup by the unittest itself, so we know that it's ok
This was an accident, but it proved that the flake8 GH action works as we want!
Hi @amete - this should be good to go now. All the scripts have been reformatted and small translation bugs are fixed |
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.
Thanks a lot for this @graeme-a-stewart! The python code looks quite a bit cleaner now. All tests pass (locally as well). I ran the plotting script over a test file and the output looks good (i.e. no change). I'm merging now.
A bit of an overdue clean-up of all of the Python scripts.
black
flake8
The scripts were also checked against
pylint
, and many issues from there fixed. However, it's exceedling strict and there are even some formatting decisions wherepylint
andblack
disagree, so that without specific exceptions added to the scripts the two checks can't agree. Most of the scripts test at 9/10 (or better) withpylint
. We should endevour to keep the scripts good againstpylint
without enforcing it.A GitHub action was added to run
flake8
as part of the CI.Fixes #157