isort
Sort Python imports
SYNOPSIS
isort [OPTIONS] [FILE|DIR]...
PARAMETERS
-h, --help
Show help message and exit.
--version
Display isort version.
--check-only
Check if files are sorted; exit with 0/1. No changes made.
--diff
Output unified diffs of changes instead of modifying files.
--profile NAME
Use predefined config profile (e.g., black, django, flask).
--settings-path PATH
Path to custom settings file.
--src-path PATH
Mark paths as source; repeat for multiple. Affects local import detection.
-V, --verbose
Enable verbose logging.
-q, --quiet
Suppress output messages.
-a TEXT, --append-only TEXT
Append TEXT only if missing; no sorting or deduping.
--ignore-whitespace
Ignore whitespace differences in checks.
-m INT, --multi-line INT
Control multi-line import output: 0=grid, 1=vertical, 2=hanging, 3=vertical-hanging.
--float-to-top
Move single-line from x import x imports to top of section.
--force-grid-wrap 0,1
Force grid wrap mode for multi-line imports.
--skip FILE
Skip processing specific files; glob patterns allowed.
DESCRIPTION
isort is a popular Python tool for sorting and organizing import statements in Python files according to PEP 8 guidelines.
It automatically groups imports into logical sections: standard library, third-party libraries, and local imports. Imports within each section are sorted alphabetically, with support for multi-line imports, hanging indents, and trailing commas.
Key capabilities include:
• In-place sorting of files or directories.
• Dry-run checks with --check-only for CI pipelines.
• Diff output via --diff to review changes.
• Configurable profiles for frameworks like black, Django, Flask.
• Skipping of already-sorted files and non-Python files.
isort integrates seamlessly with editors (VS Code, Vim), pre-commit hooks, and linters. It reduces merge conflicts in teams by enforcing consistent import order. Configuration options allow customization of line lengths, known third-party packages, and source paths via CLI, environment variables, or files like pyproject.toml.
Primarily used in Python development workflows to maintain clean, readable codebases.
CAVEATS
Not a core Linux utility; install via pip install isort. Requires Python ≥3.8. Processes only Python files (.py). Config inheritance from multiple files may lead to unexpected behavior.
CONFIGURATION SOURCES
Prioritized: CLI > env vars > pyproject.toml > isort.cfg > .isort.cfg > setup.cfg > tox.ini.
PROFILES
Built-in: black (default), django, flask, google, pytest. Custom profiles via --profile.
HISTORY
Created by Timothy Crosley in 2015 as a simple import sorter. Rewritten in v5 (2020) for performance using typed_ast. Now maintained by PyCQA; v5.13+ supports modern Python features and pyproject.toml. Widely adopted in Python ecosystem.


