Skip to content

Commit

Permalink
deploy: 171b636
Browse files Browse the repository at this point in the history
  • Loading branch information
brentyi committed Jan 19, 2024
1 parent b7eeba3 commit b6dddfa
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 21 deletions.
Binary file modified .doctrees/api/tyro/_fields/index.doctree
Binary file not shown.
Binary file modified .doctrees/environment.pickle
Binary file not shown.
62 changes: 45 additions & 17 deletions _modules/tyro/_fields/index.html

Large diffs are not rendered by default.

20 changes: 19 additions & 1 deletion _modules/tyro/_parsers/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -766,10 +766,28 @@ <h1>Source code for tyro._parsers</h1><div class="highlight"><pre>
<span class="p">)</span>

<span class="c1"># If names match, borrow subcommand default from field default.</span>
<span class="k">if</span> <span class="n">default_name</span> <span class="o">==</span> <span class="n">subcommand_name</span><span class="p">:</span>
<span class="k">if</span> <span class="n">default_name</span> <span class="o">==</span> <span class="n">subcommand_name</span> <span class="ow">and</span> <span class="p">(</span>
<span class="n">field</span><span class="o">.</span><span class="n">is_default_from_default_instance</span>
<span class="ow">or</span> <span class="n">subcommand_config</span><span class="o">.</span><span class="n">default</span> <span class="ow">in</span> <span class="n">_fields</span><span class="o">.</span><span class="n">MISSING_SINGLETONS</span>
<span class="p">):</span>
<span class="n">subcommand_config</span> <span class="o">=</span> <span class="n">dataclasses</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span>
<span class="n">subcommand_config</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="n">field</span><span class="o">.</span><span class="n">default</span>
<span class="p">)</span>

<span class="c1"># Strip the subcommand config from the option type.</span>
<span class="n">option_origin</span><span class="p">,</span> <span class="n">annotations</span> <span class="o">=</span> <span class="n">_resolver</span><span class="o">.</span><span class="n">unwrap_annotated</span><span class="p">(</span><span class="n">option</span><span class="p">)</span>
<span class="n">annotations</span> <span class="o">=</span> <span class="nb">tuple</span><span class="p">(</span>
<span class="n">a</span>
<span class="k">for</span> <span class="n">a</span> <span class="ow">in</span> <span class="n">annotations</span>
<span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">_confstruct</span><span class="o">.</span><span class="n">_SubcommandConfiguration</span><span class="p">)</span>
<span class="p">)</span>
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">annotations</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
<span class="n">option</span> <span class="o">=</span> <span class="n">option_origin</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">option</span> <span class="o">=</span> <span class="n">Annotated</span><span class="o">.</span><span class="n">__class_getitem__</span><span class="p">(</span> <span class="c1"># type: ignore</span>
<span class="p">(</span><span class="n">option_origin</span><span class="p">,)</span> <span class="o">+</span> <span class="n">annotations</span>
<span class="p">)</span>

