-
Notifications
You must be signed in to change notification settings - Fork 11
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
Add pre-commit for python formatting #15
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 like the idea of adding pre-commit hooks to avoid pushing code that will fail the limiting stage. I have three questions:
- This requires to install the
pre-commit
package, right? If so, please add it to dependencies inpyproject.toml
- Git natively already supports hooks such as
pre-commit
andpre-push
. Why use the pre-commit-hooks and pre-commit? I assume it is because you want to use the packet manager feature of thepre-commit
package to ensure that we use the same tools and versions. Additionally, you want to use some of the pre-defined hooks ofpre-commit-hooks
such ascheck-added-large-files
, correct? - Do I need to run
pre-commit install
to enable these hooks? If so, please explain this in the CONTRIBUTING.md. Additionally, according to the documentation, it is recommended to runpre-commit run --all-files
afterward to set up the environment and test the config.
Correct, will do.
It's just a convenience to make adding hooks easier. The
Yes, you need to
Yes, I did that already. |
Plus, it only runs on the changes, not on every file in the project, making it also faster compared to the current instructions in CONTRIBUTING.md |
After a quick talk with Victor, we agreed that adding it as a package dependency does not make much sense. I suggest you mention that you can install it with
Indeed, a very nice feature.
Looks good.
But each user should run this once to set up the environment, right? If so, please add this to Overall, this looks good to me. Just extend the "Pre-commit" in |
Should he? I understood the 4th optional step differently. |
@Xeratec added the installation instructions in CONTRIBUTING.md |
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.
Perfect, thanks for the changes. Ready to merge.
Add pre-commit config for the python formatting.
Pre-commit makes it easy to add git hooks that check your changes before either committing, pushing, or merging them.
I set the default stage for this config to be
pre-push
so that it isn't too overbearing.I didn't add the clang-format because pre-commit doesn't support environment variables and I didn't think of any other clever way to overcome that. We could hardcode the path to the standard llvm installation path (
install/llvm
) but I don't like that.I removed the
$>
from CONTRIBUTING.md so that you can c/p the commands directly to terminal.