usort
Safe, minimal import sorting
Decision gist · record as of 2026-08-14
Yes. μsort is actively maintained, has no known vulnerabilities, installs with low friction, and solves a real problem—safe import sorting that respects code structure. It is a good fit if you want conservative import reordering that avoids breaking changes. The MIT license poses no restrictions.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.10 or newer to run
- Low friction installation with seven runtime dependencies.
- Active maintenance with latest release on 2026-01-13 and repository last commit on 2026-03-01.
License · maintenance · safety
permissive license (permissive) — MIT license permits free use, modification, and distribution with minimal restrictions—suitable for both open-source and commercial projects.
last release 2026-01-13 (213 days) · last repo commit 2026-03-01 · 205 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 2,519,103 downloads/mo, #3,026 on PyPI
Alternatives
Verify before relying
pip install usort
usort format path/to/file.py
# or for validation:
usort check path/to/file.py- How μsort handles complex import patterns (star imports, conditional imports, or dynamic imports)
- Performance characteristics when sorting large files or projects with many imports
- Compatibility with other formatters and linters beyond pre-commit integration
What it is and what it does
μsort is a Python import sorter designed to make minimal, safe changes to code. Rather than reordering all imports globally, it detects distinct blocks of imports separated by non-import statements and sorts only within those blocks. This conservative approach avoids the risk of breaking code where import order matters due to side effects or dependencies between imports.
Within each block, μsort groups imports by source (standard library, third-party, first-party, relative) and sorts lexicographically. It respects skip directives like `#usort:skip` and `#isort:skip` to exclude specific imports from reordering. The tool integrates with pre-commit workflows via a standard hook.
Use it for
- Enforce consistent import ordering in CI pipelines using `usort check` without modifying code
- Automatically sort imports in files or directories in-place with `usort format` before committing
- Generate diffs of import changes with `usort diff` to review before applying
- Integrate import sorting into pre-commit hooks to maintain order on every commit
- Sort imports safely in codebases where import order affects behavior due to side effects
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
μsort is actively maintained, has no known vulnerabilities, installs with low friction, and solves a real problem—safe import sorting that respects code structure. It is a good fit if you want conservative import reordering that avoids breaking changes. The MIT license poses no restrictions.
Install
usort on PyPI
Before you install
Low friction installation with seven runtime dependencies. Active maintenance with latest release on 2026-01-13 and repository last commit on 2026-03-01.
Requires Python 3.10 or newer to run
License in practice
MIT license permits free use, modification, and distribution with minimal restrictions—suitable for both open-source and commercial projects.
Quickstart
pip install usort
usort format path/to/file.py
# or for validation:
usort check path/to/file.py
Verify before relying
- How μsort handles complex import patterns (star imports, conditional imports, or dynamic imports)
- Performance characteristics when sorting large files or projects with many imports
- Compatibility with other formatters and linters beyond pre-commit integration
Package facts
| License | permissive license permissive |
| Python support | Supports the current Python release >=3.10 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 7 packagesattrsclicklibcstmoreorlessstdlibstomlitrailrunner |
| Maintenance | Actively maintained 213 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 2,519,103 / month, #3,026 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseTopic :: Software DevelopmentTopic :: UtilitiesTyping :: Typed |
Evidence: usort-1.1.3-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “safe import reordering”
- usortμsort sorts Python imports within detected blocks while preserving…
- reorder-python-importsAutomatically reorders Python imports into a standardized format…
- extrasProvides three utility functions—try_import, try_imports, and…
Give your agent the search over MCP, or paste the wish link into any chat.
More Software Development packages
Provides backported and experimental type hints for Python 3.9+, allowing use of newer typing features on older Python versions and enabling early experimentation with type system PEPs before they enter the standard library.
NumPy provides an N-dimensional array object and a comprehensive suite of mathematical, linear algebra, Fourier transform, and random number functions for scientific computing in Python.
FastAPI is a Python web framework for building REST APIs using type hints, with automatic request validation, serialization, and interactive API documentation.
Provides a way to document function parameters, class attributes, return types, and variables inline using Python's `Annotated` type hint syntax instead of traditional docstrings.
Typer builds command-line applications from Python functions using type hints, automatically generating help text, argument parsing, and shell completion.
Install it if you are building CLIs in Python.
Distlib provides low-level packaging utilities for building, distributing, and managing Python software—including metadata handling, version specifiers, wheel support, script installation, and dependency resolution.
See also ufmt · reorder-python-imports · classify-imports · isort · pytest-isort · natsort · aspy.refactor-imports · sort-lines · csvsort · stdlibs