Skip to content

Split autoformatters and linters into different workflows and CI jobs #5167

Open
@pmeier

Description

@pmeier

Status quo

Currently we mix formatters and linters with pre-commit:

formatters

- id: mixed-line-ending
args: [--fix=lf]
- id: end-of-file-fixer

- id: ufmt
additional_dependencies:
- black == 21.9b0
- usort == 0.6.4

linters

- id: check-docstring-first
- id: check-toml
- id: check-yaml
exclude: packaging/.*

- id: flake8
args: [--config=setup.cfg]

- id: pydocstyle

In addition we have a separate CI job that lints with mypy

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-commit as "single source of truth" for formatting code. Currently they mentioned as "purely optional" in our contribution guide. Since pre-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 through pre-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 or pydocstyle trigger very seldom anyway due to the auto-formatting. Plus, we already need to run mypy separately.

cc @seemethere

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions