The ultimate preload, settings, lazy import manager.
Project description
Monkay
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.
Why Monkay
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.
Installation
pip install monkay
Runtime requirement: Python 3.10+.
60-Second Example
# 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.
Core Capabilities
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
Public API Stability
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
Documentation
Full docs: monkay.dymmond.com
Recommended order:
Development Quickstart
Monkay uses hatch, ruff, ty, pytest, and mkdocs/zensical.
pip install hatch
hatch run lint
hatch run check_types
hatch test
hatch run docs:build
If you use Task, Monkay ships both Taskfile.yml and Taskfile.yaml:
task check
task coverage
task docs
task docs:serve
Contributing
See Contributing for setup, quality gates, docs workflow, and pull request expectations.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file monkay-0.5.2.tar.gz.
File metadata
- Download URL: monkay-0.5.2.tar.gz
- Upload date:
- Size: 69.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: Hatch/1.16.5 cpython/3.10.19 HTTPX/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3c0064ee253b27329216314d1a6ab077e6e39ac2e7a3867feebaa026fce43829
|
|
| MD5 |
f1d1fcb2b8a28a5ba75de45bb91cf917
|
|
| BLAKE2b-256 |
b2076e358ce3cbfd925809131affa7090d4381f757fc3b171964c231e456c049
|
File details
Details for the file monkay-0.5.2-py3-none-any.whl.
File metadata
- Download URL: monkay-0.5.2-py3-none-any.whl
- Upload date:
- Size: 32.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: Hatch/1.16.5 cpython/3.10.19 HTTPX/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a6cb126a469b5397fce15dcc755edb9d6ade8287461f0782f57501e4266c21df
|
|
| MD5 |
9aa520a95076a3d4651af3cb09d65537
|
|
| BLAKE2b-256 |
1b6beb8d474a2e15362a135f7b876239a888a20a77c568903323e362ea7c01c3
|