-
Notifications
You must be signed in to change notification settings - Fork 455
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
Enhance pre-commit hooks with flake8 and black #2407
Conversation
e438b0c
to
fb3d11f
Compare
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 for doing this.
Basically, lgtm
@@ -0,0 +1,3 @@ | |||
[flake8] | |||
max-line-length = 100 | |||
extend-ignore = W503, E203 |
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.
extend-ignore = W503, E203 | |
extend-ignore = W503 |
Instead of ignoring this error, could you fix those errors?
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.
Sure I will, there is a small mistake in my flake8 fix as well, wrong indentation. Will fix that as well
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.
Black adds whitespace before : in slices, and flake8 complains about it.
Recomended configs for black:
Compatible configuration files can be found here
This behaviour may raise E203 whitespace before ':' warnings in style guide enforcement tools like Flake8. Since E203 is not PEP 8 compliant, you should tell Flake8 to ignore these warnings. More here.
WDYT?
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.
Oh, that makes sense.
Could you add a comment here on why we must ignore E203?
Also add's the flake8 config file Signed-off-by: Ignas Baranauskas <ibaranau@redhat.com>
Signed-off-by: Ignas Baranauskas <ibaranau@redhat.com>
Signed-off-by: Ignas Baranauskas <ibaranau@redhat.com>
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.
Thank you!
/lgtm
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: tenzen-y The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
hooks: | ||
- id: black | ||
files: (sdk|examples)/.* | ||
- repo: https://github.com/pycqa/flake8 | ||
rev: 7.1.1 | ||
hooks: | ||
- id: flake8 | ||
files: (sdk|examples)/.* |
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.
@Ygnas Please can create PR to add the pkg
directory as well ?
We have some Python files also: https://github.com/kubeflow/katib/tree/master/pkg/suggestion/v1beta1, https://github.com/kubeflow/katib/tree/master/pkg/earlystopping/v1beta1/medianstop
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.
Good point.
@Ygnas Thank you for your contribution! I'm trying to update a PR (#2393), and the new pre-commit check is working. However, it looks like there's an issue with the compatibility between the isort and black checks. Specifically, I've run "pre-commit run --all-files" locally, but the isort and black checks keep failing for "katib_client.py". It seems that this is because the pre-commit configuration is using the |
What this PR does / why we need it:
This PR implements the flake8 linter and black formatting as a pre-commit hook to ensure code quality and adherence to style guidelines.
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #
Checklist:
Not sure if I there is a need to exclude something else in the pre-commit config??. If it should be please let me know