-
Notifications
You must be signed in to change notification settings - Fork 296
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
Use pre-commit #347
Use pre-commit #347
Conversation
Codecov ReportPatch coverage:
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #347 +/- ##
==========================================
+ Coverage 89.13% 89.14% +0.01%
==========================================
Files 33 33
Lines 1620 1622 +2
Branches 306 307 +1
==========================================
+ Hits 1444 1446 +2
Misses 124 124
Partials 52 52
☔ View full report in Codecov by Sentry. |
If unfamiliar with pre-commit, you can do the following to test it out:
What you'll see is that pre-commit runs isort against the one staged file (but not both!), isort lints and fixes the file's imports, and the commit fails. Notably, pre-commit stashes changes temporarily so only what you've staged gets checked. For example, this is the output I see locally when I rearrange the imports in
I have to stage isort's fixes to my commit before I can successfully commit. |
Hi Anish! I hope your year is off to a good start! I'm going to close this PR to reduce cognitive load. Thanks for your work on dotbot! |
git pre-commit hooks can catch linting issues on developer PCs before they're ever committed to the repo. pre-commit is a widely-used tool that allows projects to specify all of the linters they want to run before each commit.
This PR introduces a pre-commit config that will enforce standard text linting; black, isort, and editorconfig linting; and idiomatic Python 3.6+ syntax.
pre-commit install
in the dotbot repo, and from that point forward git will run the tool prior to each commit so the files are linted and auto-fixed.