absolufy-imports
A tool to automatically replace relative imports with absolute ones.
What it is and what it does
absolufy-imports is a command-line tool and pre-commit hook that automatically rewrites relative imports as absolute imports. It operates on individual Python files and integrates into pre-commit workflows to enforce absolute import style across a codebase.
The tool supports configuration for non-standard layouts via the `--application-directories` flag, which lets you specify where your package root lives. It also offers a `--never` flag to reverse the operation and convert absolute imports back to relative. With no runtime dependencies, it installs quickly and runs as a standalone utility or integrated into your version control hooks.
Use it for:
- Enforce absolute imports across a codebase as a pre-commit hook to maintain consistent import style.
- Refactor code that uses relative imports to absolute imports for better IDE support.
- Handle src-layout projects by specifying `--application-directories` to point to the correct root.
- Batch-convert relative imports in legacy Python code during a modernization effort.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Automatically converts relative imports to absolute imports in Python source files, with optional support for src-layout projects and pre-commit integration.
Yes, if you need to standardize imports and are willing to accept that the project is no longer maintained. The tool is simple, has no dependencies, and works for its narrow purpose on Python 3.6–3.10. Use it as part of a pre-commit workflow or one-time refactoring task, but do not expect updates for future Python versions.
Install
absolufy-imports on PyPI
pip
pip install absolufy-importsuv
uv add absolufy-importspoetry
poetry add absolufy-importsInstalling absolufy-imports
Before you install
Low install friction with no runtime dependencies. The project is archived and has not been updated since 2022-01-20, though it remains functional for Python 3.6 through 3.10.
License in practice
MIT license is permissive; you can use, modify, and distribute this package freely with minimal restrictions.
Quickstart
pip install absolufy-imports
absolufy-imports myfile.py
# Or in .pre-commit-config.yaml:
# - repo: https://github.com/MarcoGorelli/absolufy-imports
# rev: v0.3.0
# hooks:
# - id: absolufy-imports
Verify before relying
- Whether the tool correctly handles all edge cases in modern Python import syntax.
- Compatibility with Python versions beyond 3.10 (classifiers list 3.10 as highest).
- Whether the tool works reliably on modern Python versions given the project has been archived since 2022-01-20.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.6.1) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | abandoned — 1,667 days since the last release |
| Last repo commit | (repository archived) |
| First released | |
| Downloads | 317,027/month — #7,666 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: absolufy_imports-0.3.1-py2.py3-none-any.whl
Tags
More Build Tools packages
Provides reusable utilities for Python…
permissive · top 100 on PyPI
tqdmWraps any iterable to display a real-time…
copyleft · top 100 on PyPI
pippip is the standard installer for Python…
permissive · top 100 on PyPI
hatchlingHatchling is a standards-compliant Python build…
permissive · top 100 on PyPI
grpcio-toolsGenerates Python gRPC service stubs and message…
permissive · top 1,000 on PyPI
pre-commitpre-commit is a framework for installing and…
permissive · top 1,000 on PyPI
pyupgradeAutomatically rewrites Python source code to…
permissive · top 5,000 on PyPI
reorder-python-importsAutomatically reorders Python imports into a…
permissive · top 15,000 on PyPI
emportEmport provides a single function to import…
permissive · top 15,000 on PyPI
protoletariatProtoletariat rewrites Python imports generated…
permissive · top 5,000 on PyPI
flake8-tidy-importsA flake8 plugin that detects and reports…
permissive · top 15,000 on PyPI
add-trailing-commaAutomatically adds trailing commas to…
permissive · top 15,000 on PyPI
ipynbImports Jupyter Notebook (.ipynb) files as…
permissive · top 15,000 on PyPI
usortμsort sorts Python imports within detected…
permissive · top 5,000 on PyPI
lazy-importsDefers loading of module attributes and their…
permissive · top 5,000 on PyPI
pre-commit-hooksProvides a collection of reusable pre-commit…
permissive · top 5,000 on PyPI