ISORT(1)
π ISORT(1) β User Commands π
okay so welcome to isort(1), the User Commands page that is literally about sorting your Python imports. this is a big one bestie, so buckle up β every single flag is in here, no skips, no cap. π¦
β¨ NAME β¨
isort β sort Python import definitions
π DESCRIPTION π
here's the whole synopsis-vibe first, exactly as it comes, every bracket and brace intact:
usage: isort [-h] [-V] [--vn] [-v] [--only-modified] [--dedup-headings]
[-q]
[-d] [--overwrite-in-place] [--show-config] [--show-files] [--df]
[-c] [--ws] [--sp SETTINGS_PATH] [--cr CONFIG_ROOT]
[--resolve-all-configs] [--profile PROFILE] [--old-finders] [-j
[JOBS]] [--ac] [--interactive] [--format-error FORMAT_ERROR]
[--format-success FORMAT_SUCCESS] [--srx] [--filter-files] [-s
SKIP] [--extend-skip EXTEND_SKIP] [--sg SKIP_GLOB]
[--extend-skip-glob EXTEND_SKIP_GLOB] [--gitignore] [--ext
SUPPORTED_EXTENSIONS] [--blocked-extension BLOCKED_EXTENSIONS]
[--dont-follow-links] [--filename FILENAME] [--allow-root] [-a
ADD_IMPORTS] [--append] [--af] [--rm REMOVE_IMPORTS]
[--float-to-top] [--dont-float-to-top] [--ca] [--cs] [-e] [--ff]
[--fgw [FORCE_GRID_WRAP]] [-i INDENT] [--lbi
LINES_BEFORE_IMPORTS] [--lai LINES_AFTER_IMPORTS] [--lbt
LINES_BETWEEN_TYPES] [--le LINE_ENDING] [--ls] [--lss] [-m
{GRID,VERTICAL,HANGING_INDENT,VERTICAL_HANGING_INDENT,VERTICAL_GRID,VERTICAL_GRID_GROUPED,VERTICAL_GRID_GROUPED_NO_COMMA,NOQA,VERTICAL_HANGING_INDENT_BRACKET,VERTICAL_PREFIX_FROM_MODULE_IMPORT,HANGING_INDENT_WITH_PARENTHESES,BACKSLASH_GRID,0,1,2,3,4,5,6,7,8,9,10,11}]
[-n] [--nis] [--ot] [--dt] [--rr] [--reverse-sort] [--sort-order
SORT_ORDER] [--sl] [--nsl SINGLE_LINE_EXCLUSIONS] [--tc] [--up]
[-l LINE_LENGTH] [--wl WRAP_LENGTH] [--case-sensitive]
[--remove-redundant-aliases] [--honor-noqa]
[--treat-comment-as-code TREAT_COMMENTS_AS_CODE]
[--treat-all-comment-as-code] [--formatter FORMATTER] [--color]
[--ext-format EXT_FORMAT] [--star-first]
[--split-on-trailing-comma] [--sd DEFAULT_SECTION]
[--only-sections] [--ds] [--fas] [--fss] [--hcss] [--srss]
[--fass] [-t FORCE_TO_TOP] [--combine-straight-imports] [--nlb
NO_LINES_BEFORE] [--src SRC_PATHS] [-b KNOWN_STANDARD_LIBRARY]
[--extra-builtin EXTRA_STANDARD_LIBRARY] [-f
KNOWN_FUTURE_LIBRARY] [-o KNOWN_THIRD_PARTY] [-p
KNOWN_FIRST_PARTY] [--known-local-folder KNOWN_LOCAL_FOLDER]
[--virtual-env VIRTUAL_ENV] [--conda-env CONDA_ENV] [--py
{all,2,27,3,310,311,312,313,36,37,38,39,auto}] [files ...]
so what does it do? it sorts Python import definitions alphabetically within logical sections. that's the whole main character moment. π
run it with no arguments at all and it'll show you a quick start guide instead β adorable. otherwise you gotta hand it one or more files/directories/stdin. use - as the first argument to represent stdin (iykyk). and if you want the pre-5.0.0 interactive behavior, hit --interactive.
π«Ά if you've used isort 4 but you're new to isort 5, there's a whole upgrading guide for you: https://pycqa.github.io/isort/docs/upgrade_guides/5.0.0.html
π general options π
-h,--helpβ shows this help message and then exits. your little tour guide. β¨-V,--versionβ Displays the currently installed version of isort.--vn,--version-numberβ Returns just the current version number without the logo. just the number, no decoration, we love a minimalist. π-v,--verboseβ Shows verbose output, such as when files are skipped or when a check is successful. it tells you everything, and honestly? gossip. π--only-modified,--omβ Suppresses verbose output for non-modified files. only the files that actually changed get to speak.--dedup-headingsβ Tells isort to only show an identical custom import heading comment once, even if there are multiple sections with the comment set. no repeats bestie, we're not doing that.-q,--quietβ Shows extra quiet output, only errors are outputted. shhh. π€«-d,--stdoutβ Force resulting output to stdout, instead of in-place. so it prints instead of touching your files.--overwrite-in-placeβ Tells isort to overwrite in place using the same file handle. Comes at a performance and memory usage penalty over its standard approach but ensures all file flags and modes stay unchanged. so yeah, it costs you speed and memory but your file flags and modes stay exactly the same. tradeoff queen. π--show-configβ See isort's determined config, as well as sources of config options.--show-filesβ See the files isort will be run against with the current config options.--df,--diffβ Prints a diff of all the changes isort would make to a file, instead of changing it in place.-c,--check-only,--checkβ Checks the file for unsorted / unformatted imports and prints them to the command line without modifying the file. Returns0when nothing would change and returns1when the file would be reformatted. the vibe check option fr fr. πΈ--ws,--ignore-whitespaceβ Tells isort to ignore whitespace differences when--check-onlyis being used.--sp,--settings-path,--settings-file,--settingsSETTINGS_PATH β Explicitly set the settings path or file instead of auto determining based on file location. you pick, it doesn't guess.--cr,--config-rootCONFIG_ROOT β Explicitly set the config root for resolving all configs. When used with the--resolve-all-configsflag, isort will look at all sub-folders in this config root to resolve config files and sort files based on the closest available config(if any).--resolve-all-configsβ Tells isort to resolve the configs for all subdirectories and sort files in terms of its closest config files. it goes digging for the nearest config, obsessed. π§--profilePROFILE β Base profile type to use for configuration. Profiles include:black,django,pycharm,google,open_stack,plone,attrs,hug,wemake,appnexus. As well as any shared profiles. pick your fighter. π--old-finders,--magic-placementβ Use the old deprecated finder logic that relies on environment introspection magic. it's deprecated and it's doing magic, which is exactly as trustworthy as it sounds. π-j,--jobs[JOBS] β Number of files to process in parallel. Negative value means use number of CPUs. negative number = "just use all my CPUs", slay. π₯--ac,--atomicβ Ensures the output doesn't save if the resulting file contains syntax errors. all or nothing, periodt.--interactiveβ Tells isort to apply changes interactively.--format-errorFORMAT_ERROR β Override the format used to print errors.--format-successFORMAT_SUCCESS β Override the format used to print success.--srx,--sort-reexportsβ Automatically sort all re-exports (module level__all__collections).
π― target options π―
- files β One or more Python source files that need their imports sorted. the whole point, honestly. β¨
--filter-filesβ Tells isort to filter files even when they are explicitly passed in as part of the CLI command.-s,--skipSKIP β Files that isort should skip over. If you want to skip multiple files you should specify twice:--skip file1 --skip file2. Values can be file names, directory names or file paths. To skip all files in a nested path use--skip-glob.--extend-skipEXTEND_SKIP β Extends--skipto add additional files that isort should skip over. If you want to skip multiple files you should specify twice:--skip file1 --skip file2. Values can be file names, directory names or file paths. To skip all files in a nested path use--skipglob.--sg,--skip-globSKIP_GLOB β Files that isort should skip over.--extend-skip-globEXTEND_SKIP_GLOB β Additional files that isort should skip over (extending--skip-glob).--gitignore,--skip-gitignoreβ Treat project as a git repository and ignore files listed in.gitignore.
β οΈ NOTE: This requires git to be installed and accessible from the same shell as isort. no git, no ignoring, bestie.
--ext,--extension,--supported-extensionSUPPORTED_EXTENSIONS β Specifies what extensions isort can be run against.--blocked-extensionBLOCKED_EXTENSIONS β Specifies what extensions isort can never be run against. never ever. π«--dont-follow-linksβ Tells isort not to follow symlinks that are encountered when running recursively.--filenameFILENAME β Provide the filename associated with a stream.--allow-rootβ Tells isort not to treat/specially, allowing it to be run against the root dir. π be careful out there.
π general output options π
-a,--add-importADD_IMPORTS β Adds the specified import line to all files, automatically determining correct placement. it finds the right spot itself, main character energy.--append,--append-onlyβ Only adds the imports specified in--add-importif the file contains existing imports.--af,--force-addsβ Forces import adds even if the original file is empty.--rm,--remove-importREMOVE_IMPORTS β Removes the specified import from all files.--float-to-topβ Causes all non-indented imports to float to the top of the file having its imports sorted (immediately below the top of file comment). This can be an excellent shortcut for collecting imports every once in a while when you place them in the middle of a file to avoid context switching.
β οΈ NOTE: It currently doesn't work with cimports and introduces some extra over-head and a performance penalty. so cute but it costs you, lowkey.
--dont-float-to-topβ Forces--float-to-topsetting off. See--float-to-topfor more information.--ca,--combine-asβ Combinesasimports on the same line.--cs,--combine-starβ Ensures that if a star import is present, nothing else is imported from that namespace.-e,--balancedβ Balances wrapping to produce the most consistent line length possible.--ff,--from-firstβ Switches the typical ordering preference, showingfromimports first then straight ones. plot twist. π--fgw,--force-grid-wrap[FORCE_GRID_WRAP] β Force number offromimports (defaults to2when passed as CLI flag without value) to be grid wrapped regardless of line length. If0is passed in (the global default) only line length is considered.-i,--indentINDENT β String to place for indents defaults to" "(4 spaces).--lbi,--lines-before-importsLINES_BEFORE_IMPORTS--lai,--lines-after-importsLINES_AFTER_IMPORTS--lbt,--lines-between-typesLINES_BETWEEN_TYPES--le,--line-endingLINE_ENDING β Forces line endings to the specified value. If not set, values will be guessed per-file.--ls,--length-sortβ Sort imports by their string length.--lss,--length-sort-straightβ Sort straight imports by their string length. Similar tolength_sortbut applies only to straight imports and doesn't affectfromimports.
and there's more coming bestie, don't go anywhere π β¨
-m,--multi-lineβ picks the multi-line output vibe. Accepted values are literally:{GRID,VERTICAL,HANGING_INDENT,VERTICAL_HANGING_INDENT,VERTICAL_GRID,VERTICAL_GRID_GROUPED,VERTICAL_GRID_GROUPED_NO_COMMA,NOQA,VERTICAL_HANGING_INDENT_BRACKET,VERTICAL_PREFIX_FROM_MODULE_IMPORT,HANGING_INDENT_WITH_PARENTHESES,BACKSLASH_GRID,0,1,2,3,4,5,6,7,8,9,10,11}. Multi line output (0-grid,1-vertical,2-hanging,3-vert-hanging,4-vert-grid,5-vert-grid-grouped,6-deprecated-alias-for-5,7-noqa,8-vertical-hangingindent-bracket,9-vertical-prefix-from-module-import,10-hanging-indent-with-parentheses).-n,--ensure-newline-before-commentsβ inserts a blank line before a comment following an import. personal space for comments, periodt.--nis,--no-inline-sortβ leavesfromimports with multiple imports 'as-is' (e.g.from foo import a, c ,b). no cap, it really does keep that chaos.--ot,--order-by-typeβ order imports by type, which is determined by case, in addition to alphabetically. NOTE: type here refers to the implied type from the import name capitalization. isort does not do type introspection for the imports. These "types" are simply:CONSTANT_VARIABLE,CamelCaseClass,variable_or_function. If your project follows PEP8 or a related coding standard and has many imports this is a good default, otherwise you likely will want to turn it off. From the CLI the--dont-order-by-typeoption will turn this off. iykyk--dt,--dont-order-by-typeβ don't order imports by type, which is determined by case, in addition to alphabetically. NOTE: type here refers to the implied type from the import name capitalization. isort does not do type introspection for the imports. These "types" are simply:CONSTANT_VARIABLE,CamelCaseClass,variable_or_function. If your project follows PEP8 or a related coding standard and has many imports this is a good default. You can turn this on from the CLI using--order-by-type.--rr,--reverse-relativeβ reverse order of relative imports.--reverse-sortβ reverses the ordering of imports.--sort-order SORT_ORDERβ specify sorting function. Can be built in (natural[default] = force numbers to be sequential,native= Python's built-in sorted function) or an installable plugin.--sl,--force-single-line-importsβ forces all from imports to appear on their own line.--nsl,--single-line-exclusions SINGLE_LINE_EXCLUSIONSβ one or more modules to exclude from the single line rule.--tc,--trailing-commaβ includes a trailing comma on multi line imports that include parentheses.--up,--use-parenthesesβ use parentheses for line continuation on length limit instead of slashes. NOTE: This is separate from wrap modes, and only affects how individual lines that are too long get continued, not sections of multiple imports.-l,-w,--line-length,--line-width LINE_LENGTHβ the max length of an import line (used for wrapping long imports).--wl,--wrap-length WRAP_LENGTHβ specifies how long lines that are wrapped should be, if not setline_lengthis used. NOTE:wrap_lengthmust be LOWER than or equal toline_length.--case-sensitiveβ tells isort to include casing when sorting module names.--remove-redundant-aliasesβ tells isort to remove redundant aliases from imports, such asimport os as os. This defaults toFalsesimply because some projects use these seemingly useless aliases to signify intent and change behaviour.--honor-noqaβ tells isort to honor noqa comments to enforce skipping those comments.--treat-comment-as-code TREAT_COMMENTS_AS_CODEβ tells isort to treat the specified single line comment(s) as if they are code.--treat-all-comment-as-codeβ tells isort to treat all single line comments as if they are code.--formatter FORMATTERβ specifies the name of a formatting plugin to use when producing output.--colorβ tells isort to use color in terminal output. slay--ext-format EXT_FORMATβ tells isort to format the given files according to an extensions formatting rules.--star-firstβ forces star imports above others to avoid overriding directly imported variables.--split-on-trailing-commaβ split imports list followed by a trailing comma intoVERTICAL_HANGING_INDENTmode.
β¨ section output options β¨
--sd,--section-default DEFAULT_SECTIONβ sets the default section for import options: ('FUTURE','STDLIB','THIRDPARTY','FIRSTPARTY','LOCALFOLDER').--only-sections,--osβ causes imports to be sorted based on their sections likeSTDLIB,THIRDPARTY, etc. Within sections, the imports are ordered by their import style and the imports with the same style maintain their relative positions.--ds,--no-sectionsβ put all imports into the same section bucket.--fas,--force-alphabetical-sortβ force all imports to be sorted as a single section.--fss,--force-sort-within-sectionsβ don't sort straight-style imports (likeimport sys) before from-style imports (likefrom itertools import groupby). Instead, sort the imports by module, independent of import style.--hcss,--honor-case-in-force-sorted-sectionsβ honor--case-sensitivewhen--force-sort-withinsectionsis being used. Without this option set,--order-by-typedecides module name ordering too. yes, that typo is literally in the manpage, bestie.--srss,--sort-relative-in-force-sorted-sectionsβ when using--force-sort-within-sections, sort relative imports the same way as they are sorted when not using that setting.--fass,--force-alphabetical-sort-within-sectionsβ force all imports to be sorted alphabetically within a section.-t,--top FORCE_TO_TOPβ force specific imports to the top of their appropriate section.--combine-straight-imports,--csiβ combines all the bare straight imports of the same section in a single line. Won't work with sections which have 'as' imports.--nlb,--no-lines-before NO_LINES_BEFOREβ sections which should not be split with previous by empty lines.--src,--src-path SRC_PATHSβ add an explicitly defined source path (modules within src paths have their imports automatically categorized asfirst_party). Glob expansion (*and**) is supported for this option.-b,--builtin KNOWN_STANDARD_LIBRARYβ force isort to recognize a module as part of Python's standard library.--extra-builtin EXTRA_STANDARD_LIBRARYβ extra modules to be included in the list of ones in Python's standard library.-f,--future KNOWN_FUTURE_LIBRARYβ force isort to recognize a module as part of Python's internal future compatibility libraries. WARNING: this overrides the behavior of__future__handling and therefore can result in code that can't execute. If you're looking to add dependencies such assix, a better option is to create another section below--futureusing custom sections. See: https://github.com/PyCQA/isort#custom-sections-andordering and the discussion here: https://github.com/PyCQA/isort/issues/1463.-o,--thirdparty KNOWN_THIRD_PARTYβ force isort to recognize a module as being part of a third party library.-p,--project KNOWN_FIRST_PARTYβ force isort to recognize a module as being part of the current python project.--known-local-folder KNOWN_LOCAL_FOLDERβ force isort to recognize a module as being a local folder. Generally, this is reserved for relative imports (from . import module).--virtual-env VIRTUAL_ENVβ virtual environment to use for determining whether a package is third-party.--conda-env CONDA_ENVβ conda environment to use for determining whether a package is third-party.--py,--python-version {all,2,27,3,310,311,312,313,36,37,38,39,auto}β tells isort to set the known standard library based on the specified Python version. Default is to assume any Python 3 version could be the target, and use a union of all stdlib modules across versions. Ifautois specified, the version of the interpreter used to run isort (currently:313) will be used.
and then the manpage hits you with this iconic little banner:
_ _
(_) ___
___ _ __| |_
| |/ _/ / _ \/ '__
_/
| |\__ \/\_\/| |
| |_
|_|\___/\___/\_/
\_/
isort your imports, so you don't have to.
VERSION 6.0.0
π SEE ALSO π
Additional documentation for isort is available online at
https://pycqa.github.io/isort/
and that's the whole page, bestie! isort 6.0.0, February 2025, ISORT(1) β literally the footer. byeee π
β¨
π¦ where this page comes from
- ubuntu resolute: isort 7.0.0-1 Β· MIT
- ubuntu stonking: isort 8.0.1-2 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms