Run
isort .
Sort every Python file below here
isort <file.py> <dir>
Sort given files and folders
isort --check-only .
Exit 1 if any file would change
isort --diff .
Print the changes, write nothing
isort --check-only --diff .
Show why a CI check fails
isort --diff --check-only <file.py>
Diff plus failing exit code, one file
isort -d <file.py>
Print sorted result to stdout
isort -c -q .
Check, print errors only
isort --color --diff .
Colored diff
isort --atomic .
Skip saving if the result has a syntax error
isort -j <n> .
Process files in parallel
isort --only-modified -v .
Verbose, but only for changed files
isort --interactive .
Confirm each change
Style
isort --profile black .
Use a preset (black, django, google, ...)
isort -l <n> .
Maximum import line length
isort -m <mode> .
Multi-line wrap mode (GRID, VERTICAL, 3, ...)
isort --tc --up .
Trailing comma and parentheses
isort --sl .
One imported name per line
isort --ca .
Combine 'as' imports on one line
isort --fss .
Sort by module, ignore import / from style
isort --ff .
Put from imports before straight imports
isort --dt .
Do not order by CONSTANT / Class / func
isort --case-sensitive .
Respect case when sorting modules
isort --reverse-sort .
Reverse the order
isort --float-to-top .
Move mid-file imports to the top
isort --lai <n> .
Blank lines after the import block
isort --le <ending> .
Force line endings (LF, CRLF)
isort --remove-redundant-aliases .
Drop 'import os as os'
Sections
isort -p <pkg> .
Treat <pkg> as first party
isort --src <dir> .
Add a source path (finds first-party code)
isort -o <pkg> .
Treat <pkg> as third party
isort -b <module> .
Treat <module> as standard library
isort --known-local-folder <name> .
Treat <name> as a local folder
isort --sd <SECTION> .
Default section for unknown modules
isort --py <ver> .
Stdlib list for a Python version (310, auto)
isort --ds .
Put all imports in one section
isort --nlb <SECTION> .
No blank line before this section
isort -t <module> .
Force a module to the top of its section
isort --virtual-env <dir> .
Venv used to detect third party
Sections, in order
| Section |
Holds |
FUTURE |
__future__ |
STDLIB |
Python standard library |
THIRDPARTY |
Installed packages |
FIRSTPARTY |
Your own packages |
LOCALFOLDER |
Relative imports (from . import x) |
Imports and files
isort -a '<import>' .
Add an import to every file
isort --rm '<import>' .
Remove an import from every file
isort --af -a '<import>' .
Add even to files without imports
isort -s <name> .
Skip a file or directory
isort --extend-skip <name> .
Skip more, keep the default skips
isort --sg '<glob>' .
Skip by glob pattern
isort --gitignore .
Skip files listed in .gitignore
isort --filter-files <file.py>
Apply skips to explicitly named files
isort --ext <ext> .
Also sort files with this extension
isort --show-files .
List files isort would process
isort --filename <name> -
Tell stdin its filename for config lookup
isort --dont-follow-links .
Do not follow symlinks