Description
Status quo
Currently we mix formatters and linters with pre-commit
:
formatters
vision/.pre-commit-config.yaml
Lines 9 to 11 in 578c154
vision/.pre-commit-config.yaml
Lines 23 to 26 in 578c154
linters
vision/.pre-commit-config.yaml
Lines 5 to 8 in 578c154
vision/.pre-commit-config.yaml
Lines 31 to 32 in 578c154
vision/.pre-commit-config.yaml
Line 37 in 578c154
In addition we have a separate CI job that lints with mypy
Line 298 in 578c154
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-commit
as "single source of truth" for formatting code. Currently they mentioned as "purely optional" in our contribution guide. Sincepre-commit
supports 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-commit
anyway, 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
flake8
orpydocstyle
trigger very seldom anyway due to the auto-formatting. Plus, we already need to runmypy
separately.
cc @seemethere