Core API
__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",
]
BaseAction
BaseActionGroup
BaseTriggerAction
DependencyInjector
Resolve Depends providers with per-call caching and callable overrides.
dependency_providers
instance-attribute
dependency_overrides
instance-attribute
ReadDTO
ReadWriteDTO
WriteDTO
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.ormasMapped[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]
InternalField
Bases: Field[T, _Internal]
Accessible on the entity, excluded from every public DTO.
ReadField
Bases: Field[T, _Readable]
Included in read DTOs, excluded from write-only DTOs.
WriteField
Bases: Field[T, _Writable]
Included in write DTOs, excluded from read-only DTOs.
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]
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).
typed_dataclass
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]