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) T #
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.
- 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) Mapping[Any, Any] #
Generate a constrained mapping.
- Parameters:
factory – A factory.
field_meta – A field meta instance.
max_items – Maximal number of items.
min_items – Minimal number of items.
- Returns:
A mapping instance.