diff --git a/docs/source/examples/custom_constructors.rst b/docs/source/examples/custom_constructors.rst index 9caf52a9..0ef63603 100644 --- a/docs/source/examples/custom_constructors.rst +++ b/docs/source/examples/custom_constructors.rst @@ -326,7 +326,6 @@ structs. if isinstance(type_info.default, Bounds): # If the default value is a `Bounds` instance, we don't need to generate a constructor. default = (type_info.default.bounds[0], type_info.default.bounds[1]) - is_default_overridden = True else: # Otherwise, the default value is missing. We'll mark the child defaults as missing as well. assert type_info.default in ( @@ -334,7 +333,6 @@ structs. tyro.constructors.MISSING_NONPROP, ) default = (tyro.MISSING, tyro.MISSING) - is_default_overridden = False # If the rule applies, we return the constructor spec. return tyro.constructors.StructConstructorSpec( @@ -345,14 +343,12 @@ structs. name="lower", type=int, default=default[0], - is_default_overridden=is_default_overridden, helptext="Lower bound." "", ), tyro.constructors.StructFieldSpec( name="upper", type=int, default=default[1], - is_default_overridden=is_default_overridden, helptext="Upper bound." "", ), ), diff --git a/docs/source/examples/subcommands.rst b/docs/source/examples/subcommands.rst index 217f95ee..0e949ea9 100644 --- a/docs/source/examples/subcommands.rst +++ b/docs/source/examples/subcommands.rst @@ -284,17 +284,17 @@ pushes all arguments to the end of the command:
$ python ./03_multiple_subcommands.py --help - usage: 03_multiple_subcommands.py [-h] {dataset:mnist,dataset:image-net} + usage: 03_multiple_subcommands.py [-h] [{dataset:mnist,dataset:image-net}] Example training script. ╭─ options ─────────────────────────────────────────╮ │ -h, --help show this help message and exit │ ╰───────────────────────────────────────────────────╯ - ╭─ subcommands ─────────────────────────────────────╮ - │ Dataset to train on. │ - │ ───────────────────────────────── │ - │ {dataset:mnist,dataset:image-net} │ + ╭─ optional subcommands ────────────────────────────╮ + │ Dataset to train on. (default: dataset:mnist) │ + │ ───────────────────────────────────────────── │ + │ [{dataset:mnist,dataset:image-net}] │ │ dataset:mnist │ │ dataset:image-net │ ╰───────────────────────────────────────────────────╯ @@ -307,18 +307,19 @@ pushes all arguments to the end of the command:$ python ./03_multiple_subcommands.py dataset:mnist --help usage: 03_multiple_subcommands.py dataset:mnist [-h] - {optimizer:adam,optimizer:sgd} + [{optimizer:adam,optimizer:sgd + }] - ╭─ options ─────────────────────────────────────────╮ - │ -h, --help show this help message and exit │ - ╰───────────────────────────────────────────────────╯ - ╭─ subcommands ─────────────────────────────────────╮ - │ Optimizer to train with. │ - │ ────────────────────────────── │ - │ {optimizer:adam,optimizer:sgd} │ - │ optimizer:adam │ - │ optimizer:sgd │ - ╰───────────────────────────────────────────────────╯ + ╭─ options ──────────────────────────────────────────╮ + │ -h, --help show this help message and exit │ + ╰────────────────────────────────────────────────────╯ + ╭─ optional subcommands ─────────────────────────────╮ + │ Optimizer to train with. (default: optimizer:adam) │ + │ ────────────────────────────────────────────────── │ + │ [{optimizer:adam,optimizer:sgd}] │ + │ optimizer:adam │ + │ optimizer:sgd │ + ╰────────────────────────────────────────────────────╯diff --git a/src/tyro/conf/_confstruct.py b/src/tyro/conf/_confstruct.py index 8f5395f8..a55b7cbc 100644 --- a/src/tyro/conf/_confstruct.py +++ b/src/tyro/conf/_confstruct.py @@ -89,15 +89,15 @@ def subcommand( .. code-block:: python - # For the first subcommand, StructType(1) will be used as the default. + # For the first subcommand, StructTypeA(1) will be used as the default. # The second subcommand, whose type is inconsistent with the field # default, will be unaffected. x: Union[ Annotated[ - StructTypeA, subcommand(default=StructTypeA(0) + StructTypeA, subcommand(default=StructTypeA(0)) ], Annotated[ - StructTypeB, subcommand(default=StructTypeB(0) + StructTypeB, subcommand(default=StructTypeB(0)) ], ] = StructTypeA(1)