classify-imports
Utilities for refactoring imports in python-like syntax.
What it is and what it does
classify-imports is a Python utility library for parsing and organizing import statements according to standard conventions. It classifies imports into four standard categories—future, builtin, third-party, and application—and provides functions to split compound imports, sort import groups, and determine the classification of any module name. The library works with import objects parsed from Python-like syntax, making it useful for code refactoring tools, linters, and import management scripts.
The package has no external runtime dependencies and is distributed as a pure Python wheel, making installation straightforward. It targets modern Python versions and supports both CPython and PyPy. With active maintenance and recent releases, it is suitable for integration into build pipelines or as a foundation for import-related tooling.
Use it for:
- Automatically organize and group imports in Python files according to standard conventions during code refactoring.
- Build custom import linting or validation tools that need to classify and partition imports by type.
- Parse and manipulate import statements programmatically in code generation or AST transformation scripts.
- Integrate import sorting logic into editor plugins or pre-commit hooks for consistent import organization.
- Analyze Python codebases to identify and report on import patterns and dependencies.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Parses, classifies, and sorts Python import statements into standard groups (future, builtin, third-party, application) and provides utilities to split and refactor imports programmatically.
Yes. The package is lightweight, actively maintained, has no dependencies, and solves a specific problem well. Install it if you need to programmatically classify or sort Python imports; skip it if you only need a command-line import formatter. The MIT license and recent activity make it a low-risk choice.
Install
classify-imports on PyPI
pip
pip install classify-importsuv
uv add classify-importspoetry
poetry add classify-importsInstalling classify-imports
Before you install
Low friction: pure Python wheel with no runtime dependencies. Active maintenance with a recent release and current Python version support.
License in practice
MIT license permits commercial and private use with minimal restrictions; you may use, modify, and distribute this package freely provided you retain the license notice.
Quickstart
pip install classify-imports
from classify_imports import import_obj_from_str, sort, classify_base
obj = import_obj_from_str('import sys')
print(classify_base('sys')) # 'BUILTIN'
partitioned = sort([import_obj_from_str('import sys'), import_obj_from_str('import requests')])
Requires Python 3.10 or later.
Verify before relying
- Whether the package integrates with common import-sorting tools or is primarily for programmatic use.
- Performance characteristics when processing large import blocks or files with many imports.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 35 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 382,392/month — #7,087 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: classify_imports-4.5.0-py2.py3-none-any.whl
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
aspy.refactor-importsParses, classifies, and manipulates Python…
permissive · top 15,000 on PyPI
isortisort sorts Python imports alphabetically and…
permissive · top 1,000 on PyPI
reorder-python-importsAutomatically reorders Python imports into a…
permissive · top 15,000 on PyPI
usortμsort sorts Python imports within detected…
permissive · top 5,000 on PyPI
stdlib-listProvides lists of Python standard library…
permissive · top 5,000 on PyPI
sqlparsesqlparse tokenizes SQL text into a tree of…
permissive · top 1,000 on PyPI
flake8-import-orderA flake8 plugin that enforces import ordering…
copyleft · top 5,000 on PyPI
import-depsAnalyzes Python module imports statically using…
permissive · top 5,000 on PyPI
stdlibsProvides a static listing of all known modules…
permissive · top 5,000 on PyPI
pytest-isortA pytest plugin that automatically checks…
permissive · top 15,000 on PyPI