From 9d20ad7dde4d83389181f5da4e4afe6b5c1f6b9c Mon Sep 17 00:00:00 2001 From: Josh Markovic Date: Fri, 12 Jun 2026 21:04:06 +0000 Subject: [PATCH] chore: consolidate isort, flake8, pycln and absolufy-imports into ruff Replace four lint pre-commit hooks with a single ruff hook configured in pyproject.toml. Equivalent rule coverage: E/F/W (flake8), I (isort), F401 (pycln), TID252 + ban-relative-imports (absolufy-imports, archived upstream July 2024). black and mypy are unchanged. ruff check passes with zero findings on the current codebase, so this is a config-only change with no source churn. The Makefile flake8 target becomes ruff, and linecheck is dropped as E501 (line-length 99) now covers it. --- .pre-commit-config.yaml | 40 ++++++++-------------------------------- Makefile | 17 ++++++----------- pyproject.toml | 16 ++++++++++++++++ 3 files changed, 30 insertions(+), 43 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 402e67158..0015df9e1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -27,28 +27,16 @@ repos: args: - '-d {extends: default, rules: {line-length: disable, document-start: disable}}' - '-s' - - repo: 'https://github.com/MarcoGorelli/absolufy-imports' - rev: v0.3.1 + - repo: 'https://github.com/astral-sh/ruff-pre-commit' + rev: v0.15.17 hooks: - - id: absolufy-imports - - repo: 'https://github.com/hadialqattan/pycln' - rev: v2.6.0 - hooks: - - id: pycln - args: - - '--all' - - repo: 'https://github.com/pycqa/isort' - rev: 9.0.0a3 - hooks: - - id: isort + - id: ruff-check args: - - '--profile' - - black - - '--atomic' - - '--line-length' - - '99' - - '--python-version' - - '39' + - '--fix' + - id: ruff-check + alias: ruff-check-manual + stages: + - manual - repo: 'https://github.com/psf/black' rev: 26.5.1 hooks: @@ -65,18 +53,6 @@ repos: - '--target-version=py310' - '--check' - '--diff' - - repo: 'https://github.com/pycqa/flake8' - rev: 7.3.0 - hooks: - - id: flake8 - args: - - '--max-line-length=99' - - id: flake8 - args: - - '--max-line-length=99' - alias: flake8-check - stages: - - manual - repo: 'https://github.com/pre-commit/mirrors-mypy' rev: v2.1.0 hooks: diff --git a/Makefile b/Makefile index defc31e1c..afa615764 100644 --- a/Makefile +++ b/Makefile @@ -11,10 +11,10 @@ mypy: ## Runs mypy against staged changes for static type checking. @\ pre-commit run --hook-stage manual mypy-check | grep -v "INFO" -.PHONY: flake8 -flake8: ## Runs flake8 against staged changes to enforce style guide. +.PHONY: ruff +ruff: ## Runs ruff against staged changes to enforce style guide. @\ - pre-commit run --hook-stage manual flake8-check | grep -v "INFO" + pre-commit run --hook-stage manual ruff-check-manual | grep -v "INFO" .PHONY: black black: ## Runs black against staged changes to enforce style guide. @@ -22,9 +22,9 @@ black: ## Runs black against staged changes to enforce style guide. pre-commit run --hook-stage manual black-check -v | grep -v "INFO" .PHONY: lint -lint: ## Runs flake8 and mypy code checks against staged changes. +lint: ## Runs ruff and mypy code checks against staged changes. @\ - pre-commit run flake8-check --hook-stage manual | grep -v "INFO"; \ + pre-commit run ruff-check-manual --hook-stage manual | grep -v "INFO"; \ pre-commit run mypy-check --hook-stage manual | grep -v "INFO" .PHONY: all @@ -32,11 +32,6 @@ all: ## Runs all checks against staged changes. @\ pre-commit run -a -.PHONY: linecheck -linecheck: ## Checks for all Python lines 100 characters or more - @\ - find dbt -type f -name "*.py" -exec grep -I -r -n '.\{100\}' {} \; - .PHONY: unit unit: ## Runs unit tests. @\ @@ -52,7 +47,7 @@ test: ## Runs unit tests and code checks against staged changes. @\ pytest -n auto -ra -v tests/unit; \ pre-commit run black-check --hook-stage manual | grep -v "INFO"; \ - pre-commit run flake8-check --hook-stage manual | grep -v "INFO"; \ + pre-commit run ruff-check-manual --hook-stage manual | grep -v "INFO"; \ pre-commit run mypy-check --hook-stage manual | grep -v "INFO" .PHONY: server diff --git a/pyproject.toml b/pyproject.toml index f614941a7..1613c3af0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -90,3 +90,19 @@ namespaces = true [tool.uv] link-mode = "copy" + +[tool.ruff] +line-length = 99 +target-version = "py310" + +[tool.ruff.lint] +# E/W = pycodestyle, F = pyflakes (together: flake8), I = isort, +# TID252 = no relative imports (absolufy-imports); unused-import +# removal (pycln) is F401, included in F +select = ["E", "F", "W", "I", "TID252"] + +[tool.ruff.lint.isort] +known-first-party = ["dbt"] + +[tool.ruff.lint.flake8-tidy-imports] +ban-relative-imports = "all"