{"id":5834,"library":"absolufy-imports","title":"absolufy-imports","description":"A Python tool and pre-commit hook designed to automatically convert relative imports to absolute imports within a codebase. While functional, its author has indicated it is superseded by the more comprehensive `reorder-python-imports` library. Its current version is `0.3.1`, last released in January 2022.","status":"deprecated","version":"0.3.1","language":"python","source_language":"en","source_url":"https://github.com/MarcoGorelli/absolufy-imports","tags":["imports","code quality","refactoring","pre-commit","linter"],"install":[{"cmd":"pip install absolufy-imports","lang":"bash","label":"Install with pip"}],"dependencies":[],"imports":[],"quickstart":{"code":"# Example file: mypackage/myfile.py\n# from . import __version__\n# from .submodule import some_function\n\n# To convert relative imports in a file:\n# Create a dummy file for demonstration\nwith open('mypackage/myfile.py', 'w') as f:\n    f.write('from . import __version__\\n')\n    f.write('from .submodule import some_function\\n')\n\nimport os\nimport subprocess\n\n# Run absolufy-imports on the file\nprint('Before conversion:')\nwith open('mypackage/myfile.py', 'r') as f:\n    print(f.read())\n\n# Assuming 'mypackage' is at the root for absolute imports\n# The tool modifies the file in place\nsubprocess.run(['absolufy-imports', 'mypackage/myfile.py'], check=True)\n\nprint('\\nAfter conversion:')\nwith open('mypackage/myfile.py', 'r') as f:\n    print(f.read())\n\n# Clean up dummy file and directory\nos.remove('mypackage/myfile.py')\nos.rmdir('mypackage')","lang":"python","description":"To use `absolufy-imports` via the command line, simply point it to the file(s) you wish to modify. It will perform the conversion in place."},"warnings":[{"fix":"Consider migrating to `reorder-python-imports` for broader import management capabilities.","message":"The author of `absolufy-imports` states that it is superseded by `reorder-python-imports` (also by the same author) and recommends using the latter instead. `absolufy-imports` is functional but is not actively maintained for new features.","severity":"deprecated","affected_versions":"0.3.1 and earlier"},{"fix":"For a project with a `src` directory, use `absolufy-imports --application-directories .:src` or configure your pre-commit hook accordingly.","message":"When using `absolufy-imports` (especially with a pre-commit hook), ensure you configure `--application-directories` correctly if your project uses non-standard layouts (e.g., a `src` directory). This helps the tool correctly identify the root of your package for absolute import resolution.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Commit your changes before running `absolufy-imports` or verify changes using a diff tool afterward. Using it as a pre-commit hook helps manage this within your workflow.","message":"This tool modifies files in-place. Always ensure you have appropriate version control or backups before running it across your codebase to prevent unintended changes.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z","problems":[{"fix":"Install the package using pip: 'pip install absolufy-imports'.","cause":"This error occurs when the 'absolufy-imports' package is not installed in the Python environment.","error":"ModuleNotFoundError: No module named 'absolufy_imports'"},{"fix":"Ensure the package is installed and the installation path is included in the system's PATH.","cause":"This error occurs when the 'absolufy-imports' command-line tool is not available, possibly due to the package not being installed or the installation path not being in the system's PATH.","error":"absolufy-imports: command not found"},{"fix":"Ensure that the import statement is correct and there are no circular imports in the codebase.","cause":"This error occurs when attempting to import 'absolufy_imports' incorrectly, possibly due to a circular import or incorrect module structure.","error":"ImportError: cannot import name 'absolufy_imports' from 'absolufy_imports'"},{"fix":"Specify your application directories using the `--application-directories` flag (e.g., `absolufy-imports . --application-directories .:src`), ensuring it includes all relevant package roots. Also, verify that the files are part of a valid Python package (i.e., contain `__init__.py`).","cause":"The tool might not be correctly configured to identify your application's source directories, or the files it's processing don't match the expected package structure.","error":"absolufy-imports not converting imports"},{"fix":"First, fix any underlying Python syntax errors in your staged files. Then, check your `.pre-commit-config.yaml` to ensure the `rev` for `absolufy-imports` is correct (e.g., `v0.3.1`) and that the `id` is properly set. Run `pre-commit autoupdate` to get the latest working revision.","cause":"This generic pre-commit error indicates that the `absolufy-imports` hook exited with a non-zero status. This can be due to syntax errors in the Python files, an unsupported file structure, or an incorrect `rev` in your `.pre-commit-config.yaml`.","error":"pre-commit hook absolufy-imports failed"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"absolufy-imports","cli_version":"usage: absolufy-imports [-h]","type":"library","homepage":null,"github":"https://github.com/MarcoGorelli/absolufy-imports","docs":null,"changelog":null,"pypi":"https://pypi.org/project/absolufy-imports/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops","testing"],"base_url":null,"auth_type":null,"_links":{"self":"https://checklist.day/api/registry/absolufy-imports","v1":"https://checklist.day/v1/registry/absolufy-imports","v1_install":"https://checklist.day/v1/registry/absolufy-imports/install","v1_imports":"https://checklist.day/v1/registry/absolufy-imports/imports","v1_compatibility":"https://checklist.day/v1/registry/absolufy-imports/compatibility","v1_quickstart":"https://checklist.day/v1/registry/absolufy-imports/quickstart","docs":"https://checklist.day/docs"}}