skillfed

absolufy-imports

A tool to automatically replace relative imports with absolute ones.

absolufy-imports v0.3.1 317.0K downloads/30d#7,666 on PyPI161
Permissive license MIT Abandoned released

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-imports

uv

uv add absolufy-imports

poetry

poetry add absolufy-imports

Installing 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

License :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPy

Tags

convert relative imports to absolutepython import refactoring toolabsolute import converterpre-commit import hookrelative to absolute importspython code import formatterimport statement normalizer
import-refactoringpre-commit-hook

More Build Tools packages