Skip to content

🐡 makes your relative python imports work without hassle.

License

Notifications You must be signed in to change notification settings

hirsimaki-markus/importmonkey

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

51 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation


🐡
importmonkey


Β  Β  Β  Β 

An utility for adding new import paths to make your relative import work without hassle.

pip install importmonkey

What does it do?

Here is your repository:

β”œβ”€ src
β”‚   └─ project
β”‚       β”œβ”€ __init__.py
β”‚       └─ module.py
└─ test
    └─ test.py

test.py can't find module.py:

ModuleNotFoundError: No module named 'module'
ImportError: attempted relative import with no known parent package
SystemError: Parent module '' not loaded, cannot perform relative import

importmonkey will fix that:

import importmonkey  # In test.py
importmonkey.add_path("../src")
import project

Documentation / Licensing / Dev stuff

Expand

Documentation

help(importmonkey.add_path) # Or look at the source.

Licensing

To protest the copyright landscape, I chose The Unlicense. If you need a different license, just ask.

Dev stuff

  • Install for dev stuff: importmonkey$ pip install -e ".[dev]" # In a venv
  • Linting: importmonkey$ python -m ruff check .
  • Testing: importmonkey$ python test/run_test_suite.py
  • Releasing:
# Remember: increment __version__ in __init__.py
# Remember: .pypirc file is needed.
# Remember: run tests
# Remember: run ruff
importmonkey$ python -m build --wheel
importmonkey$ rm -rf build/ && rm -rf src/importmonkey.egg-info/
importmonkey$ python -m twine check dist/*
importmonkey$ python -m twine upload dist/*
importmonkey$ rm -rf dist/