# We subclass `Any` to prevent typeguard from failing for MISSING types.## https://github.com/agronholm/typeguard/blob/dd98a9a0ff050166716120cc8614fa90d710a879/src/typeguard/_checkers.py#L933-L935
[docs]classPropagatingMissingType(Singleton,SubclassableAny):"""Type for the :data:`tyro.MISSING` singleton."""
# We have two types of missing sentinels: a propagating missing value, which when set as# a default will set all child values of nested structures as missing as well, and a# nonpropagating missing sentinel, which does not override child defaults.MISSING:Any=PropagatingMissingType()"""Sentinel value to mark default values as missing. Can be used to mark fieldspassed in via `default=` for `tyro.cli()` as required.When used, the 'missing' semantics propagate to children. For example, if we write:.. code-block:: python def main(inner: Dataclass = tyro.MISSING) -> None: ... tyro.cli(main)then all fields belonging to ``Dataclass`` will be marked as missing, even if adefault exists in the dataclass definition."""MISSING_NONPROP:Any=NonpropagatingMissingType()"""Non-propagating version of :data:`tyro.MISSING`.When used, the 'missing' semantics do not propagate to children. For example:.. code-block:: python def main(inner: Dataclass = tyro.MISSING_NONPROP) -> None: ... tyro.cli(main)is equivalent to:.. code-block:: python def main(inner: Dataclass) -> None: ... tyro.cli(main)where default values for fields belonging to ``Dataclass`` will be taken fromthe dataclass definition."""EXCLUDE_FROM_CALL=ExcludeFromCallType()"""Singleton indicating that an argument should not be passed into a fieldconstructor. This is used for :py:class:`typing.TypedDict`."""
[docs]defis_missing(value:Any)->bool:"""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`. """returnvalueisMISSINGorvalueisMISSING_NONPROP
[docs]defis_sentinel(value:Any)->bool:"""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`. """returnvalueisMISSINGorvalueisMISSING_NONPROPorvalueisEXCLUDE_FROM_CALL