Are there any premade solutions to enforce good Python standards in Git commit hooks?
Are there way to automamize this process in local checkouts (akin Bazaar where one can push commit hooks to clients)? It should be enough that when you checkout a repo it would come with commit hooks installed, no further work / commands to run.
E.g. if your .py file has a tab the commit would abort and a droid is send to spank the developer.
8 years later, you would use GitHub Actions, like github/super-linter.
I present that approach in "How to set up actions in GitHub for new user?".
You could add a service on GitHub side (see "GitHub - All the Hooks", and the existing third-party services).
But you cannot "push a hook" (see "why it is not possible to git add .git/hooks/my-hook" or "Git remote/shared pre-commit hook".
You can version the script which would serve as hook, but each client would still need to activate their pre-commit hook (with a symbolic link pointing to that versioned script).
An example of such a versioned script (for Python standards) would be visible in this blog post, by Lorenzo Bolla, and updated in this GitHub repo.
It is based on PyLint and PyFlake (see also "PyLint, PyChecker or PyFlakes?").
The OP mentions in the comments the package vvv 0.1
A convenience utility for software source code validation and linting
VVV
is a tool for easy validation and linting integration for your software project.
With a single command validate all files, no matter in which programming language, in a source tree against a policy you specify in a simple configuration file.VVV
prevents bad stuff to be committed in your software source control or makes cleaning it up easier.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With