Skip to content

Commit

Permalink
deploy: d242dda
Browse files Browse the repository at this point in the history
  • Loading branch information
brentyi committed Jan 19, 2024
1 parent 7548072 commit d760cba
Show file tree
Hide file tree
Showing 21 changed files with 84 additions and 79 deletions.
Binary file modified .doctrees/api/tyro/_parsers/index.doctree
Binary file not shown.
Binary file modified .doctrees/environment.pickle
Binary file not shown.
Binary file modified .doctrees/examples/02_nesting/01_nesting.doctree
Binary file not shown.
Binary file modified .doctrees/examples/04_additional/01_positional_args.doctree
Binary file not shown.
Binary file modified .doctrees/examples/04_additional/03_tuples.doctree
Binary file not shown.
Binary file modified .doctrees/examples/04_additional/07_flax.doctree
Binary file not shown.
Binary file modified .doctrees/examples/04_additional/10_custom_constructors.doctree
Binary file not shown.
3 changes: 3 additions & 0 deletions _modules/tyro/_argparse_formatter/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,9 @@ <h1>Source code for tyro._argparse_formatter</h1><div class="highlight"><pre>
<span class="o">+</span> <span class="p">(</span><span class="mi">1</span> <span class="k">if</span> <span class="n">subparser_name</span> <span class="ow">in</span> <span class="n">args</span> <span class="k">else</span> <span class="o">-</span><span class="mf">0.001</span><span class="p">),</span>
<span class="p">)</span>

<span class="k">for</span> <span class="n">child</span> <span class="ow">in</span> <span class="n">parser_spec</span><span class="o">.</span><span class="n">child_from_prefix</span><span class="o">.</span><span class="n">values</span><span class="p">():</span>
<span class="n">_recursive_arg_search</span><span class="p">(</span><span class="n">child</span><span class="p">,</span> <span class="n">prog</span><span class="p">,</span> <span class="n">subcommand_match_score</span><span class="p">)</span>

<span class="n">_recursive_arg_search</span><span class="p">(</span><span class="n">parser_spec</span><span class="p">,</span> <span class="n">prog</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>

<span class="k">return</span> <span class="n">arguments</span><span class="p">,</span> <span class="n">has_subcommands</span><span class="p">,</span> <span class="n">same_exists</span></div>
Expand Down
14 changes: 3 additions & 11 deletions _modules/tyro/_calling/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -295,11 +295,6 @@ <h1>Source code for tyro._calling</h1><div class="highlight"><pre>

<span class="sd"> Returns the output of `f` and a set of used arguments.&quot;&quot;&quot;</span>

<span class="c1"># Resolve the type of `f`, generate a field list.</span>
<span class="n">f</span><span class="p">,</span> <span class="n">type_from_typevar</span><span class="p">,</span> <span class="n">field_list</span> <span class="o">=</span> <span class="n">_fields</span><span class="o">.</span><span class="n">field_list_from_callable</span><span class="p">(</span>
<span class="n">f</span><span class="o">=</span><span class="n">f</span><span class="p">,</span> <span class="n">default_instance</span><span class="o">=</span><span class="n">default_instance</span><span class="p">,</span> <span class="n">support_single_arg_types</span><span class="o">=</span><span class="kc">True</span>
<span class="p">)</span>

<span class="n">positional_args</span><span class="p">:</span> <span class="n">List</span><span class="p">[</span><span class="n">Any</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span>
<span class="n">kwargs</span><span class="p">:</span> <span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">Any</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span>
<span class="n">consumed_keywords</span><span class="p">:</span> <span class="n">Set</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="nb">set</span><span class="p">()</span>
Expand All @@ -320,7 +315,7 @@ <h1>Source code for tyro._calling</h1><div class="highlight"><pre>

<span class="n">any_arguments_provided</span> <span class="o">=</span> <span class="kc">False</span>

<span class="k">for</span> <span class="n">field</span> <span class="ow">in</span> <span class="n">field_list</span><span class="p">:</span>
<span class="k">for</span> <span class="n">field</span> <span class="ow">in</span> <span class="n">parser_definition</span><span class="o">.</span><span class="n">field_list</span><span class="p">:</span>
<span class="n">value</span><span class="p">:</span> <span class="n">Any</span>
<span class="n">prefixed_field_name</span> <span class="o">=</span> <span class="n">_strings</span><span class="o">.</span><span class="n">make_field_name</span><span class="p">(</span>
<span class="p">[</span><span class="n">field_name_prefix</span><span class="p">,</span> <span class="n">field</span><span class="o">.</span><span class="n">intern_name</span><span class="p">]</span>
Expand Down Expand Up @@ -379,16 +374,13 @@ <h1>Source code for tyro._calling</h1><div class="highlight"><pre>
<span class="s2">&quot; is a fixed argument that cannot be parsed&quot;</span><span class="p">,</span>
<span class="n">arg</span><span class="p">,</span>
<span class="p">)</span>
<span class="k">elif</span> <span class="p">(</span>
<span class="n">prefixed_field_name</span>
<span class="ow">in</span> <span class="n">parser_definition</span><span class="o">.</span><span class="n">helptext_from_nested_class_field_name</span>
<span class="p">):</span>
<span class="k">elif</span> <span class="n">prefixed_field_name</span> <span class="ow">in</span> <span class="n">parser_definition</span><span class="o">.</span><span class="n">child_from_prefix</span><span class="p">:</span>
<span class="c1"># Nested callable.</span>
<span class="k">if</span> <span class="n">_resolver</span><span class="o">.</span><span class="n">unwrap_origin_strip_extras</span><span class="p">(</span><span class="n">field_type</span><span class="p">)</span> <span class="ow">is</span> <span class="n">Union</span><span class="p">:</span>
<span class="n">field_type</span> <span class="o">=</span> <span class="nb">type</span><span class="p">(</span><span class="n">field</span><span class="o">.</span><span class="n">default</span><span class="p">)</span>
<span class="n">value</span><span class="p">,</span> <span class="n">consumed_keywords_child</span> <span class="o">=</span> <span class="n">call_from_args</span><span class="p">(</span>
<span class="n">field_type</span><span class="p">,</span>
<span class="n">parser_definition</span><span class="p">,</span>
<span class="n">parser_definition</span><span class="o">.</span><span class="n">child_from_prefix</span><span class="p">[</span><span class="n">prefixed_field_name</span><span class="p">],</span>
<span class="n">field</span><span class="o">.</span><span class="n">default</span><span class="p">,</span>
<span class="n">value_from_prefixed_field_name</span><span class="p">,</span>
<span class="n">field_name_prefix</span><span class="o">=</span><span class="n">prefixed_field_name</span><span class="p">,</span>
Expand Down
10 changes: 1 addition & 9 deletions _modules/tyro/_fields/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -670,16 +670,8 @@ <h1>Source code for tyro._fields</h1><div class="highlight"><pre>
<span class="n">f</span><span class="p">:</span> <span class="n">Union</span><span class="p">[</span><span class="n">Callable</span><span class="p">,</span> <span class="n">TypeForm</span><span class="p">[</span><span class="n">Any</span><span class="p">]],</span>
<span class="n">default_instance</span><span class="p">:</span> <span class="n">DefaultInstance</span><span class="p">,</span>
<span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Union</span><span class="p">[</span><span class="n">List</span><span class="p">[</span><span class="n">FieldDefinition</span><span class="p">],</span> <span class="n">UnsupportedNestedTypeMessage</span><span class="p">]:</span>
<span class="c1"># TODO: this is needed when field_list_from_callable() is called in _calling.py.</span>
<span class="c1"># It&#39;s basically duplicated from (completely separate!) logic in</span>
<span class="c1"># _parsers.py, which is risky and might caused edge cases.</span>
<span class="n">f</span><span class="p">,</span> <span class="n">found_subcommand_configs</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">f</span><span class="p">,</span> <span class="n">conf</span><span class="o">.</span><span class="n">_confstruct</span><span class="o">.</span><span class="n">_SubcommandConfiguration</span>
<span class="p">)</span>
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">found_subcommand_configs</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
<span class="n">default_instance</span> <span class="o">=</span> <span class="n">found_subcommand_configs</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">default</span>

<span class="c1"># Unwrap generics.</span>
<span class="n">f</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">f</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span>
<span class="n">f</span><span class="p">,</span> <span class="n">type_from_typevar</span> <span class="o">=</span> <span class="n">_resolver</span><span class="o">.</span><span class="n">resolve_generic_types</span><span class="p">(</span><span class="n">f</span><span class="p">)</span>
<span class="n">f</span> <span class="o">=</span> <span class="n">_resolver</span><span class="o">.</span><span class="n">apply_type_from_typevar</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">type_from_typevar</span><span class="p">)</span>
<span class="n">f</span> <span class="o">=</span> <span class="n">_resolver</span><span class="o">.</span><span class="n">unwrap_newtype_and_narrow_subtypes</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">default_instance</span><span class="p">)</span>
Expand Down
Loading

0 comments on commit d760cba

Please sign in to comment.