Smoke-Import
The cheapest correctness signal in a Python monorepo is "does it import". Run it before tests, before builds, before wiring into an app. It catches broken __init__.py, circular imports, missing sibling packages, and typo'd module names in under a second.
The one-liner (uv monorepo)
uv run --no-sync python -c "import sys; sys.path.insert(0, 'packages/<pkg>'); import <pkg>; print('imports ok')"
Why each flag earns its place:
--no-sync— skip dependency resolution. You're testing import wiring, not the lockfile. Saves seconds-to-minutes per check.sys.path.insert(0, ...)— import the package straight from the tree without installing it. Lets you check a package that isn't yet a declared dependency of anything.print('imports ok')— a positive sentinel. Silence is ambiguous; an explicit string is unambiguous success.
Multiple sibling packages at once
uv run --no-sync python -c "import sys
for p in ['packages/observability', 'packages/data-ingest']:
sys.path.insert(0, p)
import observability, data-ingest
print('imports ok')"
Use this when a router or app depends on several new packages together — the cross-package wiring is what you're actually checking.
For non-uv projects
python -c "import sys; sys.path.insert(0, 'packages/<pkg>'); import <pkg>; print('imports ok')"
When to run
- After creating a new package (
packages/<pkg>/__init__.py). - After editing a package's top-level
__init__.pyor moving modules between packages. - Before wiring a package into an app router or service.
- After a rename / move, before anything heavier.
When NOT to run
- Pure data / config edits with no Python surface.
- You're about to run the test suite anyway — the import will be checked there.
- The package has heavy import-time side effects (DB connections, network) — smoke-import lies for those; prefer a targeted
pytest --collect-only.
Limitations
Smoke-import only checks the import graph. It does NOT execute the package's logic, does NOT validate types, and does NOT catch runtime errors inside functions. Follow with a real test for anything beyond wiring.