Re:GitHub Super Linter: one linter to rule them all
by tlrobinson on Friday June 19, 2020 @01:44AM
(#23571366)
Even better, IMHO, is just setting your editor to format on save. That way you can just write ugly code and hit save to get it formatted.
I've found git hooks to be more trouble than they're worth.
But as long as it's enforced in CI you can leave it up to individual team members how they want to do it.
1. Use a tracked directory for Git hooks: `git config --local core.hooksPath 'git-hooks'`.
2. Create format.bash and lint.bash.
2.1. Run `black` and `isort` in format.bash.
2.2. Run `flake8`, `mypy`, `black` and `isort` in lint.bash.
2.3. Run lint.bash in the pre-commit hook.
2.4. By default, lint/format only files which are different from origin/master to save time: `git diff --diff-filter=d --name-only -z origin/master "[asterisk].py"`.
3. In CI, run lint.bash with `--all` or some other keyword to verify formatting on every file: `git ls-files -z -- "[asterisk].py"`.
After more than a year with this setup I absolutely adore it.