pythonic-fp.containers 4.1.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.
@@ -14,9 +14,10 @@
14
14
  # limitations under the License.
15
15
 
16
16
  from collections.abc import Callable, Iterator
17
- from typing import cast, Never, overload, SupportsIndex
17
+ from typing import SupportsIndex, cast, overload
18
+
18
19
  from pythonic_fp.iterables.folding import accumulate
19
- from pythonic_fp.iterables.merging import blend, concat, MergeEnum
20
+ from pythonic_fp.iterables.merging import MergeEnum, blend, concat
20
21
 
21
22
  __all__ = ['FTuple']
22
23
 
@@ -158,7 +159,7 @@ class FTuple[D](tuple[D, ...]):
158
159
  acc = f(v, acc)
159
160
  return acc
160
161
 
161
- def copy(self) -> 'FTuple[D]':
162
+ def copy(self) -> FTuple[D]:
162
163
  """
163
164
  .. admonition:: copy
164
165
 
@@ -173,7 +174,13 @@ class FTuple[D](tuple[D, ...]):
173
174
  def __add__(self, other: object, /) -> tuple[D, ...]:
174
175
  if not isinstance(other, tuple):
175
176
  msg = 'FTuple being added to something not an FTuple'
176
- raise ValueError(msg)
177
+ raise TypeError(msg)
178
+ return self.__class__(concat(self, other))
179
+
180
+ def __radd__(self, other: object, /) -> tuple[D, ...]:
181
+ if not isinstance(other, tuple):
182
+ msg = 'FTuple being added to something not an FTuple'
183
+ raise TypeError(msg)
177
184
  return self.__class__(concat(self, other))
178
185
 
179
186
  def __mul__(self, num: SupportsIndex) -> tuple[D, ...]:
@@ -184,7 +191,7 @@ class FTuple[D](tuple[D, ...]):
184
191
 
185
192
  def accummulate[L](
186
193
  self, f: Callable[[L, D], L], s: L | None = None, /
187
- ) -> 'FTuple[L]':
194
+ ) -> FTuple[L]:
188
195
  """
189
196
  .. admonition:: accumulate partial folds
190
197
 
@@ -197,7 +204,7 @@ class FTuple[D](tuple[D, ...]):
197
204
  return FTuple(accumulate(self, f))
198
205
  return FTuple(accumulate(self, f, s))
199
206
 
200
- def map[U](self, f: Callable[[D], U], /) -> 'FTuple[U]':
207
+ def map[U](self, f: Callable[[D], U], /) -> FTuple[U]:
201
208
  """
202
209
  .. admonition:: map
203
210
 
@@ -209,10 +216,10 @@ class FTuple[D](tuple[D, ...]):
209
216
 
210
217
  def bind[U](
211
218
  self,
212
- f: 'Callable[[D], FTuple[U]]',
219
+ f: Callable[[D], FTuple[U]],
213
220
  merge_type: MergeEnum = MergeEnum.Concat,
214
221
  yield_partials: bool = False,
215
- ) -> 'FTuple[U] | Never':
222
+ ) -> FTuple[U]:
216
223
  """
217
224
  .. admonition:: bind
218
225
 
@@ -12,10 +12,11 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- from collections.abc import Callable, Iterable, Iterator, Hashable
16
- from typing import cast, Never, overload
15
+ from collections.abc import Callable, Hashable, Iterable, Iterator
16
+ from typing import cast, overload
17
+
17
18
  from pythonic_fp.iterables.folding import accumulate
18
- from pythonic_fp.iterables.merging import blend, concat, MergeEnum
19
+ from pythonic_fp.iterables.merging import MergeEnum, blend, concat
19
20
 
20
21
  __all__ = ['IList']
21
22
 
@@ -34,7 +35,7 @@ class IList[D](Hashable):
34
35
 
