Skip to content

Commit 8c687e4

Browse files
committed
Version 0.5.2
Tried to make mypy less unhappy.
1 parent 90471da commit 8c687e4

File tree

26 files changed

+480
-353
lines changed

26 files changed

+480
-353
lines changed

conda/env.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,7 @@ dependencies:
1010
- conda-build
1111
- black
1212
- pip
13+
- lxml
14+
- mypy
1315
- pip:
1416
- strip-hints

conda/raffiot/meta.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{% set name = "raffiot" %}
2-
{% set version = "0.5.1" %}
2+
{% set version = "0.5.2" %}
33

44
package:
55
name: "{{ name|lower }}"

docs/api/index.html

Lines changed: 85 additions & 64 deletions
Large diffs are not rendered by default.

docs/api/io.html

Lines changed: 43 additions & 33 deletions
Large diffs are not rendered by default.

docs/api/resource.html

Lines changed: 90 additions & 52 deletions
Large diffs are not rendered by default.

docs/api/result.html

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ <h1 class="title">Module <code>raffiot.result</code></h1>
3535

3636
from collections import abc
3737
from dataclasses import dataclass
38-
from typing import TypeVar, Generic, Callable, Any, List, Iterable, Tuple
38+
from typing import TypeVar, Generic, Callable, Any, List, Iterable, Union
3939

4040
from typing_extensions import final
4141