<span class="n">subparser</span> <span class="o">=</span> <span class="n">ParserSpecification</span><span class="o">.</span><span class="n">from_callable_or_type</span><span class="p">(</span>
<span class="p">(</span>
<span class="c1"># Recursively apply markers.</span>
Expand Down
7 changes: 6 additions & 1 deletion _sources/api/tyro/_fields/index.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ Module Contents



.. py:attribute:: is_default_from_default_instance
:type: bool



.. py:attribute:: helptext
:type: Optional[str]

Expand Down Expand Up @@ -68,7 +73,7 @@ Module Contents
.. py:method:: __post_init__()
.. py:method:: make(name: str, type_or_callable: Union[tyro._typing.TypeForm[Any], Callable], default: Any, helptext: Optional[str], call_argname_override: Optional[Any] = None, *, markers: Tuple[tyro.conf._markers.Marker, Ellipsis] = ())
.. py:method:: make(name: str, type_or_callable: Union[tyro._typing.TypeForm[Any], Callable], default: Any, is_default_from_default_instance: bool, helptext: Optional[str], call_argname_override: Optional[Any] = None, *, markers: Tuple[tyro.conf._markers.Marker, Ellipsis] = ())
:staticmethod:


Expand Down
9 changes: 8 additions & 1 deletion api/tyro/_fields/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,11 @@ <h2>Module Contents<a class="headerlink" href="#module-contents" title="Link to
<span class="sig-name descname"><span class="pre">default</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="pre">Any</span></em><a class="headerlink" href="#tyro._fields.FieldDefinition.default" title="Link to this definition">#</a></dt>
<dd></dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="tyro._fields.FieldDefinition.is_default_from_default_instance">
<span class="sig-name descname"><span class="pre">is_default_from_default_instance</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="pre">bool</span></em><a class="headerlink" href="#tyro._fields.FieldDefinition.is_default_from_default_instance" title="Link to this definition">#</a></dt>
<dd></dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="tyro._fields.FieldDefinition.helptext">
<span class="sig-name descname"><span class="pre">helptext</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="pre">str</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></em><a class="headerlink" href="#tyro._fields.FieldDefinition.helptext" title="Link to this definition">#</a></dt>
Expand Down Expand Up @@ -316,13 +321,14 @@ <h2>Module Contents<a class="headerlink" href="#module-contents" title="Link to

<dl class="py method">
<dt class="sig sig-object py" id="tyro._fields.FieldDefinition.make">
<em class="property"><span class="pre">static</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">make</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">type_or_callable</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">tyro._typing.TypeForm</span><span class="p"><span class="pre">[</span></span><span class="pre">Any</span><span class="p"><span class="pre">]</span></span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">Callable</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">default</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Any</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">helptext</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">call_argname_override</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Any</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">markers</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Tuple</span><span class="p"><span class="pre">[</span></span><span class="pre">tyro.conf._markers.Marker</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">Ellipsis</span><span class="p"><span class="pre">]</span></span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">()</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../../../_modules/tyro/_fields/#FieldDefinition.make"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tyro._fields.FieldDefinition.make" title="Link to this definition">#</a></dt>
<em class="property"><span class="pre">static</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">make</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">type_or_callable</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">tyro._typing.TypeForm</span><span class="p"><span class="pre">[</span></span><span class="pre">Any</span><span class="p"><span class="pre">]</span></span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">Callable</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">default</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Any</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">is_default_from_default_instance</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">bool</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">helptext</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">call_argname_override</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Any</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">markers</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Tuple</span><span class="p"><span class="pre">[</span></span><span class="pre">tyro.conf._markers.Marker</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">Ellipsis</span><span class="p"><span class="pre">]</span></span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">()</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../../../_modules/tyro/_fields/#FieldDefinition.make"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#tyro._fields.FieldDefinition.make" title="Link to this definition">#</a></dt>
<dd><dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>name</strong> (<em>str</em>) – </p></li>
<li><p><strong>type_or_callable</strong> (<em>Union</em><em>[</em><em>tyro._typing.TypeForm</em><em>[</em><em>Any</em><em>]</em><em>, </em><em>Callable</em><em>]</em>) – </p></li>
<li><p><strong>default</strong> (<em>Any</em>) – </p></li>
<li><p><strong>is_default_from_default_instance</strong> (<em>bool</em>) – </p></li>
<li><p><strong>helptext</strong> (<em>Optional</em><em>[</em><em>str</em><em>]</em>) – </p></li>
<li><p><strong>call_argname_override</strong> (<em>Optional</em><em>[</em><em>Any</em><em>]</em>) – </p></li>
<li><p><strong>markers</strong> (<em>Tuple</em><em>[</em><em>tyro.conf._markers.Marker</em><em>, </em><em>Ellipsis</em><em>]</em>) – </p></li>
Expand Down Expand Up @@ -562,6 +568,7 @@ <h2>Module Contents<a class="headerlink" href="#module-contents" title="Link to
<li><a class="reference internal" href="#tyro._fields.FieldDefinition.extern_name"><code class="docutils literal notranslate"><span class="pre">FieldDefinition.extern_name</span></code></a></li>
<li><a class="reference internal" href="#tyro._fields.FieldDefinition.type_or_callable"><code class="docutils literal notranslate"><span class="pre">FieldDefinition.type_or_callable</span></code></a></li>
<li><a class="reference internal" href="#tyro._fields.FieldDefinition.default"><code class="docutils literal notranslate"><span class="pre">FieldDefinition.default</span></code></a></li>
<li><a class="reference internal" href="#tyro._fields.FieldDefinition.is_default_from_default_instance"><code class="docutils literal notranslate"><span class="pre">FieldDefinition.is_default_from_default_instance</span></code></a></li>
<li><a class="reference internal" href="#tyro._fields.FieldDefinition.helptext"><code class="docutils literal notranslate"><span class="pre">FieldDefinition.helptext</span></code></a></li>
<li><a class="reference internal" href="#tyro._fields.FieldDefinition.markers"><code class="docutils literal notranslate"><span class="pre">FieldDefinition.markers</span></code></a></li>
<li><a class="reference internal" href="#tyro._fields.FieldDefinition.custom_constructor"><code class="docutils literal notranslate"><span class="pre">FieldDefinition.custom_constructor</span></code></a></li>
Expand Down
2 changes: 2 additions & 0 deletions genindex/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,8 @@ <h2>I</h2>
<li><a href="../api/tyro/_argparse_formatter/#tyro._argparse_formatter.TyroTheme.invocation">invocation (tyro._argparse_formatter.TyroTheme attribute)</a>
</li>
<li><a href="../api/tyro/_resolver/#tyro._resolver.is_dataclass">is_dataclass() (in module tyro._resolver)</a>
</li>
<li><a href="../api/tyro/_fields/#tyro._fields.FieldDefinition.is_default_from_default_instance">is_default_from_default_instance (tyro._fields.FieldDefinition attribute)</a>
</li>
<li><a href="../api/tyro/_arguments/#tyro._arguments.LoweredArgumentDefinition.is_fixed">is_fixed() (tyro._arguments.LoweredArgumentDefinition method)</a>
</li>
Expand Down
Binary file modified objects.inv
Binary file not shown.
2 changes: 1 addition & 1 deletion searchindex.js

Large diffs are not rendered by default.

0 comments on commit b6dddfa

Please sign in to comment.