constrained_collections¶
- polyfactory.value_generators.constrained_collections.handle_constrained_collection(collection_type: Callable[..., T], factory: type[BaseFactory[Any]], field_meta: FieldMeta, item_type: Any, max_items: int | None = None, min_items: int | None = None, unique_items: bool = False, field_build_parameters: Any | None = None, build_context: BuildContext | None = None) T [source]¶
Generate a constrained list or set.
- Parameters:
collection_type¶ – A type that can accept type arguments.
factory¶ – A factory.
field_meta¶ – A field meta instance.
item_type¶ – Type of the collection items.
max_items¶ – Maximal number of items.
min_items¶ – Minimal number of items.
unique_items¶ – Whether the items should be unique.
field_build_parameters¶ – Any build parameters passed to the factory as kwarg values.
build_context¶ – BuildContext data for current build.
- Returns:
A collection value.
- polyfactory.value_generators.constrained_collections.handle_constrained_mapping(factory: type[BaseFactory[Any]], field_meta: FieldMeta, max_items: int | None = None, min_items: int | None = None, field_build_parameters: Any | None = None, build_context: BuildContext | None = None) Mapping[Any, Any] [source]¶
Generate a constrained mapping.
- Parameters:
- Returns:
A mapping instance.