FAQ | This is a LIVE service | Changelog

Standardise how mypy gets run by pre-commit

Description

In MR !47 (merged) @hwtb2 introduced a new way of running mypy that used dependencies and mypy CLI options defined in pyproject.toml, to avoid needing to duplicate them in .pre-commit.yml.

To avoid ucam-faas (or other projects) using non-standard project configuration, we need to align ucam-faas with the webapp boilerplate template. Other projects also have the same issue with mypy needing pyproject.toml dependencies (and the same issue occurs in the javascript ecosystem for running typescript, as well as when running other linting tools that depend on project dependencies, or have varying behaviour between versions, so need to be kept in sync with the project version).

@hwtb2 is planning to formalise the poetry run method used in the MR into a hook repo. @st981 also suggested/wondered if it would be possible to create a poetry pre-commit language, which would allow tighter integration between poetry and pre-commit.

The plan is to advocate for the boilerplate to adopt the new hooks/language, which would bring ucam-faas in sync. Whichever approach we standardise on in boilerplate, ucam-faas should also adopt.

Further details

Task list

  • Implement a poetry pre-commit hook/language to formalise the pattern used in the MR
  • Work to get it used in boilerplate as the standard practice
  • Update ucam-faas to use the standardised approach

Acceptance criteria

  • ucam-faas is in-sync with boilerplate's approach for running project linting/validation tasks

Links/references