Skip to content

feat(tooling): Enabled local linting #1315

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

Merged
merged 5 commits into from
Feb 9, 2022

Conversation

antonpirker
Copy link
Member

To speed up development and prevent a lot of front and back with the CI linter, I added a pre-commit hook, so before one can commit something the linting (black, flake8 and mypy) will run locally to format and lint the changed files.

@antonpirker
Copy link
Member Author

I added "pre-commit" to the test-requirements.txt, did not know where to put it.

@sl0thentr0py sl0thentr0py self-requested a review January 21, 2022 13:42
@antonpirker antonpirker self-assigned this Jan 21, 2022
@sl0thentr0py
Copy link
Member

@antonpirker I'm not familiar with this tool, but why do we need this over just a normal git hook?
https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks

@antonpirker
Copy link
Member Author

pre-commit has a collection of ready made hooks to choose from and it is very easy to install/uninstall the hooks. So it is just for convenience and I think it is used in python projects quite frequently (at least in the project i was part of) :-)

@antonpirker antonpirker enabled auto-merge (squash) February 9, 2022 13:43
@antonpirker antonpirker merged commit 8df4e05 into master Feb 9, 2022
@antonpirker antonpirker deleted the antonpirker/introduce-pre-commit branch February 9, 2022 14:14
@miketheman
Copy link
Contributor

Excellent addition!
Please consider adding https://pre-commit.ci/ so that these checks can also be automatically fixed where possible. Free for open source projects like this one!

@sl0thentr0py
Copy link
Member

@miketheman we already had an autofix step here but we removed it since it was flaky on external contributors' forked PRs. Not sure if pre-commit also works with forked PRs?

@miketheman
Copy link
Contributor

I believe it does, as I use it on some of my open source projects, and it is run when people submit pull requests from their forks.

@miketheman
Copy link
Contributor

This also makes the pre-commit.yaml the source of rule evaluation, vs having to maintain them in two spots - the pre-commit files and the tox config for GH Action.

@sl0thentr0py
Copy link
Member

ok thanks! will try it out and clean this process up a bit more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants