From 075a26ee5a09dec902e3c16b1c56336129776d38 Mon Sep 17 00:00:00 2001 From: yanghao14 Date: Sun, 28 Jul 2024 18:38:48 +0800 Subject: [PATCH] chore: configure pre-commit hooks for code formatting (#73) - Install pre-commit when using make setup. - Add pre-commit hooks for Python and Rust code formatting. --- .pre-commit-config.yaml | 31 +++++++++++++++++++++++++++++++ python/Makefile | 2 ++ 2 files changed, 33 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..8df51abb --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,31 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.6.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-json + - id: check-added-large-files + - id: check-merge-conflict + + - repo: https://github.com/charliermarsh/ruff-pre-commit + rev: v0.2.0 + hooks: + - id: ruff + args: [--fix] + - id: ruff-format + + - repo: https://github.com/pre-commit/mirrors-mypy + rev: v1.11.0 + hooks: + - id: mypy + + - repo: local + hooks: + - id: cargo-fmt + name: cargo fmt + entry: cargo fmt --all -- --check + language: system + types: [rust] + pass_filenames: false diff --git a/python/Makefile b/python/Makefile index 4badaca8..3be8f905 100644 --- a/python/Makefile +++ b/python/Makefile @@ -30,6 +30,8 @@ setup-venv: ## Setup the virtualenv setup: ## Setup the requirements $(info --- Setup dependencies ---) pip install "$(MATURIN_VERSION)" + pip install pre-commit + pre-commit install .PHONY: build build: setup ## Build Python binding of delta-rs