pythonic-fp.iterables 5.2.0__py3-none-any.whl → 6.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -34,7 +34,9 @@
34
34
  """
35
35
 
36
36
  from collections.abc import Callable, Iterable, Iterator
37
+
37
38
  from pythonic_fp.gadgets.box import Box
39
+
38
40
  from .merging import concat
39
41
 
40
42
  __all__ = [
@@ -20,10 +20,13 @@
20
20
  """
21
21
 
22
22
  from collections.abc import Callable, Iterable, Iterator
23
- from typing import cast, Never
23
+ from typing import cast
24
+
24
25
  from pythonic_fp.fptools.function import negate, swap
25
26
  from pythonic_fp.fptools.maybe import MayBe
27
+ from pythonic_fp.fptools.recoverable import RECOVERABLE
26
28
  from pythonic_fp.gadgets.sentinels.novalue import NoValue
29
+
27
30
  from .drop_take import drop_while, take_while_split
28
31
 
29
32
  __all__ = [
@@ -34,10 +37,11 @@ __all__ = [
34
37
  'sc_reduce_left',
35
38
  'sc_reduce_right',
36
39
  ]
40
+ novalue = NoValue()
37
41
 
38
42
 
39
43
  def accumulate[D, L](
40
- iterable: Iterable[D], f: Callable[[L, D], L], initial: L | NoValue = NoValue()
44
+ iterable: Iterable[D], f: Callable[[L, D], L], initial: L | NoValue = novalue
41
45
  ) -> Iterator[L]:
42
46
  """
43
47
  .. admonition:: accumulate
@@ -83,7 +87,7 @@ def accumulate[D, L](
83
87
  yield acc
84
88
 
85
89
 
86
- def reduce_left[D](iterable: Iterable[D], f: Callable[[D, D], D]) -> D | Never:
90
+ def reduce_left[D](iterable: Iterable[D], f: Callable[[D, D], D]) -> D:
87
91
  """
88
92
  .. admonition:: reduce left
89
93
 
@@ -117,7 +121,7 @@ def reduce_left[D](iterable: Iterable[D], f: Callable[[D, D], D]) -> D | Never:
117
121
 
118
122
  def fold_left[D, L](
119
123
  iterable: Iterable[D], f: Callable[[L, D], L], initial: L
120
- ) -> L | Never:
124
+ ) -> L:
121
125
  """
122
126
  .. admonition:: fold left
123
127
 
@@ -146,8 +150,8 @@ def fold_left[D, L](
146
150
 
147
151
 
148
152
  def maybe_fold_left[D, L](
149
- iterable: Iterable[D], f: Callable[[L, D], L], initial: L | NoValue = NoValue()
150
- ) -> MayBe[L] | Never:
153
+ iterable: Iterable[D], f: Callable[[L, D], L], initial: L | NoValue = novalue
154
+ ) -> MayBe[L]:
151
155
  """
152
156
  .. admonition:: maybe fold left
153
157
 
