Linting isn't about making people do things the Right Way, it's about everyone doing it the same way.
- Python doesn't care if we wrap a string in apostrophies
'or quotes"so why should we? - Consistancy is the most beneficial result of automated linting
- Has anyone here written git hooks for linting multiple different file types?
- Out of the box, git supports one pre-commit hook (lots of overhead, in dev time or in commit time)
- Has almost everything that you'd want (and the ability to add custom repos)
- Setup takes less than a minute
ahonnecke@autoantonym:~/src/linting-talk$ pre-commit install
pre-commit installed at .git/hooks/pre-commitahonnecke@autoantonym:~/src/linting-talk$ cat .pre-commit-config.yaml
# See http://pre-commit.com for more information
# See http://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.5.0
hooks:
- id: check-ast
- id: flake8
- id: trailing-whitespace
- id: end-of-file-fixer
- id: mixed-line-ending
- id: check-json
- id: check-symlinks
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/psf/black
rev: 19.10b0
hooks:
- id: black
- repo: https://github.com/timothycrosley/isort
rev: 4.3.21
hooks:
- id: isort
- repo: https://github.com/asottile/pyupgrade
rev: v1.26.2
hooks:
- id: pyupgradeahonnecke@autoantonym:~/src/linting-talk$ pre-commit autoupdate
Updating https://github.com/pre-commit/pre-commit-hooks ... already up to date.
Updating https://github.com/psf/black ... already up to date.
Updating https://github.com/timothycrosley/isort ... already up to date.
Updating https://github.com/asottile/pyupgrade ... already up to date.ahonnecke@autoantonym:~/src/linting-talk$ pre-commit
Check python ast.....................................(no files to check)Skipped
Flake8 (deprecated, use gitlab.com/pycqa/flake8).....(no files to check)Skipped
Trim Trailing Whitespace.............................(no files to check)Skipped
Fix End of Files.....................................(no files to check)Skipped
Mixed line ending....................................(no files to check)Skipped
Check JSON...........................................(no files to check)Skipped
Check for broken symlinks............................(no files to check)Skipped
Check Yaml...........................................(no files to check)Skipped
Check for added large files..........................(no files to check)Skipped
black................................................(no files to check)Skipped
isort................................................(no files to check)Skipped
pyupgrade............................................(no files to check)Skipped
