roboto.sentinels#
Module Contents#
- roboto.sentinels.NotSet#
- class roboto.sentinels.NotSetType(**data)#
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.
- static openapi_schema_modifier(schema, model)#
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
- class roboto.sentinels.Null#
- roboto.sentinels.PydanticModel#
- roboto.sentinels.T#
- roboto.sentinels.is_any_set(value)#
Checks whether a Pydantic model has at least one field that is explicitly set.
- Parameters:
value (PydanticModel)
- Return type:
bool
- roboto.sentinels.is_not_set(value)#
- Parameters:
value (Any)
- Return type:
TypeGuard[NotSetType]
- roboto.sentinels.is_set(value)#
- Parameters:
value (Union[T, NotSetType])
- Return type:
TypeGuard[T]
- roboto.sentinels.null#
- roboto.sentinels.remove_not_set(value)#
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:
value (PydanticModel)
- Return type:
PydanticModel
- roboto.sentinels.value_or_default_if_unset(value, default)#
- Parameters:
value (Union[T, NotSetType])
default (T)
- Return type:
T
- roboto.sentinels.value_or_not_set(value)#
- Parameters:
value (Optional[T])
- Return type:
Union[T, NotSetType]