pydantricks.field_factory

A factory for pydantic fields.

Module Contents

Classes

GenericFakerFieldFactory

A factory that will be called during model construction. The faker instance has to be configured before calling the field factory.

Functions

Data

F

FakerFieldFactory

A factory of FieldFactory.

FieldFactory

A ready to play field factory.

K

API

pydantricks.field_factory.F

‘TypeVar(…)’

pydantricks.field_factory.FakerFieldFactory

None

A factory of FieldFactory.

pydantricks.field_factory.FieldFactory

‘FakerFieldFactory(…)’

A ready to play field factory.

class pydantricks.field_factory.GenericFakerFieldFactory(faker: faker.Faker)

Bases: typing.Generic[pydantricks.field_factory.F, pydantricks.field_factory.K]

A factory that will be called during model construction. The faker instance has to be configured before calling the field factory.

Parameters:

faker – A configured faker instance

Initialization

choice(factory: type[pydantricks.field_factory.F] | types.UnionType | pydantricks.model_factory.ModelFactory[pydantricks.model_factory.T] | str) collections.abc.Callable[[], pydantricks.field_factory.F]

Factory for composed types such as union, enum, literal and Model factory.

dict_factory(key_factory: pydantricks.field_factory.K, value_factory: pydantricks.field_factory.F, min: int, max: int) collections.abc.Callable[..., dict[pydantricks.field_factory.K, pydantricks.field_factory.F]]

Factory for the dict type.

property field: faker.Faker

Factory for simple types.

list_factory(factory: type[pydantricks.field_factory.F], min: int, max: int | None = None) collections.abc.Callable[..., list[pydantricks.field_factory.F]]

Factory for the list type.

set_factory(factory: type[pydantricks.field_factory.F], min: int, max: int | None = None) collections.abc.Callable[..., set[pydantricks.field_factory.F]]

Factory for the set type.

tuple_factory(*factory: Any) collections.abc.Callable[..., tuple[pydantricks.field_factory.F, ...]]

Factory for the type type.

pydantricks.field_factory.K

‘TypeVar(…)’

pydantricks.field_factory.is_model_factory(typ: Any) TypeGuard[pydantricks.model_factory.ModelFactory[Any]]