--- id: reorder-python-imports version: "3.17.0" license: MIT license_treatment: permissive maintenance: active --- # reorder-python-imports — Tool for reordering python imports License: permissive · Maintenance: active · Downloads: 147.7K/mo ## What it is and what it does reorder-python-imports is a command-line tool that automatically reformats Python import statements according to a consistent style designed to minimize merge conflicts. It separates imports into three sections (standard library, third-party, first-party), places import statements before from imports, splits multi-item from imports into individual lines, and removes duplicates. The tool uses static analysis to understand import classification. It integrates as a pre-commit hook or standalone CLI tool and supports options for Python version targeting (e.g., --py3-plus to remove obsolete __future__ imports), adding or removing specific imports, replacing imports with alternatives, and handling application-specific module paths. The single-import-per-line style allows multiple developers to modify imports without creating merge conflicts, even when editing the same module. Use it for: - Enforce consistent import ordering across a team codebase via pre-commit hooks. - Automatically remove obsolete __future__ imports when upgrading to newer Python versions. - Replace compatibility library imports with modern equivalents automatically. - Reduce merge conflicts when multiple contributors add imports to the same file. - Rewrite mock and typing imports for newer Python versions automatically. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Automatically reorders Python imports into a standardized format (stdlib, third-party, first-party) using static analysis, with one import per line to reduce merge conflicts. Yes. Low install friction, permissive MIT license, active maintenance, no known vulnerabilities, and a focused tool that solves a real problem (merge conflicts from import changes). Use it if your team wants deterministic import ordering enforced automatically, especially via pre-commit hooks. ## Install pip install reorder-python-imports uv add reorder-python-imports poetry add reorder-python-imports ## Installing reorder-python-imports Before you install: Low friction: pure Python wheel with a single runtime dependency (classify-imports). Active maintenance with a release 35 days ago and 784 repository stars. License in practice: MIT license permits unrestricted use, modification, and distribution in both open and closed projects with minimal obligations. Quickstart: pip install reorder-python-imports reorder-python-imports myfile.py # Or add to .pre-commit-config.yaml: # - repo: https://github.com/asottile/reorder-python-imports # rev: v3.17.0 # hooks: # - id: reorder-python-imports Requires Python 3.10 or later. Verify before relying: - Performance characteristics when processing large codebases or files with many imports. - How the static analysis approach differs in practice from similar tools on real-world projects. - Support for type-checking-only imports and conditional import blocks. ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 147.7K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags python import reordering, organize python imports, import sorting tool, merge conflict reduction, static import analysis, import formatter, python code formatter, import-formatting, pre-commit-hook, code-quality [View on SkillFed](https://skillfed.io/packages/reorder-python-imports) · [View on PyPI](https://pypi.org/project/reorder-python-imports/)