Data Structures#

class oblate.fields.Dict(key_tp=..., value_tp=..., /, **kwargs)#

A field that accepts a dictionary.

When initialized without an argument, the field accepts any arbitrary dictionary. The two positional arguments correspond to the type of key of dictionary and type of value respectively.

These arguments can take a type expression. For example, Dict(Union[str, int], bool) accepts a dictionary with key of type either a string or integer and a boolean as a value.

For more information type validation, see the Type Validation page.

New in version 1.1.

Parameters:
  • key_tp – The type of key of dictionary. This parameter supports passing type expressions.

  • value_tp – The type of value of dictionary. This parameter supports passing type expressions.

ERR_INVALID_DATATYPE#

Error raised when the given value is not a dictionary.

ERR_TYPE_VALIDATION_FAILED#

Error raised when the type validation fails. In this error’s context, ErrorContext.metadata has a key type_validation_fail_errors which is a list of error messages.

class oblate.fields.TypedDict(typed_dict, /, **kwargs)#

A field that validates from a typing.TypedDict.

This class provides type validation on the values of given TypedDict, For more information type validation, see the Type Validation page.

New in version 1.1.

Parameters:

typed_dict (typing.TypedDict) – The typed dictionary to validate from.

ERR_INVALID_DATATYPE#

Error raised when the given value is not a dictionary.

ERR_TYPE_VALIDATION_FAILED#

Error raised when the type validation fails. In this error’s context, ErrorContext.metadata has a key type_validation_fail_errors which is a list of error messages.

class oblate.fields.List(type=..., /, **kwargs)#

A field that accepts a list.

New in version 1.1.

Parameters:

type – The type of list elements. This parameter corresponds to T in typing.List[T] and supports type expressions.

ERR_INVALID_DATATYPE#

Error raised when the given value is not a dictionary.

ERR_TYPE_VALIDATION_FAILED#

Error raised when the type validation fails. In this error’s context, ErrorContext.metadata has a key type_validation_fail_errors which is a list of error messages.

class oblate.fields.Set(type=..., /, **kwargs)#

A field that accepts a set.

New in version 1.1.

Parameters:

type – The type of set elements. This parameter corresponds to T in typing.Set[T] and supports type expressions.

ERR_INVALID_DATATYPE#

Error raised when the given value is not a dictionary.

ERR_TYPE_VALIDATION_FAILED#

Error raised when the type validation fails. In this error’s context, ErrorContext.metadata has a key type_validation_fail_errors which is a list of error messages.