dtools.fp 1.3.0__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,143 @@
1
+ # CHANGELOG
2
+
3
+ PyPI dtools.fp project.
4
+
5
+ #### Semantic versioning
6
+
7
+ * first digit - major event, epoch, or paradigm shift
8
+ * second digit - breaking API changes, major changes
9
+ * third digit - bug fixes, API additions, breaking API in dev env
10
+ * forth digit - commit count changes/regressions (dev environment only)
11
+
12
+ ## Releases and Important Milestones
13
+
14
+ ### Version 1.2.0 - PyPI release date 01-04-25
15
+
16
+ * added modules lazy and state
17
+ * simplifications done to fp.iterables module
18
+ * renamed flatmap methods to bind
19
+ * minor MB and XOR updates/corrections
20
+
21
+ ### Version 1.1.0 - PyPI release date 11-18-24
22
+
23
+ * added fp.function module
24
+ * combine and partially apply functions as first class objects
25
+ * some tests may be lacking
26
+
27
+ ### Version 1.0.2.0 - Commit date 2024-10-20
28
+
29
+ * breaking API changes, next PyPI release will be 1.1.0.
30
+ * renamed module `nothingness` to `singletons`
31
+ * split class NoValue into class NoValue and Sentinel
32
+ * `noValue` represents a missing value
33
+ * `_sentinel` is intended to provide a "private" sentinel value
34
+ * frees up `None` and `()` for application use
35
+ * avoids name collisions with user code
36
+ * will be used in grscheller.datastructures
37
+ * will redo docs in docs repo
38
+
39
+ ### Version 1.0.1 - PyPI release date 2024-10-20
40
+
41
+ * removed docs from repo
42
+ * docs for all grscheller namespace projects maintained here
43
+ * https://grscheller.github.io/grscheller-pypi-namespace-docs/
44
+
45
+ ### Version 1.0.0 - PyPI Release: 2024-10-18
46
+
47
+ * decided to make this release first stable release
48
+ * renamed module fp.woException to fp.err\_handling
49
+ * better captures module's use case
50
+ * pytest improvements based on pytest documentation
51
+
52
+ ### Version 0.4.0 - PyPI Release: 2024-10-03
53
+
54
+ * long overdue PyPI release
55
+
56
+ ### Version 0.3.5.1 - Commit Date: 2024-10-03
57
+
58
+ * New module `grscheller.fp.nothingness` for
59
+ * Singleton `noValue` representing a missing value
60
+ * similar to `None` but while
61
+ * `None` represent "returned no values"
62
+ * `noValue: _NoValue = _NoValue()` represents an absent value
63
+ * mostly used as an implementation detail
64
+ * allows client code to use `None` as a sentinel value
65
+ * prefer class `MB` to represent a missing value in client code
66
+
67
+ ### Version 0.3.4.0 - Commit Date: 2024-09-30
68
+
69
+ * API change for fp.iterables
70
+ * function name changes
71
+ * `foldL`, `foldR`, `foldLsc`, `foldRsc`
72
+ * `sc` stands for "short circuit"
73
+ * all now return class woException.MB
74
+
75
+ ### Version 0.3.3.7 - Commit Date: 2024-09-22
76
+
77
+ * added more functions to fp.iterables module
78
+ * take(it: Iterable[D], n: int) -> Iterator[D]
79
+ * takeWhile(it: Iterable[D], pred: Callable[[D], bool]) -> Iterator[D]
80
+ * drop(it: Iterable[D], n: int) -> Iterator[D]
81
+ * dropWhile(it: Iterable[D], pred: Callable[[D], bool]) -> Iterator[D]
82
+
83
+ ### Version 0.3.3.4 - Commit Date: 2024-09-16
84
+
85
+ * fp.iterables `foldL_sc` & `foldR_sc` now have
86
+ * common paradigm
87
+ * similar signatures
88
+
89
+ ### Version 0.3.3.3 - Commit Date: 2024-09-15
90
+
91
+ * added fp.iterables function `foldR_sc`
92
+ * shortcut version of `foldR`
93
+ * not fully tested
94
+ * docstring not updated
95
+
96
+ ### Version 0.3.3.2 - Commit Date: 2024-09-14
97
+
98
+ * added fp.iterables function `foldL_sc`
99
+ * shortcut version of foldL
100
+
101
+ ### Version 0.3.3 - PyPI Release: 2024-08-25
102
+
103
+ * removed woException `XOR` method
104
+ * `getDefaultRight(self) -> R`:
105
+ * added methods
106
+ * makeRight(self, right: R|Nada=nada) -> XOR[L, R]:
107
+ * swapRight(self, right: R) -> XOR[L, R]:
108
+
109
+ ### Version 0.3.1 - PyPI Release: 2024-08-20
110
+
111
+ * fp.iterables no longer exports `CONCAT`, `MERGE`, `EXHAUST`
112
+ * for grscheller.datastructures
113
+ * grscheller.datastructures.ftuple
114
+ * grscheller.datastructures.split\_ends
115
+
116
+ ### Version 0.3.0 - PyPI Release: 2024-08-17
117
+
118
+ * class Nothing re-added but renamed class Nada
119
+ * version grscheller.untyped.nothing for more strictly typed code
120
+
121
+ ### Version 0.2.1 - PyPI Release: 2024-07-26
122
+
123
+ PyPI grscheller.fp package release v0.2.1
124
+
125
+ * forgot to update README.md on last PyPI release
126
+ * simplified README.md to help alleviate this mistake in the future
127
+
128
+ ### Version 0.2.0 - PyPI Release: 2024-07-26
129
+
130
+ * from last PyPI release
131
+ * added accumulate function to fp.iterators
132
+ * new fp.nothing module implementing nothing: Nothing singleton
133
+ * represents a missing value
134
+ * better "bottom" type than either None or ()
135
+ * renamed fp.wo_exception to fp.woException
136
+ * overall much better docstrings
137
+
138
+ ### Version 0.1.0 - Initial PyPI Release: 2024-07-11
139
+
140
+ * replicated functionality from grscheller.datastructures
141
+ * grscheller.datastructures.fp.MB -> grscheller.fp.wo\_exception.MB
142
+ * grscheller.datastructures.fp.XOR -> grscheller.fp.wo\_exception.XOR
143
+ * grscheller.core.iterlib -> grscheller.fp.iterators
@@ -0,0 +1,176 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
@@ -0,0 +1,58 @@
1
+ Metadata-Version: 2.3
2
+ Name: dtools.fp
3
+ Version: 1.3.0
4
+ Summary: ### Package dtools.fp - Pythonic Functional Programming
5
+ Keywords: functional,functional programming,fp,monad,iterators,maybe,either,lazy,non-strict
6
+ Author-email: "Geoffrey R. Scheller" <geoffrey@scheller.com>
7
+ Requires-Python: >=3.12
8
+ Description-Content-Type: text/markdown
9
+ Classifier: Development Status :: 5 - Production/Stable
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.13
15
+ Classifier: Typing :: Typed
16
+ Requires-Dist: pytest >=8.3 ; extra == "test"
17
+ Requires-Dist: dtools.circular-array >=3.9.0, < 3.10 ; extra == "test"
18
+ Requires-Dist: dtools.datastructures >=0.25.0, < 0.26 ; extra == "test"
19
+ Project-URL: Changelog, https://github.com/grscheller/dtools-fp/blob/main/CHANGELOG.md
20
+ Project-URL: Documentation, https://grscheller.github.io/dtools-docs/fp
21
+ Project-URL: Source, https://github.com/grscheller/dtools-fp
22
+ Provides-Extra: test
23
+
24
+ # Python Functional Programming (FP)
25
+
26
+ Functional programming tools which endeavor to be Pythonic.
27
+
28
+ * **Repositories**
29
+ * [dtools.fp][1] project on *PyPI*
30
+ * [Source code][2] on *GitHub*
31
+ * Detailed documentation for dtools.fp
32
+ * [Detailed API documentation][3] on *GH-Pages*
33
+
34
+ ### Modules
35
+
36
+ * grscheller.fp.iterables
37
+ * iteration tools implemented in Python
38
+ * grscheller.fp.nothingness
39
+ * singleton classes representing either a
40
+ * missing value
41
+ * sentinel value
42
+ * failed calculation
43
+ * grscheller.fp.err\_handling
44
+ * monadic tools for handling missing values & unexpected events
45
+
46
+ ### Benefits of FP
47
+
48
+ * improved composability
49
+ * avoid exception driven code paths
50
+ * data sharing becomes trivial due to immutability
51
+
52
+ ---
53
+
54
+ [1]: https://pypi.org/project/dtools.fp/
55
+ [2]: https://github.com/grscheller/dtools-fp/
56
+ [3]: https://grscheller.github.io/dtools-docs/fp/
57
+
58
+
@@ -0,0 +1,34 @@
1
+ # Python Functional Programming (FP)
2
+
3
+ Functional programming tools which endeavor to be Pythonic.
4
+
5
+ * **Repositories**
6
+ * [dtools.fp][1] project on *PyPI*
7
+ * [Source code][2] on *GitHub*
8
+ * Detailed documentation for dtools.fp
9
+ * [Detailed API documentation][3] on *GH-Pages*
10
+
11
+ ### Modules
12
+
13
+ * grscheller.fp.iterables
14
+ * iteration tools implemented in Python
15
+ * grscheller.fp.nothingness
16
+ * singleton classes representing either a
17
+ * missing value
18
+ * sentinel value
19
+ * failed calculation
20
+ * grscheller.fp.err\_handling
21
+ * monadic tools for handling missing values & unexpected events
22
+
23
+ ### Benefits of FP
24
+
25
+ * improved composability
26
+ * avoid exception driven code paths
27
+ * data sharing becomes trivial due to immutability
28
+
29
+ ---
30
+
31
+ [1]: https://pypi.org/project/dtools.fp/
32
+ [2]: https://github.com/grscheller/dtools-fp/
33
+ [3]: https://grscheller.github.io/dtools-docs/fp/
34
+
@@ -0,0 +1,74 @@
1
+ [build-system]
2
+ requires = ["flit_core>=3.4,<4"]
3
+ build-backend = "flit_core.buildapi"
4
+
5
+ [project]
6
+ name = "dtools.fp"
7
+ authors = [
8
+ { name = "Geoffrey R. Scheller", email = "geoffrey@scheller.com" },
9
+ ]
10
+ license = { file = "LICENSE" }
11
+ readme = "README.md"
12
+ requires-python = ">=3.12"
13
+ classifiers = [
14
+ "Development Status :: 5 - Production/Stable",
15
+ "Framework :: Pytest",
16
+ "Intended Audience :: Developers",
17
+ "License :: OSI Approved :: Apache Software License",
18
+ "Operating System :: OS Independent",
19
+ "Programming Language :: Python :: 3.13",
20
+ "Typing :: Typed"
21
+ ]
22
+ dependencies = []
23
+ dynamic = ["version", "description"]
24
+ keywords = [
25
+ "functional", "functional programming", "fp",
26
+ "monad", "iterators",
27
+ "maybe", "either",
28
+ "lazy", "non-strict"
29
+ ]
30
+
31
+ [project.optional-dependencies]
32
+ test = [
33
+ "pytest >=8.3",
34
+ "dtools.circular-array >=3.9.0, < 3.10",
35
+ "dtools.datastructures >=0.25.0, < 0.26"
36
+ ]
37
+
38
+ [project.urls]
39
+ Source = "https://github.com/grscheller/dtools-fp"
40
+ Changelog = "https://github.com/grscheller/dtools-fp/blob/main/CHANGELOG.md"
41
+ Documentation = "https://grscheller.github.io/dtools-docs/fp"
42
+
43
+ [tool.flit.sdist]
44
+ exclude = ["dist", "docs", ".gitignore", ".mypy_cache"]
45
+
46
+ [tool.pylsp-mypy]
47
+ enabled = true
48
+ live-mode = true
49
+ strict = true
50
+ report_progress = true
51
+
52
+ [tool.mypy]
53
+ enable_incomplete_feature = ["NewGenericSyntax"]
54
+ implicit_reexport = false
55
+ local_partial_types = true
56
+ warn_redundant_casts = true
57
+ warn_return_any = true
58
+ warn_unused_configs = true
59
+
60
+ [tool.pytest.ini_options]
61
+ testpaths = ["tests"]
62
+ consider_namespace_packages = true
63
+
64
+ [tool.ruff]
65
+ target-version = "py313"
66
+
67
+ [tool.ruff.lint.per-file-ignores]
68
+ "__init__.py" = ["F401"]
69
+
70
+ [tool.ruff.format]
71
+ quote-style = "single"
72
+
73
+ [tool.ruff.lint.flake8-quotes]
74
+ docstring-quotes = "double"
@@ -0,0 +1,34 @@
1
+ # Copyright 2023-2025 Geoffrey R. Scheller
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """### Package dtools.fp - Pythonic Functional Programming
16
+
17
+ Tools to aid with functional programming in Python yet still endeavoring to
18
+ remain Pythonic.
19
+
20
+ #### Modules and sub-packages
21
+
22
+ * module dtools.fp.err_handling: monadic maybe and either
23
+ * module dtools.fp.functions: tools combine and partially apply functions
24
+ * module dtools.fp.iterables: tools for iterables
25
+ * module dtools.fp.lazy: lazy (non-strict) function evaluation
26
+ * module dtools.fp.singletons: useful types with but one instance
27
+ * module dtools.fp.state: handle state monadically
28
+
29
+ """
30
+ __version__ = "1.3.0"
31
+ __author__ = "Geoffrey R. Scheller"
32
+ __copyright__ = "Copyright (c) 2023-2025 Geoffrey R. Scheller"
33
+ __license__ = "Apache License 2.0"
34
+