Skip to content

Core API

typed_pyd_dataclass module-attribute

typed_pyd_dataclass = typed_pydantic_dataclass

inject_depends module-attribute

inject_depends = DependencyInjector()

Undefined module-attribute

Undefined: Final[UndefinedType] = UndefinedType()

__all__ module-attribute

__all__ = [
    "BaseAction",
    "BaseActionGroup",
    "BaseFastSproutError",
    "BaseSchema",
    "BaseTriggerAction",
    "DependencyInjector",
    "Depends",
    "EntityVisibility",
    "FastSproutError",
    "Field",
    "IDType",
    "IdentificatorType",
    "InternalField",
    "PublicIDType",
    "ReadDTO",
    "ReadField",
    "ReadWriteDTO",
    "Undefined",
    "UndefinedType",
    "WriteDTO",
    "WriteField",
    "dto",
    "hidden_lazy_await",
    "inject_depends",
    "lazy_await",
    "typed_dataclass",
    "typed_fields",
    "typed_pyd_dataclass",
]

IdentificatorType

IdentificatorType = IdentificatableType

IDType

IDType = IdentificatableType

PublicIDType

PublicIDType = IdentificatableType

BaseAction

Bases: Protocol

Atomic unit of work in fastsprout.

Actions take a single typed payload and return a typed result. Exposed through channels (REST, CLI, task, event) via decorators from interface layers.

__call__ async

__call__(payload: I) -> O

BaseActionGroup

Bases: Protocol

Group of actions — class with multiple decorated methods.

__action_group__ class-attribute

__action_group__: bool

BaseTriggerAction

Bases: Protocol

Action triggered without payload (cron jobs, no-input commands).

__call__ async

__call__() -> O

DependencyInjector

Resolve Depends providers with per-call caching and callable overrides.

dependency_providers instance-attribute

dependency_providers: dict[Callable[..., Any], Callable[..., Any]] = {}

dependency_overrides instance-attribute

dependency_overrides: dict[Callable[..., Any], Callable[..., Any]] = {}

__init__

__init__() -> None

resolve

resolve(marker: Any, annotation: Any) -> Any

aresolve async

aresolve(marker: Any, annotation: Any) -> Any

__call__

__call__[**P, R](function: Callable[P, R]) -> Callable[P, R]

ReadDTO

Bases: _DTO

Use first in the bases of a read DTO, followed by the source entity.

__fastsprout_operations__ class-attribute

__fastsprout_operations__: frozenset[str] = frozenset({'read'})

ReadWriteDTO

Bases: _DTO

Union of read and write fields; internal fields are still forbidden.

__fastsprout_operations__ class-attribute

__fastsprout_operations__: frozenset[str] = frozenset({'read', 'write'})

WriteDTO

Bases: _DTO

Use first in the bases of a write DTO, followed by the source entity.

__fastsprout_operations__ class-attribute

__fastsprout_operations__: frozenset[str] = frozenset({'write'})

BaseFastSproutError

Bases: Exception

Base for all fastsprout exceptions.

FastSproutError

Bases: BaseFastSproutError

Fastsprout exceptions.

EntityVisibility

Unrestricted source; DTO bases supply a concrete visibility mode.

Only this private marker is Any. Field value types remain fully typed. The open marker allows a DTO to narrow visibility without an incompatible override of a literal-valued member on its source entity.

Field

Bases: Generic[T, FieldOwner]

Typed field descriptor.

Annotation form: is_active: Field[bool]

Behavior
  • On class: Hero.is_active → FieldRef[Hero, bool, OrmCtor] (carries entity binding for repository.select; the SQLAlchemy overload types .orm as Mapped[T])
  • On instance: hero.is_active → bool (the value)

Defaults are declared through the specifier, not raw assignment — this keeps both the type checker and the runtime model build happy:

class Hero(BaseSchema):
    age: Field[int] = Field(default=0)
    uid: Field[UUID] = Field(default_factory=uuid4)

Use .set(value) for partial-update assignment objects: Hero.is_active.set(True) # FieldAssignment[bool]

__slots__ class-attribute instance-attribute

__slots__ = ('_orm', 'default', 'default_factory', 'name')

__fastsprout_ops__ class-attribute

__fastsprout_ops__: frozenset[str] = frozenset({'read', 'write'})

name instance-attribute

name = ''

default instance-attribute

default = default

default_factory instance-attribute

default_factory = default_factory

__init__

__init__(
    *,
    default: T | UndefinedType = Undefined,
    default_factory: Callable[[], T] | None = None,
) -> None

__set_name__

__set_name__(owner: type, name: str) -> None

set

set(value: T) -> FieldAssignment[T]

__get__

__get__(
    instance: None, owner: type[HasOrm[Mapped[Any]]]
) -> FieldRef[Any, T, Mapped[T]]
__get__[OrmCtor](
    instance: None, owner: type[HasOrm[OrmCtor]]
) -> FieldRef[Any, T, OrmCtor]
__get__[E](instance: None, owner: type[E]) -> FieldRef[E, T, None]
__get__(
    instance: None, owner: type[FieldOwner]
) -> FieldRef[FieldOwner, T, Any]
__get__(instance: FieldOwner, owner: type[FieldOwner]) -> T
__get__(instance: object | None, owner: type) -> FieldRef[Any, T, Any] | T

__set__

__set__(instance: FieldOwner, value: T) -> None

__repr__

__repr__() -> str

InternalField

Bases: Field[T, _Internal]

Accessible on the entity, excluded from every public DTO.

__fastsprout_ops__ class-attribute

__fastsprout_ops__: frozenset[str] = frozenset({'internal'})

ReadField

Bases: Field[T, _Readable]

Included in read DTOs, excluded from write-only DTOs.

__fastsprout_ops__ class-attribute

__fastsprout_ops__: frozenset[str] = frozenset({'read'})

WriteField

Bases: Field[T, _Writable]

Included in write DTOs, excluded from read-only DTOs.

__fastsprout_ops__ class-attribute

__fastsprout_ops__: frozenset[str] = frozenset({'write'})

BaseSchema

Bases: EntityVisibility, BaseModel

Base schema with type-safe field descriptors.

Subclasses declare fields with Field[T] annotations:

class Hero(BaseSchema):
    id: Field[UUID]
    is_active: Field[bool]
    name: Field[str]
Then

hero = Hero(id=uuid(), is_active=True, name="SuperMan") hero.is_active # bool Hero.is_active # Field[bool] Hero.is_active.set(True) # FieldAssignment[bool]

model_config class-attribute instance-attribute

model_config = ConfigDict(
    alias_generator=AliasGenerator(
        alias=to_snake, validation_alias=to_camel, serialization_alias=to_camel
    ),
    populate_by_name=True,
)

UndefinedType

Sentinel type for 'no value provided'.

fastsprout's own PydanticUndefined: a single shared singleton, falsy, safe to copy/pickle, usable anywhere a missing value must be distinguished from None (which is a real value).

__slots__ class-attribute instance-attribute

__slots__ = ()

__bool__

__bool__() -> bool

__copy__

__copy__() -> UndefinedType

__deepcopy__

__deepcopy__(memo: dict[int, Any]) -> UndefinedType

__reduce__

__reduce__() -> str

__repr__

__repr__() -> str

hidden_lazy_await

hidden_lazy_await[**P, R](method: Callable[P, Awaitable[R]]) -> Callable[P, R]

typed_dataclass

typed_dataclass[C](cls: type[C]) -> type[C]

Apply stdlib @dataclass + install Field[T] descriptors.

Auto-generated init, repr, eq. No runtime validation.

Example

@typed_dataclass class User: field_int: Field[int] field_str: Field[str]

Depends

Depends(
    dependency: Callable[..., Any] | None = None, *, use_cache: bool = True
) -> Any