tyro._parsers
¶
Interface for generating argparse.ArgumentParser() definitions from callables.
Module Contents¶
- tyro._parsers.T¶
- class tyro._parsers.ParserSpecification[source]¶
Each parser contains a list of arguments and optionally some subparsers.
- f: Callable¶
- args: List[tyro._arguments.ArgumentDefinition]¶
- field_list: List[tyro._fields.FieldDefinition]¶
- child_from_prefix: Dict[str, ParserSpecification]¶
- subparsers: SubparsersSpecification | None¶
- subparsers_from_intern_prefix: Dict[str, SubparsersSpecification]¶
- static from_callable_or_type(f: Callable[Ellipsis, T], markers: Set[tyro.conf._markers._Marker], description: str | None, parent_classes: Set[Type[Any]], default_instance: T | tyro._singleton.PropagatingMissingType | tyro._singleton.NonpropagatingMissingType, intern_prefix: str, extern_prefix: str, subcommand_prefix: str = '', support_single_arg_types: bool = False) ParserSpecification [source]¶
Create a parser definition from a callable or type.
- Parameters:
f (Callable[Ellipsis, T])
markers (Set[tyro.conf._markers._Marker])
description (Optional[str])
parent_classes (Set[Type[Any]])
default_instance (Union[T, tyro._singleton.PropagatingMissingType, tyro._singleton.NonpropagatingMissingType])
intern_prefix (str)
extern_prefix (str)
subcommand_prefix (str)
support_single_arg_types (bool)
- Return type:
- apply(parser: tyro._argparse.ArgumentParser) Tuple[tyro._argparse.ArgumentParser, Ellipsis] [source]¶
Create defined arguments and subparsers.
- Parameters:
parser (tyro._argparse.ArgumentParser)
- Return type:
Tuple[tyro._argparse.ArgumentParser, Ellipsis]
- apply_args(parser: tyro._argparse.ArgumentParser, parent: ParserSpecification | None = None) None [source]¶
Create defined arguments and subparsers.
- Parameters:
parser (tyro._argparse.ArgumentParser)
parent (Optional[ParserSpecification])
- Return type:
None
- tyro._parsers.handle_field(field: tyro._fields.FieldDefinition, parent_classes: Set[Type[Any]], intern_prefix: str, extern_prefix: str, subcommand_prefix: str) tyro._arguments.ArgumentDefinition | ParserSpecification | SubparsersSpecification [source]¶
Determine what to do with a single field definition.
- Parameters:
field (tyro._fields.FieldDefinition)
parent_classes (Set[Type[Any]])
intern_prefix (str)
extern_prefix (str)
subcommand_prefix (str)
- Return type:
Union[tyro._arguments.ArgumentDefinition, ParserSpecification, SubparsersSpecification]
- class tyro._parsers.SubparsersSpecification[source]¶
Structure for defining subparsers. Each subparser is a parser with a name.
- parser_from_name: Dict[str, ParserSpecification]¶
- default_instance: Any¶
- options: Tuple[tyro._typing.TypeForm[Any] | Callable, Ellipsis]¶
- static from_field(field: tyro._fields.FieldDefinition, parent_classes: Set[Type[Any]], intern_prefix: str, extern_prefix: str) SubparsersSpecification | None [source]¶
- Parameters:
field (tyro._fields.FieldDefinition)
parent_classes (Set[Type[Any]])
intern_prefix (str)
extern_prefix (str)
- Return type:
Optional[SubparsersSpecification]
- apply(parent_parser: tyro._argparse.ArgumentParser) Tuple[tyro._argparse.ArgumentParser, Ellipsis] [source]¶
- Parameters:
parent_parser (tyro._argparse.ArgumentParser)
- Return type:
Tuple[tyro._argparse.ArgumentParser, Ellipsis]
- tyro._parsers.add_subparsers_to_leaves(root: SubparsersSpecification | None, leaf: SubparsersSpecification) SubparsersSpecification [source]¶
- Parameters:
root (Optional[SubparsersSpecification])
leaf (SubparsersSpecification)
- Return type: