Skip to content

Repository files navigation

Tatari Pre-Commit Hooks

Disclaimer! This is a public repo. Take care about what information and data you put here, since it will be viewable on the internet.

Place to store all of Tatari's custom pre-commit hooks.

Adding a new hook

Python hooks

  1. Write the module in python_hooks/. Add a no-arg main() function that is the CLI entry point:

    defmain():
    """CLI entry point for the my-hook pre-commit hook."""parser=argparse.ArgumentParser(...)
    args=parser.parse_args()
    sys.exit(run(args))
    if__name__=="__main__":
    main()
  2. Register the console script in pyproject.toml under [tool.poetry.scripts]:

    [tool.poetry.scripts]
    my-hook = "python_hooks.my_hook:main"
  3. Add any required dependencies with poetry add <dep> followed by poetry lock.

  4. Define the hook in .pre-commit-hooks.yaml using the console script name as entry:

    - id: my-hookname: my-hookdescription: Run a Python pre-commit hookentry: my-hooklanguage: pythonpass_filenames: false

    Why a console script? Tools like prek resolve entry as an installed binary rather than a shell command, so python -m ... does not work. Registering a console script in pyproject.toml ensures the hook runs correctly with both pre-commit and prek.

Bash hooks

Place the script at the root of the repo and define the hook in .pre-commit-hooks.yaml:

- id: bash-examplename: bash-exampledescription: Run a Bash pre-commit hookentry: bash-script.shlanguage: systempass_filenames: false

Using hooks from this repo

Adding hook definitions to your repo's .pre-commit-config.yaml will add specific hooks from this repo to evaluate your code.

Example:

 - repo: git@github.com:tatari-tv/pre-commit-hooks.gitrev: v0.1.0hooks:
- id: poetry-pkg-dep-constraint-format

About

Custom pre-commit hooks for use by Tatari

Topics

Resources

Stars

0 stars

Watchers

11 watching

Forks

Releases

Packages

Used by

Contributors

Languages