pythonic-fp.containers 4.0.1__tar.gz → 4.2.0__tar.gz

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.
@@ -0,0 +1,51 @@
1
+ Metadata-Version: 2.4
2
+ Name: pythonic-fp-containers
3
+ Version: 4.2.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.2.2,<6.3
19
+ Requires-Dist: pythonic-fp-fptools>=6,<6.2
20
+ Requires-Dist: pythonic-fp-iterables>=5.1.4,<6
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/release/html/
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/projects/containers.html).
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,25 @@
1
+ # Pythonic FP - Containers
2
+
3
+ Python package for containers of like data structures with functional
4
+ programming inspired tweaks.
5
+
6
+ PyPI project
7
+ [pythonic-fp-containers](https://pypi.org/project/pythonic-fp-containers).
8
+ Part of the
9
+ [pythonic-fp](https://grscheller.github.io/pythonic-fp/)
10
+ PyPI projects.
11
+
12
+ ## Documentation
13
+
14
+ Documentation and other links for this project are hosted on
15
+ [GitHub Pages](https://grscheller.github.io/pythonic-fp/projects/containers.html).
16
+
17
+ | module | class | name |
18
+ |:------ |:-----:|:---- |
19
+ | `pythonic_fp.containers.functional_tuple` | FTuple | Functional Tuple |
20
+ | `pythonic_fp.containers.immutable_list` | IList | Immutable List |
21
+
22
+ ## Copyright and License
23
+
24
+ Copyright (c) 2023-2026 Geoffrey R. Scheller. Licensed under the Apache
25
+ License, Version 2.0. See the LICENSE file for details.
@@ -1,10 +1,16 @@
1
+ [build-system]
2
+ requires = ["flit_core>=3.12,<4"]
3
+ build-backend = "flit_core.buildapi"
4
+
1
5
  [project]
2
6
  name = "pythonic-fp-containers"
3
- version = "4.0.1"
4
- readme = "README.rst"
5
- requires-python = ">=3.12"
6
- license = { file = "LICENSE" }
7
- authors = [{ name = "Geoffrey R. Scheller", email = "geoffrey@scheller.com" }]
7
+ version = "4.2.0"
8
+ description = "Containers with FP interfaces."
9
+ readme = "README.md"
10
+ requires-python = ">=3.14" # floor: PEP 649/749 deferred annotations — class-level self-reference possible NameErrors on <3.14
11
+ authors = [
12
+ { name = "Geoffrey R. Scheller", email = "geoffrey@scheller.com" },
13
+ ]
8
14
  keywords = [
9
15
  "functional_containers",
10
16
  "functional_tuple",
@@ -16,65 +22,67 @@ classifiers = [
16
22
  "Intended Audience :: Developers",
17
23
  "License :: OSI Approved :: Apache Software License",
18
24
  "Operating System :: OS Independent",
19
- "Programming Language :: Python :: 3.13",
25
+ "Programming Language :: Python :: 3.14",
26
+ "Programming Language :: Python :: 3.15",
20
27
  "Typing :: Typed",
21
28
  ]
22
29
  dependencies = [
23
- "pythonic-fp-circulararray>=6.0.1",
24
- "pythonic-fp-fptools>=5.2.0",
25
- "pythonic-fp-iterables>=5.1.3",
30
+ "pythonic-fp-circulararray>=6.2.2,<6.3",
31
+ "pythonic-fp-fptools>=6,<6.2",
32
+ "pythonic-fp-iterables>=5.1.4,<6",
26
33
  ]
27
- dynamic = ["description"]
28
34
 
29
35
  [project.urls]
30
- Changelog = "https://github.com/grscheller/pythonic-fp-containers/blob/main/CHANGELOG.rst"
31
- Documentation = "https://grscheller.github.io/pythonic-fp/containers/development/build/html/"
32
- Homepage = "https://grscheller.github.io/pythonic-fp/homepage/build/html/"
36
+ Changelog = "https://github.com/grscheller/pythonic-fp-containers/blob/main/CHANGELOG.md"
37
+ Documentation ="https://grscheller.github.io/pythonic-fp-containers/release/html/"
38
+ Homepage = "https://grscheller.github.io/pythonic-fp/"
33
39
  Source = "https://github.com/grscheller/pythonic-fp-containers"
34
40
 
35
- [project.optional-dependencies]
41
+ [dependency-groups]
42
+ docs = [
43
+ "furo>=2025.12.19",
44
+ "sphinx>=9.1",
45
+ ]
36
46
  test = [
37
47
  "pytest>=8.4.1",
38
48
  ]
39
49
 
40
- [build-system]
41
- requires = ["flit_core>=3.12,<4"]
42
- build-backend = "flit_core.buildapi"
43
-
44
50
  [tool.flit.module]
45
51
  name = "pythonic_fp.containers"
46
52
 
53
+ [tool.flit.sdist]
54
+ exclude = [
55
+ "docs/",
56
+ "tests/",
57
+ ]
58
+
59
+ [tool.pytest]
60
+ addopts = ["-ra"]
61
+ consider_namespace_packages = true
62
+ testpaths = ["tests/"]
63
+
47
64
  [tool.mypy]
48
- enable_incomplete_feature = "NewGenericSyntax"
49
65
  explicit_package_bases = true
50
- implicit_reexport = false
51
66
  local_partial_types = true
52
67
  namespace_packages = true
53
68
  warn_redundant_casts = true
54
69
  warn_return_any = true
55
70
  warn_unused_configs = true
56
71
 
57
- [tool.pylsp-mypy]
58
- enabled = true
59
- live-mode = true
60
- dmypy = false
61
- strict = true
62
- report_progress = true
63
-
64
- [tool.pytest.ini_options]
65
- addopts = "-ra"
66
- consider_namespace_packages = true
67
- testpaths = ["tests/"]
68
-
69
72
  [tool.ruff]
70
- target-version = "py313"
73
+ target-version = "py314"
74
+
75
+ [tool.ruff.lint]
76
+ ignore = ["RUF022", "E741"]
71
77
 
72
78
  [tool.ruff.lint.flake8-quotes]
73
79
  docstring-quotes = "double"
74
80
 
75
81
  [tool.ruff.lint.per-file-ignores]
76
- "tests/*" = ["C901"]
77
- "**/*.py" = ["E741"]
82
+ "tests/**/*.py" = [
83
+ "E731",
84
+ "C901",
85
+ ]
78
86
 
79
87
  [tool.ruff.format]
80
88
  quote-style = "single"
@@ -13,16 +13,15 @@
13
13
  # limitations under the License.
14
14
 
15
15
  """
16
- Container with FP interfaces
17
- ----------------------------
16
+ Containers with FP interfaces
17
+ -----------------------------
18
18
 
19
- +---------------------------------------------+-----------+------------------+
20
- | module | class | description |
21
- +=============================================+===========+==================+
22
- | ``pythonic_fp.containers.functional_tuple`` | FTuple | Functional Tuple |
23
- +---------------------------------------------+-----------+------------------+
24
- | ``pythonic_fp.containers.immutable_list`` | IList | Immutable List |
25
- +---------------------------------------------+-----------+------------------+
19
+ .. admonition:: Functional variants of Python builtins
20
+
21
+ Not sure the direction this should take.
22
+
23
+ - class **FTuple:** A tuple-like object with a functional interface.
24
+ - class **IList:** An immutable, hashable list-like object.
26
25
 
27
26
  """
28
27
 
@@ -13,8 +13,6 @@
13
13
  # See the License for the specific language governing permissions and
14
14
  # limitations under the License.
15
15
 
16
- """Pythonic FP - Functional Tuple"""
17
-
18
16
  from collections.abc import Callable, Iterator
19
17
  from typing import cast, Never, overload, SupportsIndex
20
18
  from pythonic_fp.iterables.folding import accumulate
@@ -25,26 +23,42 @@ __all__ = ['FTuple']
25
23
 
26
24
  class FTuple[D](tuple[D, ...]):
27
25
  """
28
- .. admonition:: Functional Tuple suitable for inheritance.
26
+ .. admonition:: Functional Tuple
29
27
 
28
+ - intended for further inheritance
30
29
  - supports both indexing and slicing
31
30
  - int multiplication and FTuple addition supported
32
31
  - addition concatenates results, resulting in a Union type
33
32
  - both left and right int multiplication supported
34
33
  - homogeneous in its data type
35
- - supports being further inherited from
36
34
  - unslotted
37
35
 
36
+ .. note::
37
+
38
+ Example of code very early in project. Different ways
39
+ to use __dunders__ than what I do lately.
40
+
38
41
  """
39
42
 
40
43
  def __reversed__(self) -> Iterator[D]:
44
+ """
45
+ .. admonition:: reverse iter
46
+
47
+ :yields: the tuples elements in reverse order
48
+
49
+ """
41
50
  for ii in range(len(self) - 1, -1, -1):
42
51
  yield (self[ii])
43
52
 
44
- def __repr__(self) -> str:
45
- return f'{self.__class__.__name__}(' + ', '.join(map(repr, self)) + ')'
46
-
47
53
  def __eq__(self, other: object, /) -> bool:
54
+ """
55
+ .. admonition:: equality comparison
56
+
57
+ :param other: The ``object`` to which to be compared.
58
+ :returns: ``True`` if ``other`` is the same type and
59
+ corresponding elements compare as equal.
60
+
61
+ """
48
62
  if not isinstance(other, self.__class__):
49
63
  return False
50
64
  if (length := len(self)) != len(other):
@@ -67,6 +81,9 @@ class FTuple[D](tuple[D, ...]):
67
81
  else:
68
82
  return super().__getitem__(idx)
69
83
 
84
+ def __repr__(self) -> str:
85
+ return f'{self.__class__.__name__}(' + ', '.join(map(repr, self)) + ')'
86
+
70
87
  def foldl[L](
71
88
  self,
72
89
  f: Callable[[L, D], L],
@@ -74,16 +91,20 @@ class FTuple[D](tuple[D, ...]):
74
91
  start: L | None = None,
75
92
  default: L | None = None,
76
93
  ) -> L:
77
- """Fold Left with optional starting and default values.
94
+ """
95
+ .. admonition:: fold left
78
96
 
79
- - fold left with an optional starting value
80
- - first argument of function ``f`` is for the accumulated value
97
+ Reduce left with optional starting and default values.
81
98
 
82
- :param f: The folding function, first argument is for the accumulated value.
83
- :param start: An optional starting value.
84
- :param default: An optional default value if fold does not exist.
85
- :raises ValueError: When ``FTuple`` empty and a start value not given.
86
- :returns: The folded value if it exists, otherwise the default value.
99
+ :param f: The folding function, first argument is for
100
+ the accumulated value.
101
+ :param start: An optional starting value.
102
+ :param default: An optional default value
103
+ if fold does not exist.
104
+ :raises ValueError: When ``FTuple`` empty and a start value
105
+ was not not given.
106
+ :returns: Folded value if it exists, otherwise
107
+ the default value if given.
87
108
 
88
109
  """
89
110
  it_self = iter(self)
@@ -107,13 +128,20 @@ class FTuple[D](tuple[D, ...]):
107
128
  start: R | None = None,
108
129
  default: R | None = None,
109
130
  ) -> R:
110
- """Fold Right with optional starting and default values.
131
+ """
132
+ .. admonition:: fold right
111
133
 
112
- :param f: The folding function, second argument is for the accumulated value.
113
- :param start: An optional starting value.
114
- :param default: An optional default value if fold does not exist.
115
- :raises ValueError: when FTuple empty and a start value not given
116
- :returns: The folded value if it exists, otherwise the default value.
134
+ Reduce right with optional starting and default values.
135
+
136
+ :param f: The folding function, second argument is for
137
+ the accumulated value.
138
+ :param start: An optional starting value.
139
+ :param default: An optional default value
140
+ if fold does not exist.
141
+ :raises ValueError: when ``FTuple`` empty and a start value
142
+ was not given
143
+ :returns: The folded value if it exists, otherwise
144
+ the default value if given.
117
145
 
118
146
  """
119
147
  it_self = reversed(self)
@@ -131,9 +159,13 @@ class FTuple[D](tuple[D, ...]):
131
159
  return acc
132
160
 
133
161
  def copy(self) -> 'FTuple[D]':
134
- """Return a shallow copy of ``FTuple`` in O(1) time & space complexity.
162
+ """
163
+ .. admonition:: copy
135
164
 
136
- :returns: New ``FTuple``.
165
+ Return a shallow copy of ``FTuple`` in O(1)
166
+ time & space complexity.
167
+
168
+ :returns: A new ``FTuple`` instance.
137
169
 
138
170
  """
139
171
  return self.__class__(self)
@@ -153,14 +185,12 @@ class FTuple[D](tuple[D, ...]):
153
185
  def accummulate[L](
154
186
  self, f: Callable[[L, D], L], s: L | None = None, /
155
187
  ) -> 'FTuple[L]':
156
- """Accumulate partial folds.
157
-
158
- Accumulate partial fold with an optional starting value,
159
- results in an ``FTuple``.
188
+ """
189
+ .. admonition:: accumulate partial folds
160
190
 
161
- :param f: Folding function used to produce partial folds.
162
- :param s: Optional starting value.
163
- :returns: New ``FTuple`` of the partial folds.
191
+ :param f: Folding function used to produce partial folds.
192
+ :param s: Optional starting value.
193
+ :returns: New ``FTuple`` of the partial folds.
164
194
 
165
195
  """
166
196
  if s is None:
@@ -168,6 +198,13 @@ class FTuple[D](tuple[D, ...]):
168
198
  return FTuple(accumulate(self, f, s))
169
199
 
170
200
  def map[U](self, f: Callable[[D], U], /) -> 'FTuple[U]':
201
+ """
202
+ .. admonition:: map
203
+
204
+ :param f: Folding function used to produce partial folds.
205
+ :returns: A new ``FTuple`` instance.
206
+
207
+ """
171
208
  return FTuple(map(f, self))
172
209
 
173
210
  def bind[U](
@@ -176,13 +213,17 @@ class FTuple[D](tuple[D, ...]):
176
213
  merge_type: MergeEnum = MergeEnum.Concat,
177
214
  yield_partials: bool = False,
178
215
  ) -> 'FTuple[U] | Never':
179
- """Bind function ``f`` to the ``FTuple``.
216
+ """
217
+ .. admonition:: bind
218
+
219
+ Flat map function ``f`` with the ``FTuple`` with different
220
+ merging strategies.
180
221
 
181
- :param f: Function ``D -> FTuple[U]``
182
- :param merge_type: ``MergeEnum`` to determine how to merge the result.
183
- :param yield_partials: Yield unmatched values if ``MergeEnum`` given as merge type.
184
- :return: Resulting ``FTuple``.
185
- :raises ValueError: If given an unknown merge enumeration.
222
+ :param f: Function ``D -> FTuple[U]``
223
+ :param merge_type: ``MergeEnum`` to determine how to merge the result.
224
+ :param yield_partials: Yield unmatched values if ``MergeEnum`` given as merge type.
225
+ :returns: A new ``FTuple`` instance.
226
+ :raises ValueError: If given an unknown merge enumeration.
186
227
 
187
228
  """
188
229
  return FTuple(