CLI interfaces & config objects, from types
Actively maintained. Last release 4 weeks ago, commits in 7 of the last 26 weeks. A safe choice.
pip install tyrotyro
Documentation
•
pip install tyro
tyro.cli() is a tool for generating CLI
interfaces from type-annotated Python.
We can define configurable scripts using functions:
Or instantiate configs defined using tools like dataclasses, pydantic, and attrs:
Other features include helptext generation, nested structures, subcommands, and shell completion. For examples and the API reference, see our documentation.
Why tyro?
-
Define things once. Standard Python type annotations, docstrings, and default values are parsed to automatically generate command-line interfaces with nice helptext.
-
Static types. Unlike tools dependent on dictionaries, YAML, or dynamic namespaces, arguments populated by
tyroare better undestood by IDEs and language servers, as well as static checking tools likepyrightandmypy. -
Modularity.
tyrosupports hierarchical configurations, which make it easy to decentralize definitions, defaults, and documentation.
In the wild
tyro is designed to be lightweight for throwaway scripts, while
improving maintainability for larger projects. Examples: