-
Notifications
You must be signed in to change notification settings - Fork 51
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
Apply PEP8 to the whole codebase and fix some flake8 errors #1146
Conversation
@sambles have a look at these changes. What do you think? |
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.
Looks fine to me.
I've only scanned the changed files quickly but it looks consistent. I find some of the original formatting easier to read, but happy to go with this for enforced consistency.
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.
Looks much better without the --aggressive
flag
Question on the linting call, using --exit-zero
, why not have that fail and cleanup some of the issues it raises too?
I think it makes sense to ignore some of the formatting warnings (since it should be PEP8 anyway), something like flake8 --show-source oasislmf/ --ignore W503,W504
.
- W504 line break after binary operator
- W503 line break before binary operator
.. etc with whichever warns we don't care about
Thank you @sambles I'll have a look now at how we can fix some of the warnings raised by flake8. They seemed quite a few, so I don't know how much time it'd have taken to fix them. But certainly having also flake8 as a 'live' check that makes the workflow fail if it fails is the right direction to go. |
@sambles if you have a look at the failed test Any ideas how to get around this? |
Yup agreed on rolling back and merging this for the PEP8 checking, it makes sense to start a new PR for flake if its a bigger job
|
fc4ee3b
to
a1fa599
Compare
@sambles I've reverted back as we discussed. Then, I've just implemented innocuous fixes to flake8 errors:
I've now enforced flake8 to fail the CI workflow if these 4 errors are introduced in new code. |
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.
Looks good, thanks for the changes
* dummy commit to have the code as in develop in this branch * pep8 line length 150 non agg * full PEP8 * [ci] add PEP8 check * [ci] updated Code Quality checks * [ci] cleanup * test non PEP8 code * [ci] fail if PEP8 doesn't pass * [ci] remove unnecessary step * fix non-PEP8 example issue * revert some changes to cleanup * [flake8] fix all F401,F522,F524,F524,F541 * [flake8] fix import
In this PR:
We used with the following customization:
E402
(docs here) which forces all module imports at top of file. This might clash with some initializations (e.g. the logging module) that we want to perform before importing other modules.running the following command at the repository root:
Code Quality
that:autopep8
).Issue #1147 tracks the job required to address all flake8 errors throughout the codebase, which is likely to require some non-obvious refactoring and thus an accurate integration testing.
Improving Code Quality
This PR makes all the codePEP8 compliant and introduces automatic CI checks to preserve PEP8 compliance.
This PR fixes some flake8 errors and introduces automatic CI checks to avoid that the same errors are introduced in the code in the future.