diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index 792105b..8dc150e 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -13,6 +13,13 @@ name: LaTeX hooks require_serial: true verbose: true +- description: Default pre-commit hooks for Lua repos + entry: ./precommit/python/lua_hooks.py + id: lua-hooks + language: script + name: Lua hooks + require_serial: true + verbose: true - description: Default pre-commit hooks for Python repos entry: ./precommit/python/python_hooks.py id: python-hooks diff --git a/precommit/lua/README.md b/precommit/lua/README.md new file mode 100644 index 0000000..9ff6fcd --- /dev/null +++ b/precommit/lua/README.md @@ -0,0 +1,14 @@ +# Lua pre-commit config + +In a repository that requires [pre-commit](https://pre-commit.com), simply add a +file called `.pre-commit-config.yaml` with the following code. + +```yaml +repos: + - repo: https://github.com/paddyroddy/.github + rev: v0.1.0 + hooks: + - id: lua-hooks +``` + +Then run `pre-commit install; pre-commit autoupdate`. diff --git a/precommit/lua/__init__.py b/precommit/lua/__init__.py new file mode 100644 index 0000000..6e03199 --- /dev/null +++ b/precommit/lua/__init__.py @@ -0,0 +1 @@ +# noqa: D104 diff --git a/precommit/lua/lua-hooks.yaml b/precommit/lua/lua-hooks.yaml new file mode 100644 index 0000000..991ab40 --- /dev/null +++ b/precommit/lua/lua-hooks.yaml @@ -0,0 +1,28 @@ +--- +repos: + - repo: https://github.com/adamchainz/blacken-docs + rev: 1.18.0 + hooks: + - id: blacken-docs + additional_dependencies: + - black + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.6.3 + hooks: + - id: ruff + - id: ruff-format + - repo: https://github.com/mgedmin/check-manifest + rev: "0.49" + hooks: + - id: check-manifest + additional_dependencies: + - setuptools-scm + args: + - --no-build-isolation + - repo: https://github.com/pre-commit/mirrors-mypy + rev: v1.11.2 + hooks: + - id: mypy + additional_dependencies: + - numpy + - pydantic diff --git a/precommit/lua/lua_hooks.py b/precommit/lua/lua_hooks.py new file mode 100755 index 0000000..029c3f9 --- /dev/null +++ b/precommit/lua/lua_hooks.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python +"""Lua pre-commit hooks.""" + +import pathlib +import sys + +HERE = pathlib.Path(__file__).resolve() + +sys.path.append(str(HERE.parents[1])) + +from _run_hooks import run_hooks # noqa: E402 + + +def main() -> int: + """ + Run the Lua pre-commit hooks. + + Returns + The return code of the process + """ + return run_hooks(pathlib.Path("lua/lua-hooks.yaml")) + + +if __name__ == "__main__": + sys.exit(main())