-
Notifications
You must be signed in to change notification settings - Fork 7.2k
Description
Status quo
Currently we mix formatters and linters with pre-commit:
formatters
vision/.pre-commit-config.yaml
Lines 9 to 11 in 578c154
| - id: mixed-line-ending | |
| args: [--fix=lf] | |
| - id: end-of-file-fixer |
vision/.pre-commit-config.yaml
Lines 23 to 26 in 578c154
| - id: ufmt | |
| additional_dependencies: | |
| - black == 21.9b0 | |
| - usort == 0.6.4 |
linters
vision/.pre-commit-config.yaml
Lines 5 to 8 in 578c154
| - id: check-docstring-first | |
| - id: check-toml | |
| - id: check-yaml | |
| exclude: packaging/.* |
vision/.pre-commit-config.yaml
Lines 31 to 32 in 578c154
| - id: flake8 | |
| args: [--config=setup.cfg] |
vision/.pre-commit-config.yaml
Line 37 in 578c154
| - id: pydocstyle |
In addition we have a separate CI job that lints with mypy
Line 298 in 578c154
| type_check_python: |
Proposal
I propose we change the rationale from the two CI jobs from pre-commit and mypy to code format and lint. That means, we would only keep autoformatters in our pre-commit configuration and move all linters to what is currently the mypy job.
Pros
- We could use
pre-commitas "single source of truth" for formatting code. Currently they mentioned as "purely optional" in our contribution guide. Sincepre-commitsupports running the hooks manually, we can simply treat it as our way to bundle all autoformatters while the user does not need to know or care what exactly is run. - We could simply add new autoformatters if they are available through
pre-commit, e.g. add prettier as non-code auto formatter #5158. If anyone applies code formatting throughpre-commitanyway, that won't break any workflow.
Cons
- We would loose the ability to run linters in a bundled manner. I don't think this is a strong con, since linters such as
flake8orpydocstyletrigger very seldom anyway due to the auto-formatting. Plus, we already need to runmypyseparately.
cc @seemethere