Skip to content

Commit

Permalink
**CI** Formatted code + Updated version number and documentation. [sk…
Browse files Browse the repository at this point in the history
…ip ci]
  • Loading branch information
thorwhalen committed Aug 8, 2022
1 parent 4f29754 commit 5e4cb99
Show file tree
Hide file tree
Showing 52 changed files with 160 additions and 68 deletions.
2 changes: 1 addition & 1 deletion docs/.buildinfo
@@ -1,4 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: da189bbd59119d2f23d804cdc33896f5
config: 3d89b3397c789d64428282c809dc66dc
tags: 645f666f9bcd5a90fca523b33c5a78b7
2 changes: 1 addition & 1 deletion docs/_modules/dol.html
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>dol &mdash; dol 0.1.101 documentation</title><link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
<title>dol &mdash; dol 0.1.102 documentation</title><link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../_static/copybutton.css" type="text/css" />
<link rel="stylesheet" href="../_static/graphviz.css" type="text/css" />
Expand Down
2 changes: 1 addition & 1 deletion docs/_modules/dol/appendable.html
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>dol.appendable &mdash; dol 0.1.101 documentation</title><link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
<title>dol.appendable &mdash; dol 0.1.102 documentation</title><link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../../_static/copybutton.css" type="text/css" />
<link rel="stylesheet" href="../../_static/graphviz.css" type="text/css" />
Expand Down
2 changes: 1 addition & 1 deletion docs/_modules/dol/base.html
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>dol.base &mdash; dol 0.1.101 documentation</title><link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
<title>dol.base &mdash; dol 0.1.102 documentation</title><link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../../_static/copybutton.css" type="text/css" />
<link rel="stylesheet" href="../../_static/graphviz.css" type="text/css" />
Expand Down
2 changes: 1 addition & 1 deletion docs/_modules/dol/caching.html
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>dol.caching &mdash; dol 0.1.101 documentation</title><link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
<title>dol.caching &mdash; dol 0.1.102 documentation</title><link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../../_static/copybutton.css" type="text/css" />
<link rel="stylesheet" href="../../_static/graphviz.css" type="text/css" />
Expand Down
2 changes: 1 addition & 1 deletion docs/_modules/dol/core.html
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>dol.core &mdash; dol 0.1.101 documentation</title><link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
<title>dol.core &mdash; dol 0.1.102 documentation</title><link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../../_static/copybutton.css" type="text/css" />
<link rel="stylesheet" href="../../_static/graphviz.css" type="text/css" />
Expand Down
2 changes: 1 addition & 1 deletion docs/_modules/dol/dig.html
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>dol.dig &mdash; dol 0.1.101 documentation</title><link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
<title>dol.dig &mdash; dol 0.1.102 documentation</title><link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../../_static/copybutton.css" type="text/css" />
<link rel="stylesheet" href="../../_static/graphviz.css" type="text/css" />
Expand Down
2 changes: 1 addition & 1 deletion docs/_modules/dol/errors.html
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>dol.errors &mdash; dol 0.1.101 documentation</title><link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
<title>dol.errors &mdash; dol 0.1.102 documentation</title><link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../../_static/copybutton.css" type="text/css" />
<link rel="stylesheet" href="../../_static/graphviz.css" type="text/css" />
Expand Down
2 changes: 1 addition & 1 deletion docs/_modules/dol/explicit.html
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>dol.explicit &mdash; dol 0.1.101 documentation</title><link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
<title>dol.explicit &mdash; dol 0.1.102 documentation</title><link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../../_static/copybutton.css" type="text/css" />
<link rel="stylesheet" href="../../_static/graphviz.css" type="text/css" />
Expand Down
2 changes: 1 addition & 1 deletion docs/_modules/dol/filesys.html
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>dol.filesys &mdash; dol 0.1.101 documentation</title><link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
<title>dol.filesys &mdash; dol 0.1.102 documentation</title><link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../../_static/copybutton.css" type="text/css" />
<link rel="stylesheet" href="../../_static/graphviz.css" type="text/css" />
Expand Down
2 changes: 1 addition & 1 deletion docs/_modules/dol/mixins.html
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>dol.mixins &mdash; dol 0.1.101 documentation</title><link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
<title>dol.mixins &mdash; dol 0.1.102 documentation</title><link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../../_static/copybutton.css" type="text/css" />
<link rel="stylesheet" href="../../_static/graphviz.css" type="text/css" />
Expand Down
2 changes: 1 addition & 1 deletion docs/_modules/dol/naming.html
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>dol.naming &mdash; dol 0.1.101 documentation</title><link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
<title>dol.naming &mdash; dol 0.1.102 documentation</title><link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../../_static/copybutton.css" type="text/css" />
<link rel="stylesheet" href="../../_static/graphviz.css" type="text/css" />
Expand Down
2 changes: 1 addition & 1 deletion docs/_modules/dol/paths.html
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>dol.paths &mdash; dol 0.1.101 documentation</title><link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
<title>dol.paths &mdash; dol 0.1.102 documentation</title><link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../../_static/copybutton.css" type="text/css" />
<link rel="stylesheet" href="../../_static/graphviz.css" type="text/css" />
Expand Down
62 changes: 55 additions & 7 deletions docs/_modules/dol/signatures.html
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>dol.signatures &mdash; dol 0.1.101 documentation</title><link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
<title>dol.signatures &mdash; dol 0.1.102 documentation</title><link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../../_static/copybutton.css" type="text/css" />
<link rel="stylesheet" href="../../_static/graphviz.css" type="text/css" />
Expand Down Expand Up @@ -203,7 +203,7 @@ <h1>Source code for dol.signatures</h1><div class="highlight"><pre>
<span class="n">Parameter</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s1">&#39;param_kind&#39;</span><span class="p">,</span> <span class="n">kind</span><span class="o">=</span><span class="n">Parameter</span><span class="o">.</span><span class="n">POSITIONAL_OR_KEYWORD</span><span class="p">)</span>
<span class="p">)</span>
<span class="n">ParamsType</span> <span class="o">=</span> <span class="n">Iterable</span><span class="p">[</span><span class="n">Parameter</span><span class="p">]</span>
<span class="n">ParamsAble</span> <span class="o">=</span> <span class="n">Union</span><span class="p">[</span><span class="n">ParamsType</span><span class="p">,</span> <span class="n">MappingType</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">Parameter</span><span class="p">],</span> <span class="n">Callable</span><span class="p">,</span> <span class="nb">str</span><span class="p">]</span>
<span class="n">ParamsAble</span> <span class="o">=</span> <span class="n">Union</span><span class="p">[</span><span class="n">ParamsType</span><span class="p">,</span> <span class="n">Signature</span><span class="p">,</span> <span class="n">MappingType</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">Parameter</span><span class="p">],</span> <span class="n">Callable</span><span class="p">,</span> <span class="nb">str</span><span class="p">]</span>
<span class="n">SignatureAble</span> <span class="o">=</span> <span class="n">Union</span><span class="p">[</span><span class="n">Signature</span><span class="p">,</span> <span class="n">ParamsAble</span><span class="p">]</span>
<span class="n">HasParams</span> <span class="o">=</span> <span class="n">Union</span><span class="p">[</span><span class="n">Iterable</span><span class="p">[</span><span class="n">Parameter</span><span class="p">],</span> <span class="n">MappingType</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">Parameter</span><span class="p">],</span> <span class="n">Signature</span><span class="p">,</span> <span class="n">Callable</span><span class="p">]</span>

Expand Down Expand Up @@ -313,7 +313,7 @@ <h1>Source code for dol.signatures</h1><div class="highlight"><pre>
<span class="n">assure_callable</span> <span class="o">=</span> <span class="n">ensure_callable</span> <span class="c1"># alias for backcompatibility</span>


<span class="k">def</span> <span class="nf">ensure_signature</span><span class="p">(</span><span class="n">obj</span><span class="p">:</span> <span class="n">SignatureAble</span><span class="p">):</span>
<span class="k">def</span> <span class="nf">ensure_signature</span><span class="p">(</span><span class="n">obj</span><span class="p">:</span> <span class="n">SignatureAble</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Signature</span><span class="p">:</span>
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">obj</span><span class="p">,</span> <span class="n">Signature</span><span class="p">):</span>
<span class="k">return</span> <span class="n">obj</span>
<span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">obj</span><span class="p">,</span> <span class="n">Callable</span><span class="p">):</span>
Expand Down Expand Up @@ -3716,7 +3716,57 @@ <h1>Source code for dol.signatures</h1><div class="highlight"><pre>
<span class="c1"># Not returning func so it&#39;s clear(er) that the function is transformed in place</span>


<span class="c1">########################################################################################################################</span>
<span class="c1"># Pattern: (rewiring) wrapper of make_dataclass</span>
<span class="c1"># TODO: Is there a clean way for module to be populated by __name__ of caller module?</span>
<div class="viewcode-block" id="sig_to_dataclass"><a class="viewcode-back" href="../../module_docs/dol/signatures.html#dol.signatures.sig_to_dataclass">[docs]</a><span class="k">def</span> <span class="nf">sig_to_dataclass</span><span class="p">(</span>
<span class="n">sig</span><span class="p">:</span> <span class="n">SignatureAble</span><span class="p">,</span> <span class="o">*</span><span class="p">,</span> <span class="n">cls_name</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">bases</span><span class="o">=</span><span class="p">(),</span> <span class="n">module</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span>
<span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Make a ``class`` (through ``make_dataclass``) from the given signature.</span>

<span class="sd"> :param sig: A ``SignatureAble``, that is, anything that ensure_signature can</span>
<span class="sd"> resolve into an ``inspect.Signature`` object, including a signature object</span>
<span class="sd"> itself, but also most callables, a list or params, etc.</span>
<span class="sd"> :param cls_name: The same as ``cls_name`` of ``dataclasses.make_dataclass``</span>
<span class="sd"> :param bases: The same as ``bases`` of ``dataclasses.make_dataclass``</span>
<span class="sd"> :param module: Set to module (usually ``__name__`` to specify ther module of</span>
<span class="sd"> caller) so that the class and instances can be pickle-able.</span>
<span class="sd"> :param kwargs: Passed on to ``dataclasses.make_dataclass``</span>
<span class="sd"> :return: A dataclass</span>

<span class="sd"> &gt;&gt;&gt; def foo(a, /, b : int=2, *, c=3):</span>
<span class="sd"> ... pass</span>
<span class="sd"> ...</span>
<span class="sd"> &gt;&gt;&gt; K = sig_to_dataclass(foo, cls_name=&#39;K&#39;)</span>
<span class="sd"> &gt;&gt;&gt; str(Sig(K))</span>
<span class="sd"> &#39;(a, b: int = 2, c=3) -&gt; None&#39;</span>
<span class="sd"> &gt;&gt;&gt; k = K(1,2,3)</span>
<span class="sd"> &gt;&gt;&gt; (k.a, k.b, k.c)</span>
<span class="sd"> (1, 2, 3)</span>

<span class="sd"> Would also work with any of these (and more):</span>

<span class="sd"> &gt;&gt;&gt; K = sig_to_dataclass(Sig(foo), cls_name=&#39;K&#39;)</span>
<span class="sd"> &gt;&gt;&gt; K = sig_to_dataclass(Sig(foo).params, cls_name=&#39;K&#39;)</span>

<span class="sd"> Note: ``cls_name`` is not required (we&#39;ll try to figure out a good default for you),</span>
<span class="sd"> but it&#39;s advised to only use this convenience in extreme mode.</span>
<span class="sd"> Choosing your own name might make for a safer future if you&#39;re reusing your class.</span>

<span class="sd"> &quot;&quot;&quot;</span>
<span class="kn">from</span> <span class="nn">dataclasses</span> <span class="kn">import</span> <span class="n">make_dataclass</span>

<span class="n">sig</span> <span class="o">=</span> <span class="n">ensure_signature</span><span class="p">(</span><span class="n">sig</span><span class="p">)</span>
<span class="n">cls_name</span> <span class="o">=</span> <span class="n">cls_name</span> <span class="ow">or</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">sig</span><span class="p">,</span> <span class="s1">&#39;name&#39;</span><span class="p">,</span> <span class="s1">&#39;_made_by_sig_to_dataclass&#39;</span><span class="p">)</span>
<span class="n">params</span> <span class="o">=</span> <span class="n">ensure_params</span><span class="p">(</span><span class="n">sig</span><span class="p">)</span>
<span class="n">fields</span> <span class="o">=</span> <span class="p">[(</span><span class="n">p</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">p</span><span class="o">.</span><span class="n">annotation</span><span class="p">,</span> <span class="n">p</span><span class="o">.</span><span class="n">default</span><span class="p">)</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">params</span><span class="p">]</span>
<span class="bp">cls</span> <span class="o">=</span> <span class="n">make_dataclass</span><span class="p">(</span><span class="n">cls_name</span><span class="p">,</span> <span class="n">fields</span><span class="p">,</span> <span class="n">bases</span><span class="o">=</span><span class="n">bases</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
<span class="k">if</span> <span class="n">module</span><span class="p">:</span>
<span class="bp">cls</span><span class="o">.</span><span class="vm">__module__</span> <span class="o">=</span> <span class="n">module</span>
<span class="k">return</span> <span class="bp">cls</span></div>


<span class="c1">#########################################################################################</span>
<span class="c1"># Manual construction of missing signatures</span>
<span class="c1"># ############################################################################</span>

Expand Down Expand Up @@ -3810,9 +3860,7 @@ <h1>Source code for dol.signatures</h1><div class="highlight"><pre>
<span class="c1"># zip(*iterables) --&gt; A zip object yielding tuples until an input is exhausted.</span>
<span class="p">}</span>

<span class="c1">############# Tools for testing</span>
<span class="c1"># ########################################################################################</span>
<span class="kn">from</span> <span class="nn">functools</span> <span class="kn">import</span> <span class="n">partial</span>
<span class="c1">############# Tools for testing #########################################################</span>


<div class="viewcode-block" id="param_for_kind"><a class="viewcode-back" href="../../module_docs/dol/signatures.html#dol.signatures.param_for_kind">[docs]</a><span class="k">def</span> <span class="nf">param_for_kind</span><span class="p">(</span>
Expand Down
2 changes: 1 addition & 1 deletion docs/_modules/dol/sources.html
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>dol.sources &mdash; dol 0.1.101 documentation</title><link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
<title>dol.sources &mdash; dol 0.1.102 documentation</title><link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../../_static/copybutton.css" type="text/css" />
<link rel="stylesheet" href="../../_static/graphviz.css" type="text/css" />
Expand Down
2 changes: 1 addition & 1 deletion docs/_modules/dol/tests/base_test.html
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>dol.tests.base_test &mdash; dol 0.1.101 documentation</title><link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" />
<title>dol.tests.base_test &mdash; dol 0.1.102 documentation</title><link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../../../_static/copybutton.css" type="text/css" />
<link rel="stylesheet" href="../../../_static/graphviz.css" type="text/css" />
Expand Down

0 comments on commit 5e4cb99

Please sign in to comment.