While refactoring a large Python project, I ran into an issue — the project had a lot of deeply nested relative imports (from ..module import x). The team decided to standardize everything to absolute imports, and here was the issue: manually updating them was very tedious, especially across many levels of relative imports.
So I wrote a small CLI tool that converts relative imports to absolute ones. The tool:
- Traverses the project directory
- Detects relative imports of type (from ..A import B)
- Converts them to absolute imports based on a given root package
It’s lightweight and dependency-free. Nothing fancy — just a utility that solved a real problem for me and I thought it might be useful for some people.
If anyone is going through a similar refactor, feel free to check it out on github:
github
and you can install it using pip also.
I know it's very minimal, but I would appreciate feedback or suggestions.
Top comments (0)