---
sidebar:
  label: roboto.sentinels
  order: 24
title: roboto.sentinels
---
## Module Contents

### NotSet

```python
roboto.sentinels.NotSet
```

`from roboto.sentinels import NotSet`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/sentinels.py#L187-L187)

Value of a field or argument the caller did not set, where `None` has a meaning of its own, such as clearing it.

### NotSetType

```python
class roboto.sentinels.NotSetType(**data)
```

`from roboto.sentinels import NotSetType`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/sentinels.py#L56-L104)

Bases: `pydantic.BaseModel`

Type of `NotSet`: a field or argument the caller did not set.

An update request defaults a field to `NotSet`, so that a field left out is unchanged while `None` clears it. `NotSet` is falsy. It is a pydantic model with no fields, so a request model can hold it in a field; a model dump writes it as `{}`, and `remove_not_set` leaves such fields out. Use `NotSet` rather than constructing another; constructing one with any arguments raises `ValueError`.

#### NotSetType.openapi_schema_modifier()

```python
@staticmethod
def openapi_schema_modifier(schema: dict[str, Any], model: Any) -> None
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/sentinels.py#L72-L101)

Rewrite a model's JSON schema so that each field that accepts `NotSet` shows as nullable instead.

Pydantic calls this while it builds the JSON schema of a model whose config sets `json_schema_extra=NotSetType.openapi_schema_modifier`. In each property's `anyOf`, it replaces each reference to `NotSetType` with `{"type": "null"}`, and it drops the property's default of `{}`, which is `NotSet` as a model dump writes it.

**Parameters**

- **schema** (`dict[str, Any]`): JSON schema of the model, changed in place.
- **model** (`Any`): Ignored.

**Returns**

- `None`

### Null

```python
class roboto.sentinels.Null
```

`from roboto.sentinels import Null`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/sentinels.py#L22-L33)

Type of `null`: a command-line argument a user wrote as `null` to clear a field.

Its one instance is falsy, and its `repr` is `null`. The `roboto` command line checks for it with `is`, so use `null` rather than constructing another.

### PydanticModel

```python
roboto.sentinels.PydanticModel
```

`from roboto.sentinels import PydanticModel`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/sentinels.py#L15-L15)

Type of the pydantic model that a function in this module reads.

The functions that read one are `remove_not_set` and `is_any_set`.

### T

```python
roboto.sentinels.T
```

`from roboto.sentinels import T`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/sentinels.py#L12-L12)

Type of the value a function in this module takes or returns.

### is_any_set()

```python
def roboto.sentinels.is_any_set(value: PydanticModel) -> bool
```

`from roboto.sentinels import is_any_set`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/sentinels.py#L171-L184)

Return whether any field of a pydantic model holds a value other than `NotSet`.

A field holding `None` counts as set, so this returns `True` for any model with a field that defaults to `None`.

**Parameters**

- **value** (`PydanticModel`): Model to check.

**Returns**

- `bool`

### is_not_set()

```python
def roboto.sentinels.is_not_set(value: Any) -> TypeGuard[NotSetType]
```

`from roboto.sentinels import is_not_set`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/sentinels.py#L107-L115)

Return whether `value` is `NotSet`.

A type checker narrows `value` to `NotSetType` where this returns `True`.

**Parameters**

- **value** (`Any`): Value to check.

**Returns**

- `TypeGuard[NotSetType]`

### is_set()

```python
def roboto.sentinels.is_set(value: Union[T, NotSetType]) -> TypeGuard[T]
```

`from roboto.sentinels import is_set`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/sentinels.py#L118-L126)

Return whether `value` is anything other than `NotSet`, `None` included.

A type checker narrows `value` to its type other than `NotSetType` where this returns `True`.

**Parameters**

- **value** (`Union[T, NotSetType]`): Value to check.

**Returns**

- `TypeGuard[T]`

### maybe_null()

```python
def roboto.sentinels.maybe_null(value: T) -> Union[T, Null]
```

`from roboto.sentinels import maybe_null`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/sentinels.py#L40-L53)

Return `null` when `value` is the string `"null"` in any case, else `value`.

The `roboto` command line converts each argument that can clear a field through it, so most code never calls it. That is how `--description null` clears a dataset's description.

**Parameters**

- **value** (`T`): Command-line argument to convert.

**Returns**

- `Union[T, Null]`

### null

```python
roboto.sentinels.null
```

`from roboto.sentinels import null`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/sentinels.py#L36-L36)

Value `maybe_null` returns in place of a command-line argument a user wrote as `null` to clear a field.

### remove_not_set()

```python
def roboto.sentinels.remove_not_set(value: PydanticModel) -> PydanticModel
```

`from roboto.sentinels import remove_not_set`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/sentinels.py#L156-L168)

Build a copy of a pydantic model on which the fields holding `NotSet` are unset.

`model_dump(exclude_unset=True)` on the copy leaves those fields out, where a dump of the original writes each as `{}`. Every other field is set on the copy, including one left at a default of `None`, so the dump includes it. Only the model's own fields are checked, not those of models nested in it. Building the copy runs the model's validators again.

**Parameters**

- **value** (`PydanticModel`): Model to copy.

**Returns**

- `PydanticModel`

### value_or_default_if_unset()

```python
def roboto.sentinels.value_or_default_if_unset(
    value: Union[T, NotSetType],
    default: T,
) -> T
```

`from roboto.sentinels import value_or_default_if_unset`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/sentinels.py#L143-L153)

Return `value`, or `default` when `value` is `NotSet`.

**Parameters**

- **value** (`Union[T, NotSetType]`): Value that may be `NotSet`.
- **default** (`T`): Value to return in its place.

**Returns**

- `T`

### value_or_not_set()

```python
def roboto.sentinels.value_or_not_set(value: Optional[T]) -> Union[T, NotSetType]
```

`from roboto.sentinels import value_or_not_set`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/sentinels.py#L129-L140)

Return `value`, or `NotSet` when it is `None`.

Use it to pass an optional argument to an update request field, where `None` would clear the field.

**Parameters**

- **value** (`Optional[T]`): Value to pass on.

**Returns**

- `Union[T, NotSetType]`
