neofoam.framework.dependency_resolver

Runtime dependency resolution for Depends() markers.

Handles dependency injection during solver/model execution.

class neofoam.framework.dependency_resolver.DependencyResolver[source]

Bases: object

Resolve Depends() markers and context-backed arguments.

resolve_arguments(func: Callable[[...], Any], ctx: Context | None = None, **provided_kwargs: Any) dict[str, Any][source]

Resolve function arguments from Depends markers and Context.

neofoam.framework.dependency_resolver.wrap_with_dependency_resolution(func: Callable[[...], Any], instance: Any, dependency_resolver: DependencyResolver) Callable[[Context], Any][source]

Wrap func so it can be called with just a Context.

Dependencies are resolved via dependency_resolver. If the function signature includes a self parameter it is bound to instance. If the return value is a FieldUpdates the context is updated automatically.

This is the canonical implementation shared by SolverSpec and ModelSpec — avoids duplicating the same wrapper in every factory.