Skip to content

chore: consolidate isort, flake8, pycln and absolufy-imports into ruff#707

Merged
axellpadilla merged 1 commit into
dbt-msft:masterfrom
joshmarkovic:jm/ruff-lint-tooling
Jun 14, 2026
Merged

chore: consolidate isort, flake8, pycln and absolufy-imports into ruff#707
axellpadilla merged 1 commit into
dbt-msft:masterfrom
joshmarkovic:jm/ruff-lint-tooling

Conversation

@joshmarkovic

Copy link
Copy Markdown
Contributor

Summary

This PR consolidates four of the five Python lint/format tools in our pre-commit config — absolufy-imports, pycln, isort, and flake8 — into a single Ruff hook configured in pyproject.toml. black and mypy are unchanged.

It is a config-only change: ruff check passes with zero findings on the current codebase (verified against master at 10df88a, ruff 0.15.17), so no Python source is touched and there is no churn to review beyond the three config files.

ruff has been in our dev dependency group since the PEP 621 packaging migration (9b8b82a) but was never wired up — this PR puts it to use.

Why

  1. absolufy-imports is unmaintained. The repo was archived on July 3, 2024 and its README states: "This tool has been superseded by Ruff. Please use that instead."
  2. Our isort hook was pinned to a prerelease (9.0.0a3), which is fragile.
  3. Fewer moving parts. Four pre-commit hook repos become one; per-hook CLI args scattered across .pre-commit-config.yaml become one [tool.ruff] block in pyproject.toml.
  4. Speed. Ruff checks the whole repo in ~0.05s (the flake8 hook alone takes ~2s through pre-commit), which makes adding a lint job to CI essentially free if we want one later.

Rule mapping

Removed tool Ruff equivalent
flake8 (--max-line-length=99) E, F, W with line-length = 99
isort (--profile black --line-length 99) I with known-first-party = ["dbt"]
pycln (--all) F401 (included in F)
absolufy-imports TID252 with ban-relative-imports = "all"
make linecheck (grep for lines ≥100 chars) E501 (included in E)

I verified each rule family actually fires by probing with a deliberately bad file (unsorted imports, unused import, relative import, 126-char line) — all flagged as expected.

Makefile changes: make flake8make ruff; make lint / make test updated accordingly; make linecheck removed as redundant with E501.

Notes and trade-offs

  • Rule parity isn't 100%: Ruff implements all of pyflakes and most of pycodestyle; a few whitespace-nitpick pycodestyle rules are preview-only. Since black already enforces formatting, this gap is immaterial here (empirically: zero findings either way today).
  • ruff format is deliberately out of scope. It would reformat 11 of 79 files (cosmetic differences from black). Keeping black means this PR causes zero source churn. Happy to discuss the formatter swap separately if there's interest.
  • Heads-up: this will conflict slightly with Correctness fixes: LABEL escaping, dead columnstore guard, init port, misc #706, which also touches .pre-commit-config.yaml and the Makefile. The conflicts are trivial; happy to rebase whichever lands second.

Checklist

  • ruff check dbt tests passes with zero findings (config-only change)
  • .pre-commit-config.yaml validates (pre-commit validate-config + yamllint)
  • No changes to Python source, black, or mypy configuration

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.
@axellpadilla axellpadilla added this to the v1.10.1rc1 milestone Jun 14, 2026
@axellpadilla axellpadilla enabled auto-merge June 14, 2026 22:21
@axellpadilla axellpadilla merged commit d709249 into dbt-msft:master Jun 14, 2026
16 checks passed
@axellpadilla

Copy link
Copy Markdown
Collaborator

@joshmarkovic Yes, if you want we can also move out to ruff format, but please wait for 1.10.1 final release state to avoid problems with current parallel work, we also can migrate from mypi to ty by astral, mypi is having some dependency issues with newer versions.

@joshmarkovic

Copy link
Copy Markdown
Contributor Author

@joshmarkovic Yes, if you want we can also move out to ruff format, but please wait for 1.10.1 final release state to avoid problems with current parallel work, we also can migrate from mypi to ty by astral, mypi is having some dependency issues with newer versions.

Awesome! I'll create issues for ruff format and mypy -> ty and start work after 1.10.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants