diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..9ceb40e64 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,17 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: f23336e5dc4bf11588d7db19f675418cf570971b + hooks: + - id: no-commit-to-branch + args: ["--branch", "main"] + + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: b831c3dc5d27d9da294ae4e915773b99aa24a7c5 + hooks: + - id: ruff-check + args: [--fix] + - id: ruff-format + - repo: https://github.com/NixOS/nixfmt + rev: ccb94535e519e94b77d6bda76ac1de06e9f11284 + hooks: + - id: nixfmt-nix diff --git a/flake.nix b/flake.nix index dbb94dd4a..098d8bd84 100644 --- a/flake.nix +++ b/flake.nix @@ -159,6 +159,7 @@ cudaPackages.cuda_cudart isort mypy + pre-commit pyright ruff ] @@ -192,6 +193,7 @@ postVenvCreation = '' unset SOURCE_DATE_EPOCH ( python -m pip install --no-build-isolation --no-dependencies -e kernels ) + pre-commit install ''; } diff --git a/kernels/pyproject.toml b/kernels/pyproject.toml index 605b5f5a2..45faa771a 100644 --- a/kernels/pyproject.toml +++ b/kernels/pyproject.toml @@ -26,6 +26,7 @@ build-backend = "setuptools.build_meta" dev = [ "mktestdocs>=0.2.5", "mypy>=1.15.0", + "pre-commit", "pytest>=8", # Whatever version is compatible with pytest. "pytest-benchmark",