Monkay is a production-focused module lifecycle toolkit for Python packages. It helps you ship lazy imports, settings loading, extension orchestration, and context-isolated state without fragile import-time side effects.
Monkay is designed for libraries and applications that need to:
- expose stable public imports while deferring expensive imports,
- run controlled startup preloads and settings evaluation,
- apply pluggable extensions with deterministic conflict behavior,
- isolate mutable state per thread/task for safe tests and request scopes,
- validate module export consistency during development.
pip install monkayRuntime requirement: Python 3.10+.
# yourpkg/__init__.py from monkay import Monkay monkay = Monkay( globals(), lazy_imports={ "json_dumps": "json:dumps", }, ) __all__ = ["json_dumps", "monkay"]# yourpkg/main.py from yourpkg import json_dumps payload = {"status": "ok"} print(json_dumps(payload))json_dumps is resolved lazily on first access and cached by default.
Monkay: lifecycle coordinator for imports, settings, instances, and extensionsload,load_any,absolutify_import: import/path helpersCage,TransparentCage: context-isolated mutable proxiesLifespan,LifespanHook: ASGI lifespan utilitiesfind_missing,sorted_exports: export inspection and debugging helpers
Monkay keeps top-level public imports stable via monkay.__all__:
MonkayDeprecatedImportPRE_ADD_LAZY_IMPORT_HOOKExtensionProtocolload,load_any,absolutify_importInGlobalsDict,UnsetError,get_value_from_settingsCage,TransparentCage
Full docs: monkay.dymmond.com
Recommended order:
Monkay uses hatch, ruff, ty, pytest, and mkdocs/zensical.
pip install hatch hatch run lint hatch run check_types hatch test hatch run docs:buildIf you use Task, Monkay ships both Taskfile.yml and Taskfile.yaml:
task check task coverage task docs task docs:serveSee Contributing for setup, quality gates, docs workflow, and pull request expectations.