mo-imports
More Imports! - Delayed importing
What it is and what it does
mo-imports solves the problem of circular module dependencies by providing two main patterns: expect/export for explicit cycle breaking, and delay_import for lazy loading. When modules import each other at the top level, Python can fail or produce incomplete initialization. This package lets you declare expected names upfront (expect) and fulfill them later (export), or defer imports until first use (delay_import), keeping all imports visible at the top of files rather than scattered inline or at the bottom.
The package depends only on mo-future and installs as a pure Python wheel with no compiled dependencies. It targets Python 3.9 through 3.13 and has been maintained since 2020, though releases have slowed. The expect/export pattern is the recommended approach for most cycles; delay_import is simpler but requires the imported name to be called or accessed to trigger loading, so it cannot be used for sentinel values or default arguments.
Use it for:
- Break circular imports in modular libraries where two or more modules need to reference each other's functions or classes.
- Defer expensive imports (e.g., heavy data science or ML libraries) until they are actually used in a function.
- Maintain clean import organization at the top of files while resolving cycles that would otherwise require inline or end-of-file imports.
- Verify at module load time that all expected names are exported, catching configuration errors early rather than at runtime.
- Refactor monolithic code into separate modules without restructuring to avoid cycles or keeping code in a single file.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides patterns to resolve circular module dependencies in Python through delayed imports and expect/export mechanisms, keeping imports at the top of files while breaking cycles.
Yes, if you have circular dependencies in a modular codebase. The expect/export pattern is cleaner and more maintainable than inline imports or end-of-file imports, and the package is stable with low friction. The aging maintenance status (last release 425 days ago) is a minor concern for a mature utility, but check whether the pattern fits your use case—delay_import has limitations for non-callable values.
Install
mo-imports on PyPI
pip
pip install mo-importsuv
uv add mo-importspoetry
poetry add mo-importsInstalling mo-imports
Before you install
Low install friction with a single lightweight dependency (mo-future). Maintenance is aging—last release was 425 days ago, though the repository remains active and the package has been stable since its 2020 initial release.
License in practice
Licensed under MPL 2.0 (copyleft). You must disclose source code modifications and distribute under the same license if you modify and redistribute the package, but can use it in proprietary applications without disclosing your own code.
Quickstart
# Install
pip install mo-imports
# Use expect/export pattern to break cycles
# foos.py
from mo_imports import expect
bar = expect("bar")
# bars.py
from mo_imports import export
export("bars", bar)
Verify before relying
- Whether delay_import() works correctly with type checkers and IDE autocompletion
- Performance overhead of expect/export pattern at scale with many circular dependencies
- Compatibility with dynamic import systems or import hooks beyond standard Python imports
Package facts
| License | MPL 2.0 (copyleft) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — mo-future |
| Maintenance | aging — 425 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 335,768/month — #7,472 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: mo_imports-7.685.25166-py3-none-any.whl
Tags
More Libraries packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
python-dateutilProvides parsing, arithmetic, and recurrence…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
py-import-cyclesDetects import cycles in Python projects by…
permissive · top 15,000 on PyPI
cyclicDetects and reports cyclic relationships in a…
permissive · top 15,000 on PyPI
mo-futureProvides a flat-namespace compatibility layer…
copyleft · top 15,000 on PyPI
import-depsAnalyzes Python module imports statically using…
permissive · top 5,000 on PyPI
importlabImportlab infers Python import dependencies and…
permissive · top 5,000 on PyPI
emportEmport provides a single function to import…
permissive · top 15,000 on PyPI
pydepsVisualizes Python module dependencies as graphs…
permissive · top 15,000 on PyPI
lazy-importDefers module loading and ImportErrors until a…
copyleft · top 15,000 on PyPI
delayed-assertCollects multiple assertion failures in a test…
unclear · top 15,000 on PyPI
lazy-importsDefers loading of module attributes and their…
permissive · top 5,000 on PyPI