I am trying to structure my python 2.7 project (which entails several subdirectories) correctly. I have added __init__.py files on every level, and in the cas
You can use abs-imports
https://github.com/MarcoGorelli/abs-imports :
pip install abs-imports
See pre-commit for instructions
Sample .pre-commit-config.yaml
:
- repo: https://github.com/MarcoGorelli/abs-imports
rev: v0.1.2
hooks:
- id: abs-imports
$ cat mypackage/myfile.py
from . import __version__
$ abs_imports mypackage/myfile.py
$ cat mypackage/myfile.py
from mypackage import __version__
Disclaimer: I'm the author of this little package