@@ -181,7 +185,7 @@ def maybe_fold_left[D, L](
181
185
  for v in it:
182
186
  try:
183
187
  acc = f(acc, v)
184
- except Exception:
188
+ except RECOVERABLE:
185
189
  return MayBe()
186
190
 
187
191
  return MayBe(acc)
@@ -20,7 +20,7 @@
20
20
  """
21
21
 
22
22
  from collections.abc import Iterable, Iterator
23
- from enum import auto, Enum
23
+ from enum import Enum, auto
24
24
 
25
25
  __all__ = [
26
26
  'MergeEnum',
@@ -63,7 +63,7 @@ def concat[D](*iterables: Iterable[D]) -> Iterator[D]:
63
63
  Performant to the standard library's ``itertools.chain``.
64
64
 
65
65
  """
66
- for iterator in map(lambda x: iter(x), iterables):
66
+ for iterator in (iter(x) for x in iterables):
67
67
  while True:
68
68
  try:
69
69
  item = next(iterator)
@@ -93,7 +93,7 @@ def merge[D](*iterables: Iterable[D], yield_partials: bool = False) -> Iterator[
93
93
  iterators with external references.
94
94
 
95
95
  """
96
- iter_list = list(map(lambda x: iter(x), iterables))
96
+ iter_list = [iter(x) for x in iterables]
97
97
  items = []
98
98
  if (num_iters := len(iter_list)) > 0:
99
99
  while True:
@@ -119,7 +119,7 @@ def exhaust[D](*iterables: Iterable[D]) -> Iterator[D]:
119
119
  iterables are exhausted.
120
120
 
121
121
  """
122
- iter_list = list(map(lambda x: iter(x), iterables))
122
+ iter_list = [iter(x) for x in iterables]
123
123
  if (num_iters := len(iter_list)) > 0:
124
124
  ii = 0
125
125
  items = []
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pythonic-fp-iterables
3
- Version: 5.2.0
3
+ Version: 6.0.0
4
4
  Summary: Composing and iterating iterables.
5
5
  Keywords: iterables,iterators
6
6
  Author-email: "Geoffrey R. Scheller" <geoffrey@scheller.com>
7
7
  Requires-Python: >=3.14
8
8
  Description-Content-Type: text/markdown
9
- Classifier: Development Status :: 5 - Production/Stable
9
+ Classifier: Development Status :: 4 - Beta
10
10
  Classifier: Framework :: Pytest
11
11
  Classifier: Intended Audience :: Developers
12
12
  Classifier: License :: OSI Approved :: Apache Software License
@@ -15,11 +15,11 @@ Classifier: Programming Language :: Python :: 3.14
15
15
  Classifier: Programming Language :: Python :: 3.15
16
16
  Classifier: Typing :: Typed
17
17
  License-File: LICENSE
18
- Requires-Dist: pythonic-fp-fptools>=6,<6.2
19
- Requires-Dist: pythonic-fp-gadgets>=4.5,<6
18
+ Requires-Dist: pythonic-fp-fptools>=6.2,<7
19
+ Requires-Dist: pythonic-fp-gadgets>=6,<7
20
20
  Project-URL: Changelog, https://github.com/grscheller/pythonic-fp-iterables/blob/main/CHANGELOG.md
21
- Project-URL: Documentation, https://grscheller.github.io/pythonic-fp-iterables/release/html/
22
- Project-URL: Homepage, https://grscheller.github.io/pythonic-fp/
21
+ Project-URL: Documentation, https://grscheller.github.io/pythonic-fp-iterables
22
+ Project-URL: Homepage, https://grscheller.github.io/pythonic-fp
23
23
  Project-URL: Source, https://github.com/grscheller/pythonic-fp-iterables
24
24
 
25
25
  # Pythonic FP - Tools for iterables
@@ -29,13 +29,13 @@ Library of functions for iterating iterables.
29
29
  PyPI project
30
30
  [pythonic-fp-iterators](https://pypi.org/project/pythonic-fp-iterables).
31
31
  Part of the
32
- [pythonic-fp](https://grscheller.github.io/pythonic-fp/)
32
+ [pythonic-fp](https://grscheller.github.io/pythonic-fp)
33
33
  PyPI projects.
34
34
 
35
35
  ## Documentation
36
36
 
37
37
  Documentation and other links for this project are hosted on
38
- [GitHub Pages](https://grscheller.github.io/pythonic-fp/projects/iterables.html).
38
+ [GitHub Pages](https://grscheller.github.io/pythonic-fp-iterables).
39
39
 
40
40
  - Concatenating and merging iterables
41
41
  - Dropping and taking values from iterables
@@ -44,7 +44,7 @@ Documentation and other links for this project are hosted on
44
44
  - iterables are not necessarily iterators
45
45
  - at all times iterator protocol is assumed to be followed
46
46
  - all iterators are assumed to be iterable
47
- - for all iterators ``foo`` we assume ``iter(foo) is foo``
47
+ - for all iterators `foo` we assume `iter(foo)` is `foo`
48
48
 
49
49
  ## Copyright and License
50
50
 
@@ -0,0 +1,9 @@
1
+ pythonic_fp/iterables/__init__.py,sha256=lL6SETAAn9sn2dGRBxvbJlswZwweym4OumCKbJfokQI,1246
2
+ pythonic_fp/iterables/drop_take.py,sha256=OXvDpzxDWvCwUeaZaDY0-fgOKO8bGMczkzT2q1IRD7g,5529
3
+ pythonic_fp/iterables/folding.py,sha256=f1_2mLlTnUYl5xDtrn-xd6xeVyHare2lql7-rE8UakM,9422
4
+ pythonic_fp/iterables/merging.py,sha256=_tAfQM4_tq_wg5RdWxtFjeQ6uii0DC74NQjpDQq0Qgw,5011
5
+ pythonic_fp/iterables/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ pythonic_fp_iterables-6.0.0.dist-info/licenses/LICENSE,sha256=IJMkVWQUVy-SonK6SMaMotDQ6Zb-lVi2bUTiGp1GUO8,10774
7
+ pythonic_fp_iterables-6.0.0.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
8
+ pythonic_fp_iterables-6.0.0.dist-info/METADATA,sha256=9mOfNJcoVa0PePBSUh3158X-tJzrELq-WSgTz5VW5NM,1950
9
+ pythonic_fp_iterables-6.0.0.dist-info/RECORD,,
@@ -1,9 +0,0 @@
1
- pythonic_fp/iterables/__init__.py,sha256=lL6SETAAn9sn2dGRBxvbJlswZwweym4OumCKbJfokQI,1246
2
- pythonic_fp/iterables/drop_take.py,sha256=kZS8paCc-EOD42BGmCg-89e0W9CGFCXiB88Y4oE_lSg,5527
3
- pythonic_fp/iterables/folding.py,sha256=IZmoWyuh8D9rS_g9K8DhSu_owM1_IJ_oIMsLJNqH28I,9377
4
- pythonic_fp/iterables/merging.py,sha256=YYXrCNXHF9xuIMLOySTube6-_YUNB2GGirTa8VbpeLM,5038
5
- pythonic_fp/iterables/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
- pythonic_fp_iterables-5.2.0.dist-info/licenses/LICENSE,sha256=IJMkVWQUVy-SonK6SMaMotDQ6Zb-lVi2bUTiGp1GUO8,10774
7
- pythonic_fp_iterables-5.2.0.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
8
- pythonic_fp_iterables-5.2.0.dist-info/METADATA,sha256=yajE7AFhbVcOksI_nW2PdhDdURZjrRkRlpBfBAfiVdw,1997
9
- pythonic_fp_iterables-5.2.0.dist-info/RECORD,,