Skip to content

Commit cb79b2a

Browse files
committed
Fix generic subcommand example doc
1 parent ae0ab2c commit cb79b2a

File tree

2 files changed

+8
-15
lines changed

2 files changed

+8
-15
lines changed

docs/source/examples/generics.rst

+4-14
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,8 @@ generic types is also supported.
160160
Generic Subcommands
161161
-------------------
162162

163-
163+
Just like standard classes, generic classes within unions can be selected
164+
between using subcommands.
164165

165166

166167
.. code-block:: python
@@ -253,17 +254,6 @@ Generic Subcommands
253254
.. raw:: html
254255

255256
<pre class="highlight" style="padding: 1em; box-sizing: border-box; font-size: 0.85em; line-height: 1.2em;">
256-
<strong style="opacity: 0.7; padding-bottom: 0.5em; display: inline-block"><span style="user-select: none">$ </span>python ./03_generic_subcommands.py experiment-adam --path /tmp --lr 1e-3</strong>
257-
<span style="color: #e60000">╭─</span><span style="color: #e60000"> </span><span style="font-weight: bold; color: #e60000">Unrecognized options</span><span style="color: #e60000"> </span><span style="color: #e60000">─────────────────────────────────────────</span><span style="color: #e60000">─╮</span>
258-
<span style="color: #e60000">│</span> Unrecognized options: --lr <span style="color: #e60000">│</span>
259-
<span style="color: #e60000">│</span> <span style="color: #800000">───────────────────────────────────────────────────────────────</span> <span style="color: #e60000">│</span>
260-
<span style="color: #e60000">│</span> Perhaps you meant: <span style="color: #e60000">│</span>
261-
<span style="color: #e60000">│</span> <span style="font-weight: bold">--opt.lr FLOAT</span> <span style="color: #e60000">│</span>
262-
<span style="color: #e60000">│</span> <span style="color: #008080">(default: 0.0003)</span> <span style="color: #e60000">│</span>
263-
<span style="color: #e60000">│</span> in <span style="color: #008000">03_generic_subcommands.py experiment-adam --help</span> <span style="color: #e60000">│</span>
264-
<span style="color: #e60000">│</span> <span style="color: #008080">(default: 0.0001)</span> <span style="color: #e60000">│</span>
265-
<span style="color: #e60000">│</span> in <span style="color: #008000">03_generic_subcommands.py experiment-sgd --help</span> <span style="color: #e60000">│</span>
266-
<span style="color: #e60000">│</span> <span style="color: #800000">───────────────────────────────────────────────────────────────</span> <span style="color: #e60000">│</span>
267-
<span style="color: #e60000">│</span> For full helptext, run <span style="font-weight: bold">03_generic_subcommands.py --help</span> <span style="color: #e60000">│</span>
268-
<span style="color: #e60000">╰─────────────────────────────────────────────────────────────────╯</span>
257+
<strong style="opacity: 0.7; padding-bottom: 0.5em; display: inline-block"><span style="user-select: none">$ </span>python ./03_generic_subcommands.py experiment-adam --path /tmp --opt.lr 1e-3</strong>
258+
Experiment(path=PosixPath('/tmp'), opt=Adam(lr=0.001, betas=(0.9, 0.999)))
269259
</pre>

examples/05_generics/03_generic_subcommands.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@
44
# mypy. This will be fixed by `typing.TypeForm`: https://peps.python.org/pep-0747/
55
"""Generic Subcommands
66
7+
Just like standard classes, generic classes within unions can be selected
8+
between using subcommands.
9+
710
Usage:
811
912
python ./03_generic_subcommands.py --help
1013
python ./03_generic_subcommands.py experiment-adam --help
1114
python ./03_generic_subcommands.py experiment-sgd --help
12-
python ./03_generic_subcommands.py experiment-adam --path /tmp --lr 1e-3
15+
python ./03_generic_subcommands.py experiment-adam --path /tmp --opt.lr 1e-3
1316
"""
1417

1518
import dataclasses

0 commit comments

Comments
 (0)