Skip to content

Commit

Permalink
0.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
brentyi committed Nov 18, 2024
1 parent 3a603a2 commit 91dfac2
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 13 deletions.
11 changes: 8 additions & 3 deletions docs/source/examples/custom_constructors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
Custom constructors
===================

:func:`tyro.cli` is designed for comprehensive support of standard Python type
constructs. In some cases, however, it can be useful to extend the set of types
supported by :mod:`tyro`.
:func:`tyro.cli` aims for comprehensive support of standard Python type
constructs. It can still, however, be useful to extend the set of suported
types.

We provide two complementary approaches for doing so:

Expand All @@ -19,6 +19,11 @@ We provide two complementary approaches for doing so:
instantiated from a single commandline argument, while *struct* types are
broken down into multiple arguments.

.. warning::

Custom constructors are useful, but can be verbose and require care. We
recommend using them sparingly.


.. _example-01_simple_constructors:

Expand Down
4 changes: 2 additions & 2 deletions docs/source/examples/hierarchical_structures.rst
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,11 @@ Structures can be nested inside of standard containers.
color_tuple: tuple[RGB, RGB]
color_dict: dict[str, RGB] = dataclasses.field(
# We can't use mutable values as defaults directly.
default_factory={
default_factory=lambda: {
"red": RGB(255, 0, 0),
"green": RGB(0, 255, 0),
"blue": RGB(0, 0, 255),
}.copy
}
)
if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion docs/source/whats_supported.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ As a partial list, inputs can be annotated with:
- Basic types like :class:`int`, :class:`str`, :class:`float`, :class:`bool`, :class:`pathlib.Path`, :data:`None`.
- :class:`datetime.date`, :class:`datetime.datetime`, and :class:`datetime.time`.
- Container types like :class:`list`, :class:`dict`, :class:`tuple`, and :class:`set`.
- Union types, like `X | Y`, :py:data:`typing.Union`, and :py:data:`typing.Optional`.
- Union types, like ``X | Y``, :py:data:`typing.Union`, and :py:data:`typing.Optional`.
- :py:data:`typing.Literal` and :class:`enum.Enum`.
- Type aliases, for example using Python 3.12's `PEP 695 <https://peps.python.org/pep-0695/>`_ `type` statement.
- Generics, such as those annotated with :py:class:`typing.TypeVar` or with the type parameter syntax introduced by Python 3.12's `PEP 695 <https://peps.python.org/pep-0695/>`_.
Expand Down
4 changes: 2 additions & 2 deletions examples/02_hierarchical_structures/03_nesting_containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ class Args:
color_tuple: tuple[RGB, RGB]
color_dict: dict[str, RGB] = dataclasses.field(
# We can't use mutable values as defaults directly.
default_factory={
default_factory=lambda: {
"red": RGB(255, 0, 0),
"green": RGB(0, 255, 0),
"blue": RGB(0, 0, 255),
}.copy
}
)


Expand Down
11 changes: 8 additions & 3 deletions examples/06_custom_constructors/README.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Custom constructors
===================

:func:`tyro.cli` is designed for comprehensive support of standard Python type
constructs. In some cases, however, it can be useful to extend the set of types
supported by :mod:`tyro`.
:func:`tyro.cli` aims for comprehensive support of standard Python type
constructs. It can still, however, be useful to extend the set of suported
types.

We provide two complementary approaches for doing so:

Expand All @@ -13,3 +13,8 @@ We provide two complementary approaches for doing so:
for different types. There are two categories of types: *primitive* types are
instantiated from a single commandline argument, while *struct* types are
broken down into multiple arguments.

.. warning::

Custom constructors are useful, but can be verbose and require care. We
recommend using them sparingly.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ name = "tyro"
authors = [
{name = "brentyi", email = "[email protected]"},
]
version = "0.8.14" # TODO: currently needs to be synchronized manually with __init__.py.
version = "0.9.0" # TODO: currently needs to be synchronized manually with __init__.py.
description = "Strongly typed, zero-effort CLI interfaces"
readme = "README.md"
license = { text = "MIT" }
Expand Down
2 changes: 1 addition & 1 deletion src/tyro/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@


# TODO: this should be synchronized automatically with the pyproject.toml.
__version__ = "0.8.14"
__version__ = "0.9.0"

0 comments on commit 91dfac2

Please sign in to comment.