# fundi-scopegen
Type-safe scope declaration generator for fundi dependency injection
fundi-codegen generates TypedDict classes that describe the expected scope structure for fundi-based functions.
This allows you to call inject(scope, scan(...), stack) with full type checking, autocomplete, and IDE support — no plugins or runtime introspection needed.
HOW IT WORKS
fundi-scopegen analyzes a function (and its dependency tree) via scan(...), extracts all from_(...) and outputs:
- a full list of all keys required in the
scope - expected types (supporting
FromType,Literal,Optional,Union,Annotated,Parameter, etc.) - import statements for required symbols
- a
TypedDictclass that serves as a contract for what thescopemust contain
How it works:
- Recursively walks the dependency tree using
scan(...) - Detects all
from_(...)-based dependencies - Builds a
TypedDictbased on flattened parameter annotations - Outputs a ready-to-use Python type declaration
USAGE EXAMPLES
Generate a scope for a function
fundi-scopegen play.application
Output:
from typing import Any, TypedDict, NotRequired
from fundi import FromType
from fundi.types import Parameter
class ApplicationScope(TypedDict):
parameter: NotRequired[FromType[None | Parameter]]
app_name: NotRequired[str | None]
some: NotRequired[str]
username: Any
With terminal color (for CLI readability)
fundi-scopegen play.application --colored
Without imports
fundi-scopegen play.application --no-imports
Output:
class ApplicationScope(TypedDict):
parameter: NotRequired[FromType[None | Parameter]]
app_name: NotRequired[str | None]
some: NotRequired[str]
username: Any
Using it in code
from contextlib import ExitStack
from fundi import inject, scan
from play import application
from scopes import ApplicationScope
scope: ApplicationScope = {
"username": "kuyugama",
"some": "waffel",
}
with ExitStack() as stack:
result = inject(scope, scan(application), stack)
Benefits
- Full IDE autocomplete
- Type-checking with
mypyorpyright - Lightweight: no runtime cost or decorators
- Easy to regenerate on dependency changes
🐾 Stop guessing your scope shape. Generate it once, and type it forever 😼
Metadata
Release files for fundi-scopegen 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| fundi_scopegen-0.0.1.tar.gz | 7.3 kB | Without provenance | Details for fundi_scopegen-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fundi_scopegen-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for fundi_scopegen-0.0.1-py3-none-any.whl |
Total release size: 13.5 kB
Release files / fundi_scopegen-0.0.1.tar.gz
| Download URL | fundi_scopegen-0.0.1.tar.gz |
|---|---|
| Size | 7.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b793cef16949c4f9b1184ae4c000f562104b05760c45cda6e5d681b0d3a3ee7d
|
|
BLAKE2b-256 checksum How to use checksums |
1ca14d92fdab8f61df163608f621a352a7b1f8382d1ecf149affb3acb26b04eb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.7.19
|
Release files / fundi_scopegen-0.0.1-py3-none-any.whl
| Download URL | fundi_scopegen-0.0.1-py3-none-any.whl |
|---|---|
| Size | 6.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
544975ba59f9ba851a0a132ff6669164e48dd46d65e78174677a92c77a88ca5b
|
|
BLAKE2b-256 checksum How to use checksums |
99e0383938068c7a08d8e2c63ff5d5de5520941dab47c1321c07618973758235
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.7.19
|
Security for fundi-scopegen 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.