// the find
asottile/reorder-python-imports
Rewrites source to reorder python imports
A pre-commit-friendly tool that rewrites Python import blocks into a deterministic style: one import per line, sorted by stdlib/third-party/first-party. Fills a specific niche that isort doesn't quite cover — it does more static analysis to classify imports and enforces the one-symbol-per-from-import rule that isort leaves optional.
The single-import-per-line approach genuinely reduces merge conflicts in busy files — the README example is a real problem this solves. The `--py##-plus` flags for automatically removing obsolete `__future__` imports and rewriting six/mock/typing_extensions are a useful migration tool, not just sorting. Actively maintained (push 8 days ago) and authored by someone who maintains pre-commit itself, so the pre-commit integration is first-class. The `# noreorder` escape hatch handles the real edge cases like matplotlib's `use()` call between imports without requiring ugly workarounds.
The mandatory one-import-per-from-import rule is a hard non-starter for teams that disagree with it — there's no configuration to relax it, so adoption is all-or-nothing. At 782 stars it's clearly a niche choice compared to isort or ruff's import sorter, which means less ecosystem support and fewer IDE integrations. The entire tool is one ~1800-line Python file, which makes it easy to read but also suggests it won't grow into anything more. No `pyproject.toml` support for project-level config — all options are CLI flags, so pre-commit config gets verbose fast on larger projects.