-
-
Notifications
You must be signed in to change notification settings - Fork 60
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 black
code formatter to the python codebase
#286
Conversation
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.
I see that you are adding pre-commit hooks. Are these setup in such a way that they will not interfere with contributors who make contributions without python installed?
.pre-commit-config.yaml
Outdated
# pre-commit's default_language_version, see | ||
# https://pre-commit.com/#top_level-default_language_version | ||
language_version: python3.8 | ||
exclude: "python/gherkin/parser.py" |
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.
Ideally this is kept in the python
folder.
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.
done in f1e0e7e
167c796
to
bec0869
Compare
f6ecef7
to
02ce5bf
Compare
yes |
by running `pre-commit run --all-files` and reverting `parser.py`
02ce5bf
to
f473cbe
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.
Looks good to me
I'm assuming the GitHub actions work will be in separate PR |
One thing to bare in mind (I'm doing the same in ruby), is some long methods in gherkin are written in a way that is almost language agnostic, so it reads the same in every language. |
@@ -0,0 +1,9 @@ | |||
# See https://pre-commit.com for more information | |||
# See https://pre-commit.com/hooks.html for more hooks | |||
repos: |
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.
Would it be possible to keep this whole file in the python
folder?
Right now, if I have the pre-commit plugin installed, it looks like it will activate black regardless of whether or not I have python.
This poses a problem for contributors seeking to contribute to languages other than python, they may not have it installed.
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.
pre-commit installs hooks in a completely isolated environment that does not affect global packages. If other contributors don't touch the python
folder, the black
hook won't even run at all.
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.
I tried putting .pre-commit-config.yaml
under the python
directory, but it won't allow any other .pre-commit-config.yaml
to be used if anyone decides to have one under java/
or any other folder.
Seems like a limitation of pre-commit.
So the only way is to keep it on the root dir, and explicitly whitelist the dirs that each hook should handle.
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.
I'm not sure about the pre-commit hook yet. Looks like it will activate regardless.
not sure how this applies in this PR @luke-hill |
🤔 What's changed?
black
code formatter to the python codebase, to enforce a standard formatting.pre-commit-config.yaml
to the project, so that we can enforce this conventionadd github action to check the pre-commit hooks have been appliedWill add pre-commit.ci app once this lands⚡️ What's your motivation?
The python codebase does not really use a standard formatting, this is arguably widely accepted as "annoying".
🏷️ What kind of change is this?
♻️ Anything particular you want feedback on?
📋 Checklist:
This text was originally generated from a template, then edited by hand. You can modify the template here.