A tool for automatically reordering Python imports into a consistent style (stdlib, third-party, first-party) and removing unused imports. Current version: 3.16.0. Released irregularly, maintained by asottile.
pip install reorder-python-importsVerified import paths — ran on the pinned version, not inferred.
Reorder imports via CLI or programmatically. The fix_file_contents function returns reordered code.
Pin to version 2.x if needed: pip install 'reorder-python-imports<3'
Manually verify that imports used dynamically are not removed. Use '--no-remove-unused' flag to disable removal.
Place type-checking imports in a separate block or use '# noqa' comments judiciously; review output.
Run: pip install reorder-python-imports
Check CLI options with: reorder-python-imports --help
No dependency data recorded yet.