Pre-commit

Pre-commit is great tool for catching bugs early and ensuring consistency across developers.

Msort can be used as part of a pre-commit workflow.

Steps

  1. Install pre-commit

$ pip install pre-commit
  1. Create a .pre-commit-config.yaml file

$ touch .pre-commit-config.yaml
  1. Paste in the msort hook

- repo: https://github.com/isaacksdata/msort
rev: v0.1.8
hooks:
  - id: msort
    args: []
  1. Initiate pre-commit

$ pre-commit init

Common amendments

  • exclusion criteria

    Files can be excluded using the --skip-patterns option

- repo: https://github.com/isaacksdata/msort
rev: v0.1.8
hooks:
  - id: msort
    args: ["--skip-patterns=test_", "--skip-patterns=_test.py"]
  • personalised configurations

    Msort in pre-commit can be configured by the user through CLI arguments or through a config file - see Configurations

- repo: https://github.com/isaacksdata/msort
rev: v0.1.8
hooks:
  - id: msort
    args: ["--config-path=./pyproject.toml"]