pythonic-fp-gadgets 4.0.2__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.
- pythonic_fp_gadgets-4.0.2/.gitignore +7 -0
- pythonic_fp_gadgets-4.0.2/CHANGELOG.rst +90 -0
- pythonic_fp_gadgets-4.0.2/LICENSE +176 -0
- pythonic_fp_gadgets-4.0.2/PKG-INFO +58 -0
- pythonic_fp_gadgets-4.0.2/README.rst +33 -0
- pythonic_fp_gadgets-4.0.2/pyproject.toml +77 -0
- pythonic_fp_gadgets-4.0.2/src/pythonic_fp/gadgets/__init__.py +85 -0
- pythonic_fp_gadgets-4.0.2/src/pythonic_fp/gadgets/__init__.pyi +6 -0
- pythonic_fp_gadgets-4.0.2/src/pythonic_fp/gadgets/box.py +179 -0
- pythonic_fp_gadgets-4.0.2/src/pythonic_fp/gadgets/box.pyi +27 -0
- pythonic_fp_gadgets-4.0.2/src/pythonic_fp/gadgets/py.typed +0 -0
- pythonic_fp_gadgets-4.0.2/src/pythonic_fp/gadgets/sentinels/__init__.py +17 -0
- pythonic_fp_gadgets-4.0.2/src/pythonic_fp/gadgets/sentinels/__init__.pyi +0 -0
- pythonic_fp_gadgets-4.0.2/src/pythonic_fp/gadgets/sentinels/flavored.py +74 -0
- pythonic_fp_gadgets-4.0.2/src/pythonic_fp/gadgets/sentinels/flavored.pyi +8 -0
- pythonic_fp_gadgets-4.0.2/src/pythonic_fp/gadgets/sentinels/novalue.py +123 -0
- pythonic_fp_gadgets-4.0.2/src/pythonic_fp/gadgets/sentinels/novalue.pyi +6 -0
- pythonic_fp_gadgets-4.0.2/src/pythonic_fp/gadgets/wrap.py +144 -0
- pythonic_fp_gadgets-4.0.2/src/pythonic_fp/gadgets/wrap.pyi +23 -0
- pythonic_fp_gadgets-4.0.2/tests/sentinels/test_novalue.py +83 -0
- pythonic_fp_gadgets-4.0.2/tests/sentinels/test_sentinel_hidden_implemetation_detail.py +70 -0
- pythonic_fp_gadgets-4.0.2/tests/sentinels/test_sentinel_with_functions.py +31 -0
- pythonic_fp_gadgets-4.0.2/tests/test_box.py +95 -0
- pythonic_fp_gadgets-4.0.2/tests/test_first_common_ancestor.py +115 -0
- pythonic_fp_gadgets-4.0.2/tests/test_hwrap.py +76 -0
- pythonic_fp_gadgets-4.0.2/tests/test_iterate_over_arguments.py +46 -0
- pythonic_fp_gadgets-4.0.2/tests/test_wrap.py +71 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
CHANGELOG
|
|
2
|
+
=========
|
|
3
|
+
|
|
4
|
+
PyPI pythonic-fp-gadgets project.
|
|
5
|
+
|
|
6
|
+
Semantic Versioning
|
|
7
|
+
-------------------
|
|
8
|
+
|
|
9
|
+
Strict 3 digit semantic versioning
|
|
10
|
+
|
|
11
|
+
- **MAJOR** version incremented for incompatible API changes
|
|
12
|
+
- **MINOR** version incremented for backward compatible added functionality
|
|
13
|
+
- **PATCH** version incremented for backward compatible bug fixes
|
|
14
|
+
|
|
15
|
+
See `Semantic Versioning 2.0.0 <https://semver.org>`_.
|
|
16
|
+
|
|
17
|
+
Releases and Important Milestones
|
|
18
|
+
---------------------------------
|
|
19
|
+
|
|
20
|
+
PyPI 4.0.2 - 2026-01-TBD
|
|
21
|
+
~~~~~~~~~~~~~~~~~~~~~~~~
|
|
22
|
+
|
|
23
|
+
Docstring improvements based on lessons learned from my PyPI
|
|
24
|
+
boring-math-abstract-algebra project.
|
|
25
|
+
|
|
26
|
+
PyPI v4.0.1 - 2025-12-02
|
|
27
|
+
~~~~~~~~~~~~~~~~~~~~~~~~
|
|
28
|
+
|
|
29
|
+
Move functions out of their own packages to __init__.py (2025-10-13).
|
|
30
|
+
|
|
31
|
+
- latest_common_ancestor.lca -> first_common_ancestor
|
|
32
|
+
- iterate_arguments.ita -> iterate_over_arguments
|
|
33
|
+
|
|
34
|
+
Unfortunately I forgot to push these changes to PyPI for a
|
|
35
|
+
month and a half!
|
|
36
|
+
|
|
37
|
+
PyPI v3.0.1 - 2025-09-09
|
|
38
|
+
~~~~~~~~~~~~~~~~~~~~~~~~
|
|
39
|
+
|
|
40
|
+
Corrected incorrect dependencies.
|
|
41
|
+
|
|
42
|
+
PyPI v3.0.0 - 2025-08-31
|
|
43
|
+
~~~~~~~~~~~~~~~~~~~~~~~~
|
|
44
|
+
|
|
45
|
+
Discovered I was not quite compliant with
|
|
46
|
+
Python typing 3.12+ conventions.
|
|
47
|
+
|
|
48
|
+
- No longer explicitly using TypeVar directly.
|
|
49
|
+
|
|
50
|
+
- Removed Unions with Never from .py files
|
|
51
|
+
|
|
52
|
+
- the "happy path" returns just types (pythonic convention)
|
|
53
|
+
- stubgen actually puts them back in .pyi files
|
|
54
|
+
|
|
55
|
+
- renamed it.it -> iterate_arguments.ita
|
|
56
|
+
- renamed lca.latest_common_ancestor -> latest_common_ancestor.lca
|
|
57
|
+
|
|
58
|
+
PyPI v2.2.0 - 2025-08-30
|
|
59
|
+
~~~~~~~~~~~~~~~~~~~~~~~~
|
|
60
|
+
|
|
61
|
+
Moved for pythonic_fp.gadgets package to a new GitHub repo,
|
|
62
|
+
pythonic-fp-gadgets. Replaced it with the empty Python
|
|
63
|
+
module pythonic_fp.name_claim in pythonic-fp.
|
|
64
|
+
|
|
65
|
+
The gadgets package being different from the other namespace
|
|
66
|
+
packages was throwing off my workflow.
|
|
67
|
+
|
|
68
|
+
- added function it.it
|
|
69
|
+
- added function lca.latest_common_ancestor
|
|
70
|
+
|
|
71
|
+
Update - 2025-08-09
|
|
72
|
+
~~~~~~~~~~~~~~~~~~~
|
|
73
|
+
|
|
74
|
+
Preparing for upcoming PyPI release for gadgets.
|
|
75
|
+
|
|
76
|
+
- decided to make gadget's pyproject.toml the exemplar for rest of pythonic-fp namespace
|
|
77
|
+
- pythonic_fp.gadget works with previous and next release of singletons
|
|
78
|
+
|
|
79
|
+
PyPI v1.1.0 - 2025-08-02
|
|
80
|
+
~~~~~~~~~~~~~~~~~~~~~~~~
|
|
81
|
+
|
|
82
|
+
Released pythonic-fp v1.1.0 which contains pythonic_fp.gadgets package.
|
|
83
|
+
|
|
84
|
+
Update - 2025-08-01
|
|
85
|
+
~~~~~~~~~~~~~~~~~~~
|
|
86
|
+
|
|
87
|
+
Added package pythonic_fp.gadgets to the "name-claim" PyPI
|
|
88
|
+
project pythonic-fp. The gadgets library is for simple,
|
|
89
|
+
but useful, functions and data structures with minimal
|
|
90
|
+
dependencies.
|
|
@@ -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.4
|
|
2
|
+
Name: pythonic-fp-gadgets
|
|
3
|
+
Version: 4.0.2
|
|
4
|
+
Summary: Gadgets
|
|
5
|
+
Keywords: gadgets
|
|
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 :: 4 - Beta
|
|
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
|
+
License-File: LICENSE
|
|
17
|
+
Requires-Dist: pytest>=8.4.1 ; extra == "test"
|
|
18
|
+
Requires-Dist: pythonic-fp-circulararray>=6.0.1 ; extra == "test"
|
|
19
|
+
Project-URL: Changelog, https://github.com/grscheller/pythonic-fp-gadgets/blob/main/CHANGELOG.rst
|
|
20
|
+
Project-URL: Documentation, https://grscheller.github.io/pythonic-fp/gadgets/development/build/html/
|
|
21
|
+
Project-URL: Homepage, https://grscheller.github.io/pythonic-fp/homepage/build/html/
|
|
22
|
+
Project-URL: Source, https://github.com/grscheller/pythonic-fp-gadgets
|
|
23
|
+
Provides-Extra: test
|
|
24
|
+
|
|
25
|
+
Pythonic FP - Gadgets
|
|
26
|
+
=====================
|
|
27
|
+
|
|
28
|
+
PyPI project
|
|
29
|
+
`pythonic-fp-gadgets
|
|
30
|
+
<https://pypi.org/project/pythonic-fp>`_.
|
|
31
|
+
|
|
32
|
+
Library of simple, but useful, classes and functions with no dependencies
|
|
33
|
+
outside the Python Standard Library.
|
|
34
|
+
|
|
35
|
+
- Gadgets
|
|
36
|
+
|
|
37
|
+
- single item box
|
|
38
|
+
- function returning iterator of its arguments
|
|
39
|
+
- function to find the latest common ancestor of two classes
|
|
40
|
+
|
|
41
|
+
Part of the
|
|
42
|
+
`pythonic-fp
|
|
43
|
+
<https://grscheller.github.io/pythonic-fp>`_
|
|
44
|
+
PyPI projects.
|
|
45
|
+
|
|
46
|
+
Documentation
|
|
47
|
+
-------------
|
|
48
|
+
|
|
49
|
+
Documentation for this project is hosted on
|
|
50
|
+
`GitHub Pages
|
|
51
|
+
<https://grscheller.github.io/pythonic-fp/gadgets>`_.
|
|
52
|
+
|
|
53
|
+
Copyright and License
|
|
54
|
+
---------------------
|
|
55
|
+
|
|
56
|
+
Copyright (c) 2025 Geoffrey R. Scheller. Licensed under the Apache
|
|
57
|
+
License, Version 2.0. See the LICENSE file for details.
|
|
58
|
+
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
Pythonic FP - Gadgets
|
|
2
|
+
=====================
|
|
3
|
+
|
|
4
|
+
PyPI project
|
|
5
|
+
`pythonic-fp-gadgets
|
|
6
|
+
<https://pypi.org/project/pythonic-fp>`_.
|
|
7
|
+
|
|
8
|
+
Library of simple, but useful, classes and functions with no dependencies
|
|
9
|
+
outside the Python Standard Library.
|
|
10
|
+
|
|
11
|
+
- Gadgets
|
|
12
|
+
|
|
13
|
+
- single item box
|
|
14
|
+
- function returning iterator of its arguments
|
|
15
|
+
- function to find the latest common ancestor of two classes
|
|
16
|
+
|
|
17
|
+
Part of the
|
|
18
|
+
`pythonic-fp
|
|
19
|
+
<https://grscheller.github.io/pythonic-fp>`_
|
|
20
|
+
PyPI projects.
|
|
21
|
+
|
|
22
|
+
Documentation
|
|
23
|
+
-------------
|
|
24
|
+
|
|
25
|
+
Documentation for this project is hosted on
|
|
26
|
+
`GitHub Pages
|
|
27
|
+
<https://grscheller.github.io/pythonic-fp/gadgets>`_.
|
|
28
|
+
|
|
29
|
+
Copyright and License
|
|
30
|
+
---------------------
|
|
31
|
+
|
|
32
|
+
Copyright (c) 2025 Geoffrey R. Scheller. Licensed under the Apache
|
|
33
|
+
License, Version 2.0. See the LICENSE file for details.
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "pythonic-fp-gadgets"
|
|
3
|
+
version = "4.0.2"
|
|
4
|
+
readme = "README.rst"
|
|
5
|
+
requires-python = ">=3.13"
|
|
6
|
+
license = { file = "LICENSE" }
|
|
7
|
+
authors = [{ name = "Geoffrey R. Scheller", email = "geoffrey@scheller.com" }]
|
|
8
|
+
keywords = [
|
|
9
|
+
"gadgets",
|
|
10
|
+
]
|
|
11
|
+
classifiers = [
|
|
12
|
+
"Development Status :: 4 - Beta",
|
|
13
|
+
"Framework :: Pytest",
|
|
14
|
+
"Intended Audience :: Developers",
|
|
15
|
+
"License :: OSI Approved :: Apache Software License",
|
|
16
|
+
"Operating System :: OS Independent",
|
|
17
|
+
"Programming Language :: Python :: 3.13",
|
|
18
|
+
"Typing :: Typed",
|
|
19
|
+
]
|
|
20
|
+
dependencies = []
|
|
21
|
+
dynamic = ["description"]
|
|
22
|
+
|
|
23
|
+
[project.urls]
|
|
24
|
+
Changelog = "https://github.com/grscheller/pythonic-fp-gadgets/blob/main/CHANGELOG.rst"
|
|
25
|
+
Documentation = "https://grscheller.github.io/pythonic-fp/gadgets/development/build/html/"
|
|
26
|
+
Homepage = "https://grscheller.github.io/pythonic-fp/homepage/build/html/"
|
|
27
|
+
Source = "https://github.com/grscheller/pythonic-fp-gadgets"
|
|
28
|
+
|
|
29
|
+
[project.optional-dependencies]
|
|
30
|
+
test = [
|
|
31
|
+
"pytest>=8.4.1",
|
|
32
|
+
"pythonic-fp-circulararray>=6.0.1",
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
[build-system]
|
|
36
|
+
requires = ["flit_core>=3.12,<4"]
|
|
37
|
+
build-backend = "flit_core.buildapi"
|
|
38
|
+
|
|
39
|
+
[tool.flit.module]
|
|
40
|
+
name = "pythonic_fp.gadgets"
|
|
41
|
+
|
|
42
|
+
[tool.mypy]
|
|
43
|
+
enable_incomplete_feature = "NewGenericSyntax"
|
|
44
|
+
explicit_package_bases = true
|
|
45
|
+
implicit_reexport = false
|
|
46
|
+
local_partial_types = true
|
|
47
|
+
namespace_packages = true
|
|
48
|
+
warn_redundant_casts = true
|
|
49
|
+
warn_return_any = true
|
|
50
|
+
warn_unused_configs = true
|
|
51
|
+
|
|
52
|
+
[tool.pylsp-mypy]
|
|
53
|
+
enabled = true
|
|
54
|
+
live-mode = true
|
|
55
|
+
dmypy = false
|
|
56
|
+
strict = true
|
|
57
|
+
report_progress = true
|
|
58
|
+
|
|
59
|
+
[tool.pytest.ini_options]
|
|
60
|
+
addopts = "-ra"
|
|
61
|
+
consider_namespace_packages = true
|
|
62
|
+
testpaths = ["tests/"]
|
|
63
|
+
|
|
64
|
+
[tool.ruff]
|
|
65
|
+
target-version = "py313"
|
|
66
|
+
|
|
67
|
+
[tool.ruff.lint.flake8-quotes]
|
|
68
|
+
docstring-quotes = "double"
|
|
69
|
+
|
|
70
|
+
[tool.ruff.lint.per-file-ignores]
|
|
71
|
+
"tests/*" = ["C901"]
|
|
72
|
+
"tests/**/*.py" = ['E731']
|
|
73
|
+
"**/*.py" = ["E741"]
|
|
74
|
+
|
|
75
|
+
[tool.ruff.format]
|
|
76
|
+
quote-style = "single"
|
|
77
|
+
docstring-code-line-length = 72
|
|
@@ -0,0 +1,85 @@
|
|
|
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
|
+
"""
|
|
16
|
+
Gadgets
|
|
17
|
+
-------
|
|
18
|
+
|
|
19
|
+
.. admonition:: Collection of mostly self-contained functions and classes
|
|
20
|
+
|
|
21
|
+
- Functions and classes which could go multiple places or have
|
|
22
|
+
no good place to go.
|
|
23
|
+
- Self-contained with minimal dependencies.
|
|
24
|
+
- No pythonic_fp dependencies.
|
|
25
|
+
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
from collections.abc import Iterator
|
|
29
|
+
from inspect import getmro
|
|
30
|
+
|
|
31
|
+
__all__ = ['first_common_ancestor', 'iterate_over_arguments']
|
|
32
|
+
|
|
33
|
+
__author__ = 'Geoffrey R. Scheller'
|
|
34
|
+
__copyright__ = 'Copyright (c) 2023-2025 Geoffrey R. Scheller'
|
|
35
|
+
__license__ = 'Apache License 2.0'
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def first_common_ancestor(cls1: type, cls2: type) -> type:
|
|
39
|
+
"""Find the least upper bound in the inheritance graph
|
|
40
|
+
of two classes.
|
|
41
|
+
|
|
42
|
+
.. warning::
|
|
43
|
+
|
|
44
|
+
This function can fail with a TypeError. Some error messages
|
|
45
|
+
seen are
|
|
46
|
+
|
|
47
|
+
- multiple bases have instance lay-out conflict
|
|
48
|
+
- type 'bool' is not an acceptable base type
|
|
49
|
+
|
|
50
|
+
This happens frequently when the function is given
|
|
51
|
+
Python builtin types or in multiple inheritance situations.
|
|
52
|
+
|
|
53
|
+
:param cls1: A class in the inheritance hierarchy.
|
|
54
|
+
:param cls2: A class in the inheritance hierarchy.
|
|
55
|
+
:returns: First common ancestor based on getmro order.
|
|
56
|
+
:raises TypeError: Raised when no common ancestor or not
|
|
57
|
+
caught when raised by ``inspect.getmro``.
|
|
58
|
+
|
|
59
|
+
"""
|
|
60
|
+
if issubclass(cls1, cls2):
|
|
61
|
+
return cls2
|
|
62
|
+
if issubclass(cls2, cls1):
|
|
63
|
+
return cls1
|
|
64
|
+
|
|
65
|
+
for common_ancestor in getmro(type('LcaDiamondClass', (cls1, cls2), {})):
|
|
66
|
+
if issubclass(cls1, common_ancestor) and issubclass(cls2, common_ancestor):
|
|
67
|
+
return common_ancestor
|
|
68
|
+
raise TypeError("latest_common_ancestor: no common ancestor found!!!")
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def iterate_over_arguments[A](*args: A) -> Iterator[A]:
|
|
72
|
+
"""Function returning an iterator of its arguments.
|
|
73
|
+
|
|
74
|
+
.. note::
|
|
75
|
+
|
|
76
|
+
Does not create an object to iterate over.
|
|
77
|
+
|
|
78
|
+
- well, not in the Python world
|
|
79
|
+
- maybe in the C world
|
|
80
|
+
|
|
81
|
+
:param args: Objects to iterate over.
|
|
82
|
+
:returns: An iterator of the functions arguments.
|
|
83
|
+
|
|
84
|
+
"""
|
|
85
|
+
yield from args
|