tyro._singleton

Module Contents

tyro._singleton.SubclassableAny
class tyro._singleton.Singleton[source]
init(*args, **kwds)[source]
class tyro._singleton.PropagatingMissingType[source]

Bases: Singleton, typing_extensions.Any

Type for the tyro.MISSING singleton.

__repr__() str[source]

Return repr(self).

Return type:

str

class tyro._singleton.NonpropagatingMissingType[source]

Bases: Singleton, typing_extensions.Any

Type for the tyro.MISSING_NONPROP singleton.

__repr__() str[source]

Return repr(self).

Return type:

str

class tyro._singleton.ExcludeFromCallType[source]

Bases: Singleton

class tyro._singleton.NotRequiredButWeDontKnowTheValueType[source]

Bases: Singleton

tyro._singleton.MISSING: Any

Sentinel value to mark default values as missing. Can be used to mark fields passed in via default= for tyro.cli() as required.

When used, the ‘missing’ semantics propagate to children. For example, if we write:

def main(inner: Dataclass = tyro.MISSING) -> None:
    ...

tyro.cli(main)

then all fields belonging to Dataclass will be marked as missing, even if a default exists in the dataclass definition.

tyro._singleton.MISSING_NONPROP: Any

Non-propagating version of tyro.MISSING.

When used, the ‘missing’ semantics do not propagate to children. For example:

def main(inner: Dataclass = tyro.MISSING_NONPROP) -> None:
    ...

tyro.cli(main)

is equivalent to:

def main(inner: Dataclass) -> None:
    ...

tyro.cli(main)

where default values for fields belonging to Dataclass will be taken from the dataclass definition.

tyro._singleton.EXCLUDE_FROM_CALL

Singleton indicating that an argument should not be passed into a field constructor. This is used for typing.TypedDict.

tyro._singleton.is_missing(value: Any) bool[source]

Check if a value is a missing sentinel (MISSING or MISSING_NONPROP).

Uses identity checks to avoid issues with types like numpy arrays that have ambiguous truth values when compared with == or in.

Parameters:

value (Any)

Return type:

bool

tyro._singleton.is_sentinel(value: Any) bool[source]

Check if a value is any default sentinel (MISSING, MISSING_NONPROP, or EXCLUDE_FROM_CALL).

Uses identity checks to avoid issues with types like numpy arrays that have ambiguous truth values when compared with == or in.

Parameters:

value (Any)

Return type:

bool