isort – Python utility and library to sort imports

isort is a Python utility and library that automatically organises import statements. It helps developers maintain consistent import sections without manually rearranging modules whenever dependencies change.

The program can be used from the command line, called through its Python API, or integrated with development environments. It is particularly useful in projects containing numerous modules and third-party dependencies, where inconsistent import ordering can make source code harder to follow.

isort offers extensive configuration, allowing developers to adopt established formatting conventions or define their own. It can operate independently or alongside general-purpose Python formatters such as Black.

This is free and open source software.

Key Features

  • Automatically sorts Python imports alphabetically.
  • Separates imports into sections for standard library, third-party, first-party, future and relative modules.
  • Supports numerous formatting profiles, including compatibility with Black.
  • Offers configurable line lengths, indentation and multiline import formatting.
  • Provides several wrapping styles for lengthy import statements.
  • Detects and removes duplicate imports.
  • Can process individual files or recursively organise imports throughout a project.
  • Provides check and diff modes to validate imports without modifying files.
  • Offers an atomic mode that checks syntax before applying changes.
  • Supports configuration through pyproject.toml and other project configuration files.
  • Allows selected imports and files to be excluded from processing.
  • Can add or remove specified imports through command-line options.
  • Provides a Python API for sorting source code programmatically.
  • Integrates with code editors, pre-commit hooks and automated development workflows.

Website: github.com/pycqa/isort
Support:
Developer: Timothy Edmund Crosley
License: MIT License

isort is written in Python. Learn Python with our recommended free books and free tutorials.


Related Software

Python Code Formatters
RuffExtremely fast Python linter and code formatter
YAPFPython formatter based on clang-format
BlackUncompromising Python code formatter
isortPython utility and library to sort imports
autopep8Formats Python code to conform to the PEP 8 style guide
DarkerApply black reformatting to Python files
PyinkPython code formatter
docformatterAutomatically formats Python docstrings for consistent style
SSortSorts Python statements by dependency for clearer code
reorder-python-importsReorders Python imports into a consistent, readable layout
μsortSorts import statements
eradicateRemove commented-out code from Python files

Read our verdict in the software roundup.


Best Free and Open Source Software LinuxLinks helps you discover the best free and open source software for Linux. Explore our extensive collection of recommended applications, including alternatives to popular proprietary software.

We also publish software reviews, Linux tutorials, hardware reviews, free programming books and articles covering the wider open source community. Browse our Linux resources to discover more.

Know a useful free and open source Linux application we haven't covered? Suggest a program for inclusion.

Has your software been featured on LinuxLinks? Display one of our Featured on LinuxLinks badges on your website or GitHub README.
Subscribe

Please read our Comment Policy before commenting.

Notify of
guest
0 Comments
Oldest
Newest Most Voted