# field_meta

class polyfactory.field_meta.Null

  Bases: `object`

  Sentinel class for empty values

class polyfactory.field_meta.UrlConstraints

  Bases: `TypedDict`

class polyfactory.field_meta.Constraints

  Bases: `TypedDict`

  Metadata regarding a type constraints, if any

class polyfactory.field_meta.FieldMeta

  Bases: `object`

  Factory field metadata container. This class is used to store the data about a field of a factory’s model.

  __init__(*, name: str, annotation: type, random: Random | None = None, default: Any = <class 'polyfactory.field_meta.Null'>, children: list[FieldMeta] | None = None, constraints: Constraints | None = None) → None

    Create a factory field metadata instance.

  property type_args: tuple[Any, ...]

    Return the normalized type args of the annotation, if any.

    Returns:

      a tuple of types.

  classmethod from_type(annotation: Any, random: Random = <random.Random object>, name: str = '', default: Any = <class 'polyfactory.field_meta.Null'>, constraints: Constraints | None = None, randomize_collection_length: bool | None = None, min_collection_length: int | None = None, max_collection_length: int | None = None, children: list[FieldMeta] | None = None) → Self

    Builder method to create a FieldMeta from a type annotation.

    Parameters:

      - annotation – A type annotation.

      - random – An instance of random.Random.

      - name – Field name

      - default – Default value, if any.

      - constraints – A dictionary of constraints, if any.

      - randomize_collection_length – A boolean flag whether to randomize collections lengths

      - min_collection_length – Minimum number of elements in randomized collection

      - max_collection_length – Maximum number of elements in randomized collection

    Returns:

      A field meta instance.

  classmethod get_constraints_metadata(annotation: Any) → Sequence[Any]

    Get the metadatas of the constraints from the given annotation.

    Parameters:

      - annotation – A type annotation.

      - random – An instance of random.Random.

    Returns:

      A list of the metadata in the annotation.