{"id":2836,"library":"tyro","title":"Tyro","description":"Tyro is a Python library that generates command-line interfaces (CLIs) and configuration objects directly from standard Python type annotations, docstrings, and default values. It simplifies CLI creation by reducing boilerplate, improving IDE support, and enabling static type checking, acting as a lightweight wrapper around `argparse`. The current version is 1.0.12, and it follows a frequent, point-release cadence.","status":"active","version":"1.0.12","language":"en","source_language":"en","source_url":"https://github.com/brentyi/tyro","tags":["CLI","configuration","dataclasses","type-hints","argparse","developer-tools"],"install":[{"cmd":"pip install tyro","lang":"bash","label":"Install Tyro"}],"dependencies":[{"reason":"Requires Python 3.8 or higher.","package":"python","optional":false}],"imports":[{"symbol":"cli","correct":"import tyro\n# ...\ntyro.cli(...)"}],"quickstart":{"code":"from dataclasses import dataclass\nimport tyro\n\n@dataclass\nclass Args:\n    \"\"\"Configure a greeting.\"\"\"\n    name: str\n    greet: str = \"Hi\" # Default value\n\nif __name__ == \"__main__\":\n    # From command line:\n    # python your_script.py --name World\n    # Or: python your_script.py --name World --greet Hello\n    args = tyro.cli(Args)\n    print(f\"{args.greet}, {args.name}!\")","lang":"python","description":"This example defines a command-line interface using a dataclass. Tyro automatically generates arguments, help text, and parses values from the command line based on the type annotations and docstrings, then populates an instance of `Args`."},"warnings":[{"fix":"Refer to the official documentation on 'What's supported' and 'Argument Prefixing' for `tyro`'s specific interpretation of type hints and argument parsing. Upgrade to the latest version (>=1.0.12) for bug fixes related to `nargs` and positional arguments.","message":"Tyro's parsing logic for complex types like `Union` and `List` (especially with `nargs`) or positional arguments can sometimes behave differently from standard `argparse`. Users migrating complex `argparse` setups should thoroughly test argument parsing, particularly with edge cases.","severity":"gotcha","affected_versions":"<=1.0.11"},{"fix":"Consider using `tyro.conf.OmitSubcommandPrefixes` on your dataclass or `prefix_name=False` in `tyro.conf.arg()` to shorten argument names where appropriate. For `Union` types defining subcommands, `tyro.conf.subcommand(name='...')` can customize the subcommand name directly.","message":"When working with nested dataclasses or `Union` types that define subcommands, `tyro` by default prefixes arguments (e.g., `parent.child.arg`). This can lead to very long argument names. While explicit, it might not be desired for all CLIs.","severity":"gotcha","affected_versions":"all"},{"fix":"Refactor code to pass configuration markers as a tuple to `tyro.cli(YourConfig, config=(tyro.conf.Marker,))` instead of using the `@tyro.conf.configure` decorator.","message":"The `@tyro.conf.configure` decorator is generally discouraged for applying global configuration markers. The preferred approach for global options is to pass the `config=` argument directly to `tyro.cli()`.","severity":"deprecated","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-10T00:00:00.000Z","next_check":"2026-07-09T00:00:00.000Z"}