Skip to content

Commit

Permalink
deploy: ac9ca04
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhiyuanChen committed Aug 21, 2024
1 parent d65c654 commit d3e9ffe
Show file tree
Hide file tree
Showing 24 changed files with 10,369 additions and 10,625 deletions.
3,254 changes: 1,481 additions & 1,773 deletions config/index.html

Large diffs are not rendered by default.

82 changes: 29 additions & 53 deletions configclass/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1003,7 +1003,7 @@ <h1 id="configclass">configclass<a class="headerlink" href="#configclass" title=


<h2 id="chanfig.configclasses.configclass" class="doc doc-heading">
<code class="highlight language-python"><span class="n">configclass</span><span class="p">(</span><span class="bp">cls</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">recursive</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span></code>
<code class="highlight language-python"><span class="n">configclass</span><span class="p">(</span><span class="bp">cls</span><span class="o">=</span><span class="kc">None</span><span class="p">)</span></code>

<a href="#chanfig.configclasses.configclass" class="headerlink" title="Permanent link">&para;</a></h2>

Expand Down Expand Up @@ -1044,20 +1044,6 @@ <h2 id="chanfig.configclasses.configclass" class="doc doc-heading">
<code>None</code>
</td>
</tr>
<tr class="doc-section-item">
<td><code>recursive</code></td>
<td>
<code><a class="autorefs autorefs-external" href="https://docs.python.org/3/library/functions.html#bool">bool</a></code>
</td>
<td>
<div class="doc-md-description">
<p>If True, recursively copy class attributes. Only applicable if used with parentheses.</p>
</div>
</td>
<td>
<code>False</code>
</td>
</tr>
</tbody>
</table>

Expand Down Expand Up @@ -1101,8 +1087,7 @@ <h2 id="chanfig.configclasses.configclass" class="doc doc-heading">

<details class="quote">
<summary>Source code in <code>chanfig/configclasses.py</code></summary>
<div class="highlight"><table class="highlighttable"><tr><th colspan="2" class="filename"><span class="filename">Python</span></th></tr><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-0-24">24</a></span>
<span class="normal"><a href="#__codelineno-0-25">25</a></span>
<div class="highlight"><table class="highlighttable"><tr><th colspan="2" class="filename"><span class="filename">Python</span></th></tr><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"><a href="#__codelineno-0-25">25</a></span>
<span class="normal"><a href="#__codelineno-0-26">26</a></span>
<span class="normal"><a href="#__codelineno-0-27">27</a></span>
<span class="normal"><a href="#__codelineno-0-28">28</a></span>
Expand Down Expand Up @@ -1148,22 +1133,17 @@ <h2 id="chanfig.configclasses.configclass" class="doc doc-heading">
<span class="normal"><a href="#__codelineno-0-68">68</a></span>
<span class="normal"><a href="#__codelineno-0-69">69</a></span>
<span class="normal"><a href="#__codelineno-0-70">70</a></span>
<span class="normal"><a href="#__codelineno-0-71">71</a></span>
<span class="normal"><a href="#__codelineno-0-72">72</a></span>
<span class="normal"><a href="#__codelineno-0-73">73</a></span>
<span class="normal"><a href="#__codelineno-0-74">74</a></span>
<span class="normal"><a href="#__codelineno-0-75">75</a></span></pre></div></td><td class="code"><div><pre><span></span><code><a id="__codelineno-0-24" name="__codelineno-0-24"></a><span class="k">def</span> <span class="nf">configclass</span><span class="p">(</span><span class="bp">cls</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">recursive</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">):</span>
<a id="__codelineno-0-25" name="__codelineno-0-25"></a><span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
<a id="__codelineno-0-26" name="__codelineno-0-26"></a><span class="sd"> Construct a Config in [`dataclass`][dataclasses.dataclass] style.</span>
<a id="__codelineno-0-27" name="__codelineno-0-27"></a>
<a id="__codelineno-0-28" name="__codelineno-0-28"></a><span class="sd"> This decorator creates a Config instance with the provided class attributes.</span>
<a id="__codelineno-0-29" name="__codelineno-0-29"></a>
<a id="__codelineno-0-30" name="__codelineno-0-30"></a><span class="sd"> See Also:</span>
<a id="__codelineno-0-31" name="__codelineno-0-31"></a><span class="sd"> [`dataclass`][dataclasses.dataclass]</span>
<a id="__codelineno-0-32" name="__codelineno-0-32"></a>
<a id="__codelineno-0-33" name="__codelineno-0-33"></a><span class="sd"> Args:</span>
<a id="__codelineno-0-34" name="__codelineno-0-34"></a><span class="sd"> cls (Type[Any]): The class to be enhanced, provided directly if no parentheses are used.</span>
<a id="__codelineno-0-35" name="__codelineno-0-35"></a><span class="sd"> recursive (bool): If True, recursively copy class attributes. Only applicable if used with parentheses.</span>
<span class="normal"><a href="#__codelineno-0-71">71</a></span></pre></div></td><td class="code"><div><pre><span></span><code><a id="__codelineno-0-25" name="__codelineno-0-25"></a><span class="k">def</span> <span class="nf">configclass</span><span class="p">(</span><span class="bp">cls</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
<a id="__codelineno-0-26" name="__codelineno-0-26"></a><span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
<a id="__codelineno-0-27" name="__codelineno-0-27"></a><span class="sd"> Construct a Config in [`dataclass`][dataclasses.dataclass] style.</span>
<a id="__codelineno-0-28" name="__codelineno-0-28"></a>
<a id="__codelineno-0-29" name="__codelineno-0-29"></a><span class="sd"> This decorator creates a Config instance with the provided class attributes.</span>
<a id="__codelineno-0-30" name="__codelineno-0-30"></a>
<a id="__codelineno-0-31" name="__codelineno-0-31"></a><span class="sd"> See Also:</span>
<a id="__codelineno-0-32" name="__codelineno-0-32"></a><span class="sd"> [`dataclass`][dataclasses.dataclass]</span>
<a id="__codelineno-0-33" name="__codelineno-0-33"></a>
<a id="__codelineno-0-34" name="__codelineno-0-34"></a><span class="sd"> Args:</span>
<a id="__codelineno-0-35" name="__codelineno-0-35"></a><span class="sd"> cls (Type[Any]): The class to be enhanced, provided directly if no parentheses are used.</span>
<a id="__codelineno-0-36" name="__codelineno-0-36"></a>
<a id="__codelineno-0-37" name="__codelineno-0-37"></a><span class="sd"> Returns:</span>
<a id="__codelineno-0-38" name="__codelineno-0-38"></a><span class="sd"> A modified class with Config functionalities or a decorator with bound parameters.</span>
Expand All @@ -1183,27 +1163,23 @@ <h2 id="chanfig.configclasses.configclass" class="doc doc-heading">
<a id="__codelineno-0-52" name="__codelineno-0-52"></a><span class="sd"> )</span>
<a id="__codelineno-0-53" name="__codelineno-0-53"></a><span class="sd"> &quot;&quot;&quot;</span>
<a id="__codelineno-0-54" name="__codelineno-0-54"></a>
<a id="__codelineno-0-55" name="__codelineno-0-55"></a> <span class="k">def</span> <span class="nf">decorator</span><span class="p">(</span><span class="bp">cls</span><span class="p">:</span> <span class="n">Type</span><span class="p">[</span><span class="n">Any</span><span class="p">]):</span>
<a id="__codelineno-0-56" name="__codelineno-0-56"></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">issubclass</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">Config</span><span class="p">):</span>
<a id="__codelineno-0-57" name="__codelineno-0-57"></a> <span class="n">config_cls</span> <span class="o">=</span> <span class="nb">type</span><span class="p">(</span><span class="bp">cls</span><span class="o">.</span><span class="vm">__name__</span><span class="p">,</span> <span class="p">(</span><span class="n">Config</span><span class="p">,</span> <span class="bp">cls</span><span class="p">),</span> <span class="nb">dict</span><span class="p">(</span><span class="bp">cls</span><span class="o">.</span><span class="vm">__dict__</span><span class="p">))</span>
<a id="__codelineno-0-58" name="__codelineno-0-58"></a> <span class="bp">cls</span> <span class="o">=</span> <span class="n">config_cls</span>
<a id="__codelineno-0-59" name="__codelineno-0-59"></a>
<a id="__codelineno-0-60" name="__codelineno-0-60"></a> <span class="n">cls_init</span> <span class="o">=</span> <span class="bp">cls</span><span class="o">.</span><span class="fm">__init__</span>
<a id="__codelineno-0-55" name="__codelineno-0-55"></a> <span class="n">warn</span><span class="p">(</span>
<a id="__codelineno-0-56" name="__codelineno-0-56"></a> <span class="s2">&quot;This decorator is deprecated and may be removed in the future release. &quot;</span>
<a id="__codelineno-0-57" name="__codelineno-0-57"></a> <span class="s2">&quot;All chanfig classes will copy variable identified in `__annotations__` by default.&quot;</span>
<a id="__codelineno-0-58" name="__codelineno-0-58"></a> <span class="s2">&quot;This decorator is equivalent to inheriting from `Config`.&quot;</span><span class="p">,</span>
<a id="__codelineno-0-59" name="__codelineno-0-59"></a> <span class="ne">PendingDeprecationWarning</span><span class="p">,</span>
<a id="__codelineno-0-60" name="__codelineno-0-60"></a> <span class="p">)</span>
<a id="__codelineno-0-61" name="__codelineno-0-61"></a>
<a id="__codelineno-0-62" name="__codelineno-0-62"></a> <span class="nd">@wraps</span><span class="p">(</span><span class="n">cls_init</span><span class="p">)</span>
<a id="__codelineno-0-63" name="__codelineno-0-63"></a> <span class="k">def</span> <span class="nf">init</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
<a id="__codelineno-0-64" name="__codelineno-0-64"></a> <span class="n">cls_init</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span>
<a id="__codelineno-0-65" name="__codelineno-0-65"></a> <span class="bp">self</span><span class="o">.</span><span class="n">copy_class_attributes</span><span class="p">(</span><span class="n">recursive</span><span class="o">=</span><span class="n">recursive</span><span class="p">)</span>
<a id="__codelineno-0-66" name="__codelineno-0-66"></a> <span class="bp">self</span><span class="o">.</span><span class="n">merge</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
<a id="__codelineno-0-67" name="__codelineno-0-67"></a>
<a id="__codelineno-0-68" name="__codelineno-0-68"></a> <span class="nb">setattr</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="s2">&quot;__init__&quot;</span><span class="p">,</span> <span class="n">init</span><span class="p">)</span> <span class="c1"># noqa: B010</span>
<a id="__codelineno-0-69" name="__codelineno-0-69"></a>
<a id="__codelineno-0-70" name="__codelineno-0-70"></a> <span class="k">return</span> <span class="bp">cls</span>
<a id="__codelineno-0-71" name="__codelineno-0-71"></a>
<a id="__codelineno-0-72" name="__codelineno-0-72"></a> <span class="k">if</span> <span class="bp">cls</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
<a id="__codelineno-0-73" name="__codelineno-0-73"></a> <span class="k">return</span> <span class="n">decorator</span>
<a id="__codelineno-0-74" name="__codelineno-0-74"></a> <span class="k">else</span><span class="p">:</span>
<a id="__codelineno-0-75" name="__codelineno-0-75"></a> <span class="k">return</span> <span class="n">decorator</span><span class="p">(</span><span class="bp">cls</span><span class="p">)</span>
<a id="__codelineno-0-62" name="__codelineno-0-62"></a> <span class="k">def</span> <span class="nf">decorator</span><span class="p">(</span><span class="bp">cls</span><span class="p">:</span> <span class="n">Type</span><span class="p">[</span><span class="n">Any</span><span class="p">]):</span>
<a id="__codelineno-0-63" name="__codelineno-0-63"></a> <span class="k">if</span> <span class="ow">not</span> <span class="nb">issubclass</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">Config</span><span class="p">):</span>
<a id="__codelineno-0-64" name="__codelineno-0-64"></a> <span class="n">config_cls</span> <span class="o">=</span> <span class="nb">type</span><span class="p">(</span><span class="bp">cls</span><span class="o">.</span><span class="vm">__name__</span><span class="p">,</span> <span class="p">(</span><span class="n">Config</span><span class="p">,</span> <span class="bp">cls</span><span class="p">),</span> <span class="nb">dict</span><span class="p">(</span><span class="bp">cls</span><span class="o">.</span><span class="vm">__dict__</span><span class="p">))</span>
<a id="__codelineno-0-65" name="__codelineno-0-65"></a> <span class="bp">cls</span> <span class="o">=</span> <span class="n">config_cls</span>
<a id="__codelineno-0-66" name="__codelineno-0-66"></a>
<a id="__codelineno-0-67" name="__codelineno-0-67"></a> <span class="k">return</span> <span class="bp">cls</span>
<a id="__codelineno-0-68" name="__codelineno-0-68"></a>
<a id="__codelineno-0-69" name="__codelineno-0-69"></a> <span class="k">if</span> <span class="bp">cls</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
<a id="__codelineno-0-70" name="__codelineno-0-70"></a> <span class="k">return</span> <span class="n">decorator</span>
<a id="__codelineno-0-71" name="__codelineno-0-71"></a> <span class="k">return</span> <span class="n">decorator</span><span class="p">(</span><span class="bp">cls</span><span class="p">)</span>
</code></pre></div></td></tr></table></div>
</details>
</div>
Expand Down
Loading

0 comments on commit d3e9ffe

Please sign in to comment.