Skip to content
Roboto
Esc
↑↓navigate↵open⌘Jpreview
On this page

roboto.sentinels

Module Contents

NotSet

roboto.sentinels.NotSet#View Source

NotSetType

class roboto.sentinels.NotSetType(**data)#View Source

Bases: pydantic.BaseModel

A sentinel value for fields (e.g. kwargs) that are not set, useful when ‘None’ is a meaningful value.

It extends pydantic.BaseModel so that it integrates nicely with pydantic’s schema generation/json serialization.

NotSetType.openapi_schema_modifier()

static openapi_schema_modifier(schema, model)#View Source

Replace NotSetType with null in anyOf lists.

To use in pydantic.BaseModel, add the following to your model: >>> class Config: … schema_extra = NotSetType.openapi_schema_modifier

See https://docs.pydantic.dev/1.10/usage/schema/#schema-customization

Parameters

schema dict[str, Any]
model Any

Return type

None

Null

class roboto.sentinels.Null#View Source

PydanticModel

roboto.sentinels.PydanticModel#View Source

T

roboto.sentinels.T#View Source

is_any_set()

roboto.sentinels.is_any_set(value)#View Source

Checks whether a Pydantic model has at least one field that is explicitly set.

Parameters

Return type

bool

is_not_set()

roboto.sentinels.is_not_set(value)#View Source

Parameters

value Any

Return type

TypeGuard[NotSetType]

is_set()

roboto.sentinels.is_set(value)#View Source

Parameters

value Union[T, NotSetType]

Return type

TypeGuard[T]

maybe_null()

roboto.sentinels.maybe_null(value)#View Source

Returns the null sentinel if value is the string “null” (case-insensitive), otherwise returns value unchanged.

Parameters

value T

Return type

Union[T, Null]

null

roboto.sentinels.null#View Source

remove_not_set()

roboto.sentinels.remove_not_set(value)#View Source

This function round-trips a pydantic model through initialization while ensuring that NotSetType values are not explicitly set. This allows value.model_dump(exclude_unset=True) to be used to generate a correct payload.

Parameters

Return type

value_or_default_if_unset()

roboto.sentinels.value_or_default_if_unset(value, default)#View Source

Parameters

value Union[T, NotSetType]
default T

Return type

value_or_not_set()

roboto.sentinels.value_or_not_set(value)#View Source

Parameters

value Optional[T]

Return type

Union[T, NotSetType]

Was this page helpful?