35
36
  """
36
37
 
37
- __slots__ = ('_ds', '_len', '_hash')
38
+ __slots__ = ('_ds', '_hash', '_len')
38
39
  __match_args__ = ('_ds', '_len')
39
40
 
40
41
  def __init__(self, *ds: Iterable[D]) -> None:
@@ -48,7 +49,7 @@ class IList[D](Hashable):
48
49
  msg = f'IList expects at most 1 iterable argument, got {size}'
49
50
  raise ValueError(msg)
50
51
  else:
51
- self._ds: tuple[D, ...] = tuple(ds[0]) if size == 1 else tuple()
52
+ self._ds: tuple[D, ...] = tuple(ds[0]) if size == 1 else ()
52
53
  self._len = len(self._ds)
53
54
  try:
54
55
  self._hash = hash((self._len, 42) + self._ds)
@@ -118,9 +119,9 @@ class IList[D](Hashable):
118
119
  @overload
119
120
  def __getitem__(self, idx: int, /) -> D: ...
120
121
  @overload
121
- def __getitem__(self, idx: slice, /) -> 'IList[D]': ...
122
+ def __getitem__(self, idx: slice, /) -> IList[D]: ...
122
123
 
123
- def __getitem__(self, idx: slice | int, /) -> 'IList[D] | D':
124
+ def __getitem__(self, idx: slice | int, /) -> IList[D] | D:
124
125
  """
125
126
  .. admonition:: getitem
126
127
 
@@ -222,7 +223,7 @@ class IList[D](Hashable):
222
223
  acc = f(v, acc)
223
224
  return acc
224
225
 
225
- def __add__(self, other: 'IList[D]', /) -> 'IList[D]':
226
+ def __add__(self, other: IList[D], /) -> IList[D]:
226
227
  """
227
228
  .. admonition:: add by concatenation
228
229
 
@@ -237,11 +238,11 @@ class IList[D](Hashable):
237
238
  """
238
239
  if not isinstance(other, IList):
239
240
  msg = 'IList being added to something not an IList'
240
- raise ValueError(msg)
241
+ raise TypeError(msg)
241
242
 
242
243
  return IList(concat(self, other))
243
244
 
244
- def __mul__(self, num: int, /) -> 'IList[D]':
245
+ def __mul__(self, num: int, /) -> IList[D]:
245
246
  """
246
247
  .. admonition:: add by concatenation
247
248
 
@@ -255,9 +256,9 @@ class IList[D](Hashable):
255
256
  Maybe define a "column vector" version?
256
257
 
257
258
  """
258
- return IList(self._ds.__mul__(num if num > 0 else 0))
259
+ return IList(self._ds.__mul__(max(0, num)))
259
260
 
260
- def __rmul__(self, num: int, /) -> 'IList[D]':
261
+ def __rmul__(self, num: int, /) -> IList[D]:
261
262
  """
262
263
  .. admonition:: concatenation with itself
263
264
 
@@ -267,11 +268,11 @@ class IList[D](Hashable):
267
268
  :raises ValueError: When ``other`` is not an ``IList``.
268
269
 
269
270
  """
270
- return IList(self._ds.__mul__(num if num > 0 else 0))
271
+ return IList(self._ds.__mul__(max(0, num)))
271
272
 
272
273
  def accummulate[L](
273
274
  self, f: Callable[[L, D], L], s: L | None = None, /
274
- ) -> 'IList[L]':
275
+ ) -> IList[L]:
275
276
  """
276
277
  .. admonition:: accumulate partial folds
277
278
 
@@ -287,7 +288,7 @@ class IList[D](Hashable):
287
288
  return IList(accumulate(self, f))
288
289
  return IList(accumulate(self, f, s))
289
290
 
290
- def map[U](self, f: Callable[[D], U], /) -> 'IList[U]':
291
+ def map[U](self, f: Callable[[D], U], /) -> IList[U]:
291
292
  """
292
293
  .. admonition:: map
293
294
 
@@ -299,10 +300,10 @@ class IList[D](Hashable):
299
300
 