@@ -146,7 +146,7 @@ <h1 class="title">Module <code>raffiot.result</code></h1>
146146
return on_error(self.errors)
147147
if isinstance(self, Panic):
148148
return on_panic(self.exceptions, self.errors)
149-
raise on_panic([MatchError(f&#34;{self} should be a Result&#34;)])
149+
raise on_panic([MatchError(f&#34;{self} should be a Result&#34;)], [])
150150

151151
@final
152152
@safe
@@ -220,7 +220,7 @@ <h1 class="title">Module <code>raffiot.result</code></h1>
220220
&#34;&#34;&#34;
221221
if isinstance(self, Ok):
222222
return f(self.success)
223-
return self
223+
return self # type: ignore
224224

225225
@final
226226
@safe
@@ -306,7 +306,7 @@ <h1 class="title">Module <code>raffiot.result</code></h1>
306306
&#34;&#34;&#34;
307307
if isinstance(self, Ok):
308308
return Ok(f(self.success))
309-
return self
309+
return self # type: ignore
310310

311311
@final
312312
@safe
@@ -319,15 +319,15 @@ <h1 class="title">Module <code>raffiot.result</code></h1>
319319
return self.unsafe_map(f)
320320

321321
@final
322-
def zip(self: Result[E, A], *arg: Result[E, X]) -&gt; Result[E, List[A]]:
322+
def zip(self: Result[E, A], *arg: Result[E, A]) -&gt; Result[E, List[A]]:
323323
&#34;&#34;&#34;
324324
Transform a list of Result (including self) into a Result of list.
325325

326326
Is Ok is all results are Ok.
327327
Is Errors some are Ok, but at least one is an errors but no panics.
328328
Is Panic is there is at least one panic.
329329
&#34;&#34;&#34;
330-
return zip((self, *arg))
330+
return zip((self, *arg)) # type: ignore
331331

332332
@final
333333
def unsafe_ap(
@@ -340,7 +340,7 @@ <h1 class="title">Module <code>raffiot.result</code></h1>
340340
and arg represent a computation returning a value `x1: X1`,...,`xn: Xn`, then
341341
`self.ap(arg)` represents the computation returning `f(x1,...,xn): A`.
342342
&#34;&#34;&#34;
343-
return zip((self, *arg)).unsafe_map(lambda l: l[0](*l[1:]))
343+
return zip((self, *arg)).unsafe_map(lambda l: l[0](*l[1:])) # type: ignore
344344

345345
@final
346346
@safe
@@ -352,7 +352,7 @@ <h1 class="title">Module <code>raffiot.result</code></h1>
352352
and arg represent computations returning values `x1: X1`,...,`xn: Xn` then
353353
`self.ap(arg)` represents the computation returning `f(x1,...,xn): A`.
354354
&#34;&#34;&#34;
355-
return self.unsafe_ap(*arg)
355+
return self.unsafe_ap(*arg) # type: ignore
356356

357357
@final
358358
def flatten(self: Result[E, Result[E, A]]) -&gt; Result[E, A]:
@@ -361,7 +361,7 @@ <h1 class="title">Module <code>raffiot.result</code></h1>
361361
&#34;&#34;&#34;
362362
if isinstance(self, Ok):
363363
return self.success
364-
return self
364+
return self # type: ignore
365365

366366
@final
367367
def unsafe_map_error(self, f: Callable[[E], E2]) -&gt; Result[E2, A]:
@@ -398,7 +398,7 @@ <h1 class="title">Module <code>raffiot.result</code></h1>
398398

399399
@final
400400
@safe
401-
def catch(self, handler: Callable[[E], Result[List[E], A]]) -&gt; Result[E, A]:
401+
def catch(self, handler: Callable[[List[E]], Result[E, A]]) -&gt; Result[E, A]:
402402
&#34;&#34;&#34;
403403
React to errors (the except part of a try-except).
404404

@@ -579,7 +579,7 @@ <h1 class="title">Module <code>raffiot.result</code></h1>
579579
return Panic(exceptions=list(exceptions), errors=list(errors) if errors else [])
580580

581581

582-
def zip(*l: Iterable[Result[E, A]]) -&gt; Result[E, List[A]]:
582+
def zip(*l: Result[E, A]) -&gt; Result[E, List[A]]:
583583
&#34;&#34;&#34;
584584
Combine a list of `Result`.
585585

@@ -618,7 +618,7 @@ <h1 class="title">Module <code>raffiot.result</code></h1>
618618
return Ok(values)
619619

620620

621-
def sequence(*l: Iterable[Result[E, A]]) -&gt; Result[List[E], A]:
621+
def sequence(*l: Union[Iterable[Result[E, A]], Result[E, A]]) -&gt; Result[E, A]:
622622
&#34;&#34;&#34;
623623
Combine a list of `Result`.
624624

@@ -632,7 +632,7 @@ <h1 class="title">Module <code>raffiot.result</code></h1>
632632
else:
633633
args = l
634634

635-
value = None
635+
value: A = None
636636
errs = []
637637
exceptions = []
638638

@@ -859,7 +859,7 @@ <h2 class="section-title" id="header-functions">Functions</h2>
859859
</details>
860860
</dd>
861861
<dt id="raffiot.result.sequence"><code class="name flex">
862-
<span>def <span class="ident">sequence</span></span>(<span>*l: Iterable[<a title="raffiot.result.Result" href="#raffiot.result.Result">Result</a>[E, A]]) ‑> <a title="raffiot.result.Result" href="#raffiot.result.Result">Result</a>[typing.List[~E], ~A]</span>
862+
<span>def <span class="ident">sequence</span></span>(<span>*l: Union[Iterable[<a title="raffiot.result.Result" href="#raffiot.result.Result">Result</a>[E, A]]<a title="raffiot.result.Result" href="#raffiot.result.Result">Result</a>[E, A]]) ‑> <a title="raffiot.result.Result" href="#raffiot.result.Result">Result</a>[~E, ~A]</span>
863863
</code></dt>
864864
<dd>
865865
<div class="desc"><p>Combine a list of <code><a title="raffiot.result.Result" href="#raffiot.result.Result">Result</a></code>.</p>
@@ -871,7 +871,7 @@ <h2 class="section-title" id="header-functions">Functions</h2>
871871
<summary>
872872
<span>Expand source code</span>
873873
</summary>
874-
<pre><code class="python">def sequence(*l: Iterable[Result[E, A]]) -&gt; Result[List[E], A]:
874+
<pre><code class="python">def sequence(*l: Union[Iterable[Result[E, A]], Result[E, A]]) -&gt; Result[E, A]:
875875
&#34;&#34;&#34;
876876
Combine a list of `Result`.
877877

@@ -885,7 +885,7 @@ <h2 class="section-title" id="header-functions">Functions</h2>
885885
else:
886886
args = l
887887

888-
value = None
888+
value: A = None
889889
errs = []
890890
exceptions = []
891891

@@ -945,7 +945,7 @@ <h2 class="section-title" id="header-functions">Functions</h2>
945945
</details>
946946
</dd>
947947
<dt id="raffiot.result.zip"><code class="name flex">
948-
<span>def <span class="ident">zip</span></span>(<span>*l: Iterable[<a title="raffiot.result.Result" href="#raffiot.result.Result">Result</a>[E, A]]) ‑> <a title="raffiot.result.Result" href="#raffiot.result.Result">Result</a>[~E, typing.List[~A]]</span>
948+
<span>def <span class="ident">zip</span></span>(<span>*l: <a title="raffiot.result.Result" href="#raffiot.result.Result">Result</a>[E, A]) ‑> <a title="raffiot.result.Result" href="#raffiot.result.Result">Result</a>[~E, typing.List[~A]]</span>
949949
</code></dt>
950950
<dd>
951951
<div class="desc"><p>Combine a list of <code><a title="raffiot.result.Result" href="#raffiot.result.Result">Result</a></code>.</p>
@@ -959,7 +959,7 @@ <h2 class="section-title" id="header-functions">Functions</h2>
959959
<summary>
960960
<span>Expand source code</span>
961961
</summary>
962-
<pre><code class="python">def zip(*l: Iterable[Result[E, A]]) -&gt; Result[E, List[A]]:
962+
<pre><code class="python">def zip(*l: Result[E, A]) -&gt; Result[E, List[A]]:
963963
&#34;&#34;&#34;
964964
Combine a list of `Result`.
965965

@@ -1279,7 +1279,7 @@ <h3>Inherited members</h3>
12791279
return on_error(self.errors)
12801280
if isinstance(self, Panic):
12811281
return on_panic(self.exceptions, self.errors)
1282-
raise on_panic([MatchError(f&#34;{self} should be a Result&#34;)])
1282+
raise on_panic([MatchError(f&#34;{self} should be a Result&#34;)], [])
12831283

12841284
@final
12851285
@safe
@@ -1353,7 +1353,7 @@ <h3>Inherited members</h3>
13531353
&#34;&#34;&#34;
13541354
if isinstance(self, Ok):
13551355
return f(self.success)
1356-
return self
1356+
return self # type: ignore
13571357

13581358
@final
13591359
@safe
@@ -1439,7 +1439,7 @@ <h3>Inherited members</h3>
14391439
&#34;&#34;&#34;
14401440
if isinstance(self, Ok):
14411441
return Ok(f(self.success))
1442-
return self
1442+
return self # type: ignore
14431443

14441444
@final
14451445
@safe
@@ -1452,15 +1452,15 @@ <h3>Inherited members</h3>
14521452
return self.unsafe_map(f)
14531453

14541454
@final
1455-
def zip(self: Result[E, A], *arg: Result[E, X]) -&gt; Result[E, List[A]]:
1455+
def zip(self: Result[E, A], *arg: Result[E, A]) -&gt; Result[E, List[A]]:
14561456
&#34;&#34;&#34;
14571457
Transform a list of Result (including self) into a Result of list.
14581458

14591459
Is Ok is all results are Ok.
14601460
Is Errors some are Ok, but at least one is an errors but no panics.
14611461
Is Panic is there is at least one panic.
14621462
&#34;&#34;&#34;
1463-
return zip((self, *arg))
1463+
return zip((self, *arg)) # type: ignore
14641464

14651465
@final
14661466
def unsafe_ap(
@@ -1473,7 +1473,7 @@ <h3>Inherited members</h3>
14731473
and arg represent a computation returning a value `x1: X1`,...,`xn: Xn`, then
14741474
`self.ap(arg)` represents the computation returning `f(x1,...,xn): A`.
14751475
&#34;&#34;&#34;
1476-
return zip((self, *arg)).unsafe_map(lambda l: l[0](*l[1:]))
1476+
return zip((self, *arg)).unsafe_map(lambda l: l[0](*l[1:])) # type: ignore
14771477

14781478
@final
14791479
@safe
@@ -1485,7 +1485,7 @@ <h3>Inherited members</h3>
14851485
and arg represent computations returning values `x1: X1`,...,`xn: Xn` then
14861486
`self.ap(arg)` represents the computation returning `f(x1,...,xn): A`.
14871487
&#34;&#34;&#34;
1488-
return self.unsafe_ap(*arg)
1488+
return self.unsafe_ap(*arg) # type: ignore
14891489

14901490
@final
14911491
def flatten(self: Result[E, Result[E, A]]) -&gt; Result[E, A]:
@@ -1494,7 +1494,7 @@ <h3>Inherited members</h3>
14941494
&#34;&#34;&#34;
14951495
if isinstance(self, Ok):
14961496
return self.success
1497-
return self
1497+
return self # type: ignore
14981498

14991499
@final
15001500
def unsafe_map_error(self, f: Callable[[E], E2]) -&gt; Result[E2, A]:
@@ -1531,7 +1531,7 @@ <h3>Inherited members</h3>
15311531

15321532
@final
15331533
@safe
1534-
def catch(self, handler: Callable[[E], Result[List[E], A]]) -&gt; Result[E, A]:
1534+
def catch(self, handler: Callable[[List[E]], Result[E, A]]) -&gt; Result[E, A]:
15351535
&#34;&#34;&#34;
15361536
React to errors (the except part of a try-except).
15371537

@@ -1698,7 +1698,7 @@ <h3>Methods</h3>
16981698
&#34;&#34;&#34;
16991699
if isinstance(self, Ok):
17001700
return self.success
1701-
return self</code></pre>
1701+
return self # type: ignore</code></pre>
17021702
</details>
17031703
</dd>
17041704
<dt id="raffiot.result.Result.fold"><code class="name flex">
@@ -1932,7 +1932,7 @@ <h3>Methods</h3>
19321932
and arg represent a computation returning a value `x1: X1`,...,`xn: Xn`, then
19331933
`self.ap(arg)` represents the computation returning `f(x1,...,xn): A`.
19341934
&#34;&#34;&#34;
1935-
return zip((self, *arg)).unsafe_map(lambda l: l[0](*l[1:]))</code></pre>
1935+
return zip((self, *arg)).unsafe_map(lambda l: l[0](*l[1:])) # type: ignore</code></pre>
19361936
</details>
19371937
</dd>
19381938
<dt id="raffiot.result.Result.unsafe_catch"><code class="name flex">
@@ -1991,7 +1991,7 @@ <h3>Methods</h3>
19911991
&#34;&#34;&#34;
19921992
if isinstance(self, Ok):
19931993
return f(self.success)
1994-
return self</code></pre>
1994+
return self # type: ignore</code></pre>
19951995
</details>
19961996
</dd>
19971997
<dt id="raffiot.result.Result.unsafe_fold"><code class="name flex">
@@ -2027,7 +2027,7 @@ <h3>Methods</h3>
20272027
return on_error(self.errors)
20282028
if isinstance(self, Panic):
20292029
return on_panic(self.exceptions, self.errors)
2030-
raise on_panic([MatchError(f&#34;{self} should be a Result&#34;)])</code></pre>
2030+
raise on_panic([MatchError(f&#34;{self} should be a Result&#34;)], [])</code></pre>
20312031
</details>
20322032
</dd>
20332033
<dt id="raffiot.result.Result.unsafe_fold_raise"><code class="name flex">
@@ -2115,7 +2115,7 @@ <h3>Methods</h3>
21152115
&#34;&#34;&#34;
21162116
if isinstance(self, Ok):
21172117
return Ok(f(self.success))
2118-
return self</code></pre>
2118+
return self # type: ignore</code></pre>
21192119
</details>
21202120
</dd>
21212121
<dt id="raffiot.result.Result.unsafe_map_error"><code class="name flex">
@@ -2221,7 +2221,7 @@ <h3>Methods</h3>
22212221
</details>
22222222
</dd>
22232223
<dt id="raffiot.result.Result.zip"><code class="name flex">
2224-
<span>def <span class="ident">zip</span></span>(<span>self: <a title="raffiot.result.Result" href="#raffiot.result.Result">Result</a>[E, A], *arg: <a title="raffiot.result.Result" href="#raffiot.result.Result">Result</a>[E, X]) ‑> <a title="raffiot.result.Result" href="#raffiot.result.Result">Result</a>[~E, typing.List[~A]]</span>
2224+
<span>def <span class="ident">zip</span></span>(<span>self: <a title="raffiot.result.Result" href="#raffiot.result.Result">Result</a>[E, A], *arg: <a title="raffiot.result.Result" href="#raffiot.result.Result">Result</a>[E, A]) ‑> <a title="raffiot.result.Result" href="#raffiot.result.Result">Result</a>[~E, typing.List[~A]]</span>
22252225
</code></dt>
22262226
<dd>
22272227
<div class="desc"><p>Transform a list of Result (including self) into a Result of list.</p>
@@ -2233,15 +2233,15 @@ <h3>Methods</h3>
22332233
<span>Expand source code</span>
22342234
</summary>
22352235
<pre><code class="python">@final
2236-
def zip(self: Result[E, A], *arg: Result[E, X]) -&gt; Result[E, List[A]]:
2236+
def zip(self: Result[E, A], *arg: Result[E, A]) -&gt; Result[E, List[A]]:
22372237
&#34;&#34;&#34;
22382238
Transform a list of Result (including self) into a Result of list.
22392239

22402240
Is Ok is all results are Ok.
22412241
Is Errors some are Ok, but at least one is an errors but no panics.
22422242
Is Panic is there is at least one panic.
22432243
&#34;&#34;&#34;
2244-
return zip((self, *arg))</code></pre>
2244+
return zip((self, *arg)) # type: ignore</code></pre>
22452245
</details>
22462246
</dd>
22472247
</dl>

0 commit comments

Comments
 (0)