Skip to content

pre-commit hooks for running linting and formatting tools in python tests directories

FYI: @kmochocki @kudmich @mkudela @rmaslowski

Requires:

This one replaces: !820 (closed)

There is so many changes that it should be reviewed a commit by commit (apart from the renames/relocations, there are no significant changes, mostly auto-fixes from black and ruff tools and pre-commit hooks)

Hooks can be installed via:

  • pre-commit install

Hooks can be run manually (separately from commit) via:

  • pre-commit run --all-files

For WIP changes, skip checks via --no-verify flag like:

  • commit -m "WIP" --no-verify

Overall: this MR enforces commits related with python-tests to follow formatting/linting rules. This is crucial because it allows us to reveal errors and speed up the review process, standardize the code, get rid of codemeels. Of course WIP changes could skip pre-commit checks (if ever installed, via the commit ... --no-verify flag)

Work done:

  • added ci jobs that reuse logic from common-ci-configuration for running checks on python-related code (similar to schemas, clive, test-tools and helpy):
    • pre-commit hooks run
    • black run
    • ruff run
  • configuration of black
  • basic configuration for ruff (still more rules should be added in later MR(s))
  • all things related to python tests are now in the tests/python path (this change was required to properly configure include/excludes for tools), this has another benefit as previously there there functional/python_tests but no other functional tests were present, and we had a a lack of consistency since there were python related and cpp related (unit) things mixed together.
Edited by Mateusz Żebrak

Merge request reports