300
301
  def bind[U](
301
302
  self,
302
- f: 'Callable[[D], IList[U]]',
303
+ f: Callable[[D], IList[U]],
303
304
  merge_enum: MergeEnum = MergeEnum.Concat,
304
305
  yield_partials: bool = False,
305
- ) -> 'IList[U] | Never':
306
+ ) -> IList[U]:
306
307
  """
307
308
  .. admonition:: bind
308
309
 
@@ -0,0 +1,51 @@
1
+ Metadata-Version: 2.4
2
+ Name: pythonic-fp-containers
3
+ Version: 6.0.0
4
+ Summary: Containers with FP interfaces.
5
+ Keywords: functional_containers,functional_tuple,immutable_list
6
+ Author-email: "Geoffrey R. Scheller" <geoffrey@scheller.com>
7
+ Requires-Python: >=3.14
8
+ Description-Content-Type: text/markdown
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Framework :: Pytest
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: Apache Software License
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3.14
15
+ Classifier: Programming Language :: Python :: 3.15
16
+ Classifier: Typing :: Typed
17
+ License-File: LICENSE
18
+ Requires-Dist: pythonic-fp-circulararray>=6.4,<7
19
+ Requires-Dist: pythonic-fp-fptools>=6.2,<7
20
+ Requires-Dist: pythonic-fp-iterables>=6,<7
21
+ Project-URL: Changelog, https://github.com/grscheller/pythonic-fp-containers/blob/main/CHANGELOG.md
22
+ Project-URL: Documentation, https://grscheller.github.io/pythonic-fp-containers
23
+ Project-URL: Homepage, https://grscheller.github.io/pythonic-fp
24
+ Project-URL: Source, https://github.com/grscheller/pythonic-fp-containers
25
+
26
+ # Pythonic FP - Containers
27
+
28
+ Python package for containers of like data structures with functional
29
+ programming inspired tweaks.
30
+
31
+ PyPI project
32
+ [pythonic-fp-containers](https://pypi.org/project/pythonic-fp-containers).
33
+ Part of the
34
+ [pythonic-fp](https://grscheller.github.io/pythonic-fp)
35
+ PyPI projects.
36
+
37
+ ## Documentation
38
+
39
+ Documentation and other links for this project are hosted on
40
+ [GitHub Pages](https://grscheller.github.io/pythonic-fp-containers).
41
+
42
+ | module | class | name |
43
+ |:------ |:-----:|:---- |
44
+ | pythonic_fp.containers.functional_tuple | FTuple | Functional Tuple |
45
+ | pythonic_fp.containers.immutable_list | IList | Immutable List |
46
+
47
+ ## Copyright and License
48
+
49
+ Copyright (c) 2023-2026 Geoffrey R. Scheller. Licensed under the Apache
50
+ License, Version 2.0. See the LICENSE file for details.
51
+
@@ -0,0 +1,8 @@
1
+ pythonic_fp/containers/__init__.py,sha256=J1UvKHza0iDCR1GrVSUeps5LHsPc56xISvkbnGXOJtA,1034
2
+ pythonic_fp/containers/functional_tuple.py,sha256=tIfCjildvY-WZctFq-zpwHABbUnHffoo7aw6lZY8BIk,7724
3
+ pythonic_fp/containers/immutable_list.py,sha256=9IJfUQ0dqOzNQ5U06acN69kyl5qaUl5upeHdYhjEWBg,9736
4
+ pythonic_fp/containers/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ pythonic_fp_containers-6.0.0.dist-info/licenses/LICENSE,sha256=IJMkVWQUVy-SonK6SMaMotDQ6Zb-lVi2bUTiGp1GUO8,10774
6
+ pythonic_fp_containers-6.0.0.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
7
+ pythonic_fp_containers-6.0.0.dist-info/METADATA,sha256=IX9TGjaaRMa1iCdugL1JI5HxSZG7pEasS9vun0r6Ie8,1927
8
+ pythonic_fp_containers-6.0.0.dist-info/RECORD,,
File without changes
@@ -1,22 +0,0 @@
1
- from collections.abc import Callable, Iterator
2
- from pythonic_fp.iterables.merging import MergeEnum
3
- from typing import Never, SupportsIndex, overload
4
-
5
- __all__ = ['FTuple']
6
-
7
- class FTuple[D](tuple[D, ...]):
8
- def __reversed__(self) -> Iterator[D]: ...
9
- def __eq__(self, other: object) -> bool: ...
10
- @overload
11
- def __getitem__(self, idx: SupportsIndex) -> D: ...
12
- @overload
13
- def __getitem__(self, idx: slice) -> tuple[D, ...]: ...
14
- def foldl[L](self, f: Callable[[L, D], L], /, start: L | None = None, default: L | None = None) -> L: ...
15
- def foldr[R](self, f: Callable[[D, R], R], /, start: R | None = None, default: R | None = None) -> R: ...
16
- def copy(self) -> FTuple[D]: ...
17
- def __add__(self, other: object) -> tuple[D, ...]: ...
18
- def __mul__(self, num: SupportsIndex) -> tuple[D, ...]: ...
19
- def __rmul__(self, num: SupportsIndex) -> tuple[D, ...]: ...
20
- def accummulate[L](self, f: Callable[[L, D], L], s: L | None = None, /) -> FTuple[L]: ...
21
- def map[U](self, f: Callable[[D], U], /) -> FTuple[U]: ...
22
- def bind[U](self, f: Callable[[D], FTuple[U]], merge_type: MergeEnum = ..., yield_partials: bool = False) -> FTuple[U] | Never: ...
@@ -1,28 +0,0 @@
1
- from _typeshed import Incomplete
2
- from collections.abc import Callable, Hashable, Iterable, Iterator
3
- from pythonic_fp.iterables.merging import MergeEnum
4
- from typing import Never, overload
5
-
6
- __all__ = ['IList']
7
-
8
- class IList[D](Hashable):
9
- __match_args__: Incomplete
10
- def __init__(self, *ds: Iterable[D]) -> None: ...
11
- def __hash__(self) -> int: ...
12
- def __iter__(self) -> Iterator[D]: ...
13
- def __reversed__(self) -> Iterator[D]: ...
14
- def __bool__(self) -> bool: ...
15
- def __len__(self) -> int: ...
16
- def __eq__(self, other: object) -> bool: ...
17
- @overload
18
- def __getitem__(self, idx: int) -> D: ...
19
- @overload
20
- def __getitem__(self, idx: slice) -> IList[D]: ...
21
- def foldl[L](self, f: Callable[[L, D], L], /, start: L | None = None, default: L | None = None) -> L | None: ...
22
- def foldr[R](self, f: Callable[[D, R], R], /, start: R | None = None, default: R | None = None) -> R | None: ...
23
- def __add__(self, other: IList[D]) -> IList[D]: ...
24
- def __mul__(self, num: int) -> IList[D]: ...
25
- def __rmul__(self, num: int) -> IList[D]: ...
26
- def accummulate[L](self, f: Callable[[L, D], L], s: L | None = None, /) -> IList[L]: ...
27
- def map[U](self, f: Callable[[D], U], /) -> IList[U]: ...
28
- def bind[U](self, f: Callable[[D], IList[U]], merge_enum: MergeEnum = ..., yield_partials: bool = False) -> IList[U] | Never: ...
@@ -1,62 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: pythonic-fp-containers
3
- Version: 4.1.0
4
- Summary: Containers with FP interfaces
5
- Keywords: functional_containers,functional_tuple,immutable_list
6
- Author-email: "Geoffrey R. Scheller" <geoffrey@scheller.com>
7
- Requires-Python: >=3.13
8
- Description-Content-Type: text/x-rst
9
- Classifier: Development Status :: 3 - Alpha
10
- Classifier: Framework :: Pytest
11
- Classifier: Intended Audience :: Developers
12
- Classifier: License :: OSI Approved :: Apache Software License
13
- Classifier: Operating System :: OS Independent
14
- Classifier: Programming Language :: Python :: 3.14
15
- Classifier: Typing :: Typed
16
- License-File: LICENSE
17
- Requires-Dist: pythonic-fp-circulararray>=6.0.4
18
- Requires-Dist: pythonic-fp-fptools>=5.2.0
19
- Requires-Dist: pythonic-fp-iterables>=5.1.3
20
- Requires-Dist: pytest>=8.4.1 ; extra == "test"
21
- Project-URL: Changelog, https://github.com/grscheller/pythonic-fp-containers/blob/main/CHANGELOG.rst
22
- Project-URL: Documentation, https://grscheller.github.io/pythonic-fp/projects/containers.html
23
- Project-URL: Homepage, https://grscheller.github.io/pythonic-fp/
24
- Project-URL: Source, https://github.com/grscheller/pythonic-fp-containers
25
- Provides-Extra: test
26
-
27
- Pythonic FP - Containers
28
- ========================
29
-
30
- PyPI project
31
- `pythonic-fp-containers
32
- <https://pypi.org/project/pythonic-fp-containers>`_.
33
-
34
- Python package of container like data structures with functional
35
- programming inspired tweaks.
36
-
37
- +---------------------------------------------+-----------+------------------+
38
- | module | class | name |
39
- +=============================================+===========+==================+
40
- | ``pythonic_fp.containers.functional_tuple`` | FTuple | Functional Tuple |
41
- +---------------------------------------------+-----------+------------------+
42
- | ``pythonic_fp.containers.immutable_list`` | IList | Immutable List |
43
- +---------------------------------------------+-----------+------------------+
44
-
45
- Part of the
46
- `pythonic-fp
47
- <https://grscheller.github.io/pythonic-fp/>`_
48
- PyPI projects.
49
-
50
- Documentation
51
- -------------
52
-
53
- Documentation and other links for this project are hosted on
54
- `GitHub Pages
55
- <https://grscheller.github.io/pythonic-fp/projects/containers.html>`_.
56
-
57
- Copyright and License
58
- ---------------------
59
-
60
- Copyright (c) 2023-2026 Geoffrey R. Scheller. Licensed under the Apache
61
- License, Version 2.0. See the LICENSE file for details.
62
-
@@ -1,11 +0,0 @@
1
- pythonic_fp/containers/__init__.py,sha256=J1UvKHza0iDCR1GrVSUeps5LHsPc56xISvkbnGXOJtA,1034
2
- pythonic_fp/containers/__init__.pyi,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
- pythonic_fp/containers/functional_tuple.py,sha256=3Vdg3Fri5wGDdWv4bomS7xqWLy0B_eMQuXojZhgvKYM,7498
4
- pythonic_fp/containers/functional_tuple.pyi,sha256=g8IvlIhPxecEsetEexZ7WmN9Ifdh-vAeK0z9SwLiCGE,1182
5
- pythonic_fp/containers/immutable_list.py,sha256=9qtSF5R7O2f-Dzji2G11CneC0BTrk3WA5EV3z2sdnms,9796
6
- pythonic_fp/containers/immutable_list.pyi,sha256=1p7w7FP-OpCHvCBJIlztoP_uUoZIoj9uI_XGKEib-kU,1371
7
- pythonic_fp/containers/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
- pythonic_fp_containers-4.1.0.dist-info/licenses/LICENSE,sha256=IJMkVWQUVy-SonK6SMaMotDQ6Zb-lVi2bUTiGp1GUO8,10774
9
- pythonic_fp_containers-4.1.0.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
10
- pythonic_fp_containers-4.1.0.dist-info/METADATA,sha256=I5j_6Nc6ykHEfx6ThA1S9x3ifqyHyYxdktbMw5wNr_w,2387
11
- pythonic_fp_containers-4.1.0.dist-info/RECORD,,