Run isort on a Python project before committing to automatically clean up all import statements in one pass.
Add isort to a CI pipeline in check-only mode to fail the build when imports are not sorted.
Install the editor plugin for VS Code or PyCharm to have imports sorted automatically as you write code.
Configure isort to match your project's specific line length and import grouping conventions.
Requires Python 3.10 or higher to run the tool itself, though it can sort code written for older Python versions.
isort is a small utility for Python developers that automatically cleans up and reorganizes the import statements at the top of Python files. In Python, every file usually starts with a list of imports (lines that bring in code from other files or packages). These can easily become jumbled over time as a codebase grows. isort sorts them alphabetically, groups them by category (standard library, third-party packages, your own code), and removes duplicates. The tool can be run from the command line on a single file, a folder, or an entire project. It also has a check-only mode that reports which files have unsorted imports without modifying them, which is useful in automated testing or continuous integration pipelines. A git hook integration lets it run automatically before each commit. Isort can also be used directly in Python code as a library, and editor plugins exist for a range of text editors and IDEs so imports get sorted as you work. Configuration options cover things like line length, how long import lines wrap, whether to include trailing commas, and how to order custom sections beyond the built-in groupings. Individual imports or entire files can be marked to skip sorting using inline comments or a marker in the file's docstring. Installation is a single pip command. The project requires Python 3.10 or higher to run the tool itself, but it can format code written for older Python versions including Python 2. Isort is part of the PyCQA (Python Code Quality Authority) organization, which maintains several widely used Python code quality tools. It is MIT licensed and actively maintained with a full documentation site.
← pycqa on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.