From ae776ff08dc990a53eb509e7d496e92f70c27845 Mon Sep 17 00:00:00 2001 From: Michael Kania Date: Fri, 25 Apr 2025 15:58:08 -0700 Subject: [PATCH] Add pre-commit hooks for ruff check and format --- .pre-commit-config.yaml | 18 ++++++++++++++++++ pyproject.toml | 5 +++-- 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..4b26b92 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,18 @@ +repos: +- repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.4.2 + hooks: + - id: ruff + args: [--fix, --ignore=E501] + - id: ruff-format + +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.5.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-toml + - id: check-added-large-files + - id: debug-statements + - id: check-merge-conflict diff --git a/pyproject.toml b/pyproject.toml index 03c1563..9116290 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,6 +28,7 @@ dev = [ "pytest>=7.4.0", "ruff>=0.1.0", "mypy>=1.6.0", + "pre-commit>=4.2.0", ] [tool.ruff] @@ -35,7 +36,7 @@ line-length = 88 target-version = "py312" [tool.ruff.lint] -select = ["E", "F", "I"] +select = ["E", "F", "I", "B", "C4", "SIM", "TCH", "UP", "N", "PL", "RUF"] ignore = ["E501"] # Ignore line too long errors [tool.mypy] @@ -46,4 +47,4 @@ disallow_untyped_defs = true disallow_incomplete_defs = true [tool.pytest.ini_options] -testpaths = ["tests"] \ No newline at end of file +testpaths = ["tests"]