msgspec_factory#

class polyfactory.factories.msgspec_factory.MsgspecFactory#

Bases: Generic[T], BaseFactory[T]

Base factory for msgspec Structs.

__is_base_factory__: bool = True#

Flag dictating whether the factory is a ‘base’ factory. Base factories are registered globally as handlers for types. For example, the ‘DataclassFactory’, ‘TypedDictFactory’ and ‘ModelFactory’ are all base factories.

classmethod get_provider_map() dict[Any, Callable[[], Any]]#

Map types to callables.

Notes:
  • This method is distinct to allow overriding.

Returns:

a dictionary mapping types to callables.

classmethod is_supported_type(value: Any) TypeGuard[type[T]]#

Determine whether the given value is supported by the factory.

Parameters:

value – An arbitrary value.

Returns:

A typeguard

classmethod get_model_fields() list[polyfactory.field_meta.FieldMeta]#

Retrieve a list of fields from the factory’s model.

Returns:

A list of field MetaData instances.