ft3 0.0.1__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.
Files changed (116) hide show
  1. ft3-0.0.1/LICENSE +165 -0
  2. ft3-0.0.1/PKG-INFO +443 -0
  3. ft3-0.0.1/README.md +407 -0
  4. ft3-0.0.1/pyproject.toml +179 -0
  5. ft3-0.0.1/setup.cfg +4 -0
  6. ft3-0.0.1/src/ft3/__init__.py +56 -0
  7. ft3-0.0.1/src/ft3/cli/__init__.py +31 -0
  8. ft3-0.0.1/src/ft3/cli/cfg.py +11 -0
  9. ft3-0.0.1/src/ft3/cli/lib.py +7 -0
  10. ft3-0.0.1/src/ft3/cli/obj.py +34 -0
  11. ft3-0.0.1/src/ft3/cli/utl.py +25 -0
  12. ft3-0.0.1/src/ft3/core/__init__.py +37 -0
  13. ft3-0.0.1/src/ft3/core/cfg.py +67 -0
  14. ft3-0.0.1/src/ft3/core/codecs/__init__.py +15 -0
  15. ft3-0.0.1/src/ft3/core/codecs/cfg.py +46 -0
  16. ft3-0.0.1/src/ft3/core/codecs/enm.py +65 -0
  17. ft3-0.0.1/src/ft3/core/codecs/lib.py +20 -0
  18. ft3-0.0.1/src/ft3/core/codecs/typ.py +14 -0
  19. ft3-0.0.1/src/ft3/core/codecs/utl.py +352 -0
  20. ft3-0.0.1/src/ft3/core/enm.py +23 -0
  21. ft3-0.0.1/src/ft3/core/exc.py +39 -0
  22. ft3-0.0.1/src/ft3/core/lib.py +57 -0
  23. ft3-0.0.1/src/ft3/core/strings/__init__.py +19 -0
  24. ft3-0.0.1/src/ft3/core/strings/cfg.py +55 -0
  25. ft3-0.0.1/src/ft3/core/strings/enm.py +20 -0
  26. ft3-0.0.1/src/ft3/core/strings/exc.py +29 -0
  27. ft3-0.0.1/src/ft3/core/strings/lib.py +7 -0
  28. ft3-0.0.1/src/ft3/core/strings/obj.py +448 -0
  29. ft3-0.0.1/src/ft3/core/strings/typ.py +7 -0
  30. ft3-0.0.1/src/ft3/core/strings/utl.py +410 -0
  31. ft3-0.0.1/src/ft3/core/typ/__init__.py +52 -0
  32. ft3-0.0.1/src/ft3/core/typ/cfg.py +11 -0
  33. ft3-0.0.1/src/ft3/core/typ/lib.py +16 -0
  34. ft3-0.0.1/src/ft3/core/typ/obj.py +560 -0
  35. ft3-0.0.1/src/ft3/core/typ/typ.py +123 -0
  36. ft3-0.0.1/src/ft3/core/typ/utl/__init__.py +9 -0
  37. ft3-0.0.1/src/ft3/core/typ/utl/check.py +550 -0
  38. ft3-0.0.1/src/ft3/core/typ/utl/hint.py +189 -0
  39. ft3-0.0.1/src/ft3/docs/__init__.py +33 -0
  40. ft3-0.0.1/src/ft3/docs/cfg.py +25 -0
  41. ft3-0.0.1/src/ft3/docs/enm.py +45 -0
  42. ft3-0.0.1/src/ft3/docs/lib.py +16 -0
  43. ft3-0.0.1/src/ft3/docs/obj.py +173 -0
  44. ft3-0.0.1/src/ft3/docs/static/__init__.py +12 -0
  45. ft3-0.0.1/src/ft3/docs/static/conf.tpl +106 -0
  46. ft3-0.0.1/src/ft3/docs/static/favicon.ico +0 -0
  47. ft3-0.0.1/src/ft3/docs/static/logo.png +0 -0
  48. ft3-0.0.1/src/ft3/docs/utl.py +437 -0
  49. ft3-0.0.1/src/ft3/loggers/__init__.py +55 -0
  50. ft3-0.0.1/src/ft3/loggers/cfg.py +26 -0
  51. ft3-0.0.1/src/ft3/loggers/exc.py +37 -0
  52. ft3-0.0.1/src/ft3/loggers/lib.py +18 -0
  53. ft3-0.0.1/src/ft3/loggers/obj.py +291 -0
  54. ft3-0.0.1/src/ft3/loggers/typ.py +59 -0
  55. ft3-0.0.1/src/ft3/loggers/utl.py +108 -0
  56. ft3-0.0.1/src/ft3/objects/__init__.py +48 -0
  57. ft3-0.0.1/src/ft3/objects/cfg.py +79 -0
  58. ft3-0.0.1/src/ft3/objects/enm.py +26 -0
  59. ft3-0.0.1/src/ft3/objects/exc.py +299 -0
  60. ft3-0.0.1/src/ft3/objects/fields/__init__.py +10 -0
  61. ft3-0.0.1/src/ft3/objects/fields/obj.py +781 -0
  62. ft3-0.0.1/src/ft3/objects/lib.py +20 -0
  63. ft3-0.0.1/src/ft3/objects/metas/__init__.py +12 -0
  64. ft3-0.0.1/src/ft3/objects/metas/obj.py +309 -0
  65. ft3-0.0.1/src/ft3/objects/metas/utl.py +181 -0
  66. ft3-0.0.1/src/ft3/objects/objs/__init__.py +10 -0
  67. ft3-0.0.1/src/ft3/objects/objs/obj.py +922 -0
  68. ft3-0.0.1/src/ft3/objects/queries/__init__.py +11 -0
  69. ft3-0.0.1/src/ft3/objects/queries/obj.py +213 -0
  70. ft3-0.0.1/src/ft3/objects/typ.py +54 -0
  71. ft3-0.0.1/src/ft3/objects/utl.py +130 -0
  72. ft3-0.0.1/src/ft3.egg-info/PKG-INFO +443 -0
  73. ft3-0.0.1/src/ft3.egg-info/SOURCES.txt +114 -0
  74. ft3-0.0.1/src/ft3.egg-info/dependency_links.txt +1 -0
  75. ft3-0.0.1/src/ft3.egg-info/entry_points.txt +2 -0
  76. ft3-0.0.1/src/ft3.egg-info/requires.txt +17 -0
  77. ft3-0.0.1/src/ft3.egg-info/top_level.txt +2 -0
  78. ft3-0.0.1/src/tests/__init__.py +7 -0
  79. ft3-0.0.1/src/tests/ci/__init__.py +7 -0
  80. ft3-0.0.1/src/tests/ci/cfg.py +9 -0
  81. ft3-0.0.1/src/tests/ci/commit_msg_test.py +105 -0
  82. ft3-0.0.1/src/tests/core/__init__.py +7 -0
  83. ft3-0.0.1/src/tests/core/cfg.py +11 -0
  84. ft3-0.0.1/src/tests/core/codecs/__init__.py +7 -0
  85. ft3-0.0.1/src/tests/core/codecs/cfg.py +11 -0
  86. ft3-0.0.1/src/tests/core/codecs/utl_test.py +463 -0
  87. ft3-0.0.1/src/tests/core/strings/__init__.py +7 -0
  88. ft3-0.0.1/src/tests/core/strings/cfg.py +15 -0
  89. ft3-0.0.1/src/tests/core/strings/exc_test.py +29 -0
  90. ft3-0.0.1/src/tests/core/strings/utl_test.py +190 -0
  91. ft3-0.0.1/src/tests/core/typings/__init__.py +7 -0
  92. ft3-0.0.1/src/tests/core/typings/cfg.py +13 -0
  93. ft3-0.0.1/src/tests/core/typings/utl_test.py +148 -0
  94. ft3-0.0.1/src/tests/loggers/__init__.py +7 -0
  95. ft3-0.0.1/src/tests/loggers/backup.py +397 -0
  96. ft3-0.0.1/src/tests/loggers/cfg.py +11 -0
  97. ft3-0.0.1/src/tests/loggers/exc_test.py +19 -0
  98. ft3-0.0.1/src/tests/loggers/obj_test.py +510 -0
  99. ft3-0.0.1/src/tests/mocking/__init__.py +103 -0
  100. ft3-0.0.1/src/tests/mocking/examples.py +13 -0
  101. ft3-0.0.1/src/tests/objects/__init__.py +7 -0
  102. ft3-0.0.1/src/tests/objects/cfg.py +11 -0
  103. ft3-0.0.1/src/tests/objects/exc_test.py +78 -0
  104. ft3-0.0.1/src/tests/objects/fields/__init__.py +7 -0
  105. ft3-0.0.1/src/tests/objects/fields/cfg.py +11 -0
  106. ft3-0.0.1/src/tests/objects/fields/fields_test.py +299 -0
  107. ft3-0.0.1/src/tests/objects/metas/__init__.py +7 -0
  108. ft3-0.0.1/src/tests/objects/metas/cfg.py +11 -0
  109. ft3-0.0.1/src/tests/objects/metas/metas_test.py +333 -0
  110. ft3-0.0.1/src/tests/objects/objs/__init__.py +7 -0
  111. ft3-0.0.1/src/tests/objects/objs/cfg.py +11 -0
  112. ft3-0.0.1/src/tests/objects/objs/objs_test.py +382 -0
  113. ft3-0.0.1/src/tests/objects/queries/__init__.py +7 -0
  114. ft3-0.0.1/src/tests/objects/queries/cfg.py +11 -0
  115. ft3-0.0.1/src/tests/objects/queries/queries_test.py +175 -0
  116. ft3-0.0.1/src/tests/readme_test.py +134 -0
ft3-0.0.1/LICENSE ADDED
@@ -0,0 +1,165 @@
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
ft3-0.0.1/PKG-INFO ADDED
@@ -0,0 +1,443 @@
1
+ Metadata-Version: 2.1
2
+ Name: ft3
3
+ Version: 0.0.1
4
+ Summary: Zero-dependency Python framework for object oriented development.
5
+ Author-email: Dan <dan@1howardcapital.com>
6
+ Maintainer-email: Dan <dan@1howardcapital.com>
7
+ Project-URL: Documentation, https://ft3.readthedocs.io/en/stable/ft3.html
8
+ Project-URL: Homepage, https://ft3.readthedocs.io/en/stable/
9
+ Project-URL: Repository, https://github.com/dan1hc/ft3.git
10
+ Project-URL: Issues, https://github.com/dan1hc/ft3/issues
11
+ Project-URL: Changelog, https://github.com/dan1hc/ft3/blob/main/CHANGELOG.md
12
+ Keywords: dataclasses,ft3,framework,openapi,rest,swagger
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
19
+ Classifier: Typing :: Typed
20
+ Requires-Python: >=3.10
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Requires-Dist: typing_extensions; python_version < "3.11"
24
+ Provides-Extra: develop
25
+ Requires-Dist: mypy==1.11.*; extra == "develop"
26
+ Requires-Dist: pre-commit==3.7.*; extra == "develop"
27
+ Requires-Dist: coverage==7.6.*; extra == "develop"
28
+ Requires-Dist: pytest==8.3.*; extra == "develop"
29
+ Requires-Dist: pytest-cov==5.0.*; extra == "develop"
30
+ Requires-Dist: ruff==0.5.*; extra == "develop"
31
+ Requires-Dist: commonmark==0.9.*; extra == "develop"
32
+ Requires-Dist: sphinx==7.*; extra == "develop"
33
+ Provides-Extra: docs
34
+ Requires-Dist: commonmark==0.9.*; extra == "docs"
35
+ Requires-Dist: sphinx==7.*; extra == "docs"
36
+
37
+ # [![banner](https://1howardcapital.s3.amazonaws.com/images/ft3/banner.png)](https://ft3.readthedocs.io)
38
+
39
+ [![MinVersion](https://img.shields.io/python/required-version-toml?tomlFilePath=https://raw.githubusercontent.com/dan1hc/ft3/main/pyproject.toml&color=gold)](https://pypi.org/project/ft3)
40
+ [![PyVersions](https://img.shields.io/pypi/pyversions/ft3?color=brightgreen)](https://pypi.org/project/ft3)
41
+ [![readthedocs](https://readthedocs.org/projects/ft3/badge)](https://ft3.readthedocs.io)
42
+ [![CI](https://github.com/dan1hc/ft3/actions/workflows/main.yml/badge.svg?branch=main&event=push)](https://github.com/dan1hc/ft3/actions)
43
+ [![codeql](https://github.com/dan1hc/ft3/workflows/codeql/badge.svg)](https://github.com/dan1hc/ft3/actions/workflows/codeql.yml)
44
+ [![coverage](https://img.shields.io/badge/dynamic/toml?url=https://raw.githubusercontent.com/dan1hc/ft3/main/pyproject.toml&query=tool.coverage.report.fail_under&label=coverage&suffix=%25&color=brightgreen)](https://github.com/dan1hc/ft3/actions)
45
+ [![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)
46
+ [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
47
+ [![mypy](https://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/)
48
+ [![PyPI](https://img.shields.io/pypi/v/ft3?color=blue)](https://pypi.org/project/ft3)
49
+ [![License](https://img.shields.io/pypi/l/ft3?color=blue)](https://www.gnu.org/licenses/lgpl-3.0)
50
+
51
+ # Overview
52
+
53
+ **Author:** dan@1howardcapital.com | daniel.dube@annalect.com
54
+
55
+ **Summary:** Zero-dependency python framework for object oriented development.
56
+ Implement _once_, document _once_, in _one_ place.
57
+
58
+ > With ft3, you will quickly learn established best practice...
59
+ > or face the consequences of runtime errors that will break your code
60
+ > if you deviate from it.
61
+ >
62
+ > Experienced python engineers will find a framework
63
+ > that expects and rewards intuitive magic method usage,
64
+ > consistent type annotations, and robust docstrings.
65
+ >
66
+ > Implement _pythonically_ with ft3 and you will only ever need to:
67
+ > implement _once_, document _once_, in _one_ place.
68
+
69
+ ---
70
+
71
+ ## Mission Statement
72
+
73
+ Ultimately, ft3 seeks to capture and abstract all recurring patterns in
74
+ application development with known, optimal implementations, so engineers
75
+ can focus more on clever implementation of application-specific logic and good
76
+ documentation than on things like how to query X database most efficiently,
77
+ whether or not everything important is being logged correctly, where to
78
+ put what documentation, and how to implement an effective change management
79
+ scheme with git in the first place.
80
+
81
+ ## Getting Started
82
+
83
+ ### Installation
84
+
85
+ ```bash
86
+ pip install ft3
87
+ ```
88
+
89
+ ### Basic Usage
90
+
91
+ ```py
92
+ import ft3
93
+
94
+
95
+ class Pet(ft3.Object):
96
+ """A pet."""
97
+
98
+ id_: ft3.Field[int]
99
+ name: ft3.Field[str]
100
+ type_: ft3.Field[str] = {
101
+ 'default': 'dog',
102
+ 'enum': ['cat', 'dog'],
103
+ 'nullable': False,
104
+ 'required': True,
105
+ }
106
+ is_tail_wagging: ft3.Field[bool] = ft3.Field(
107
+ default=True,
108
+ enum=[True, False],
109
+ nullable=False,
110
+ required=True,
111
+ )
112
+
113
+ ```
114
+
115
+ ## Best Practice - Guard Rails at a Bowling Alley
116
+
117
+ ft3 has been designed from the outset to teach best practice to less
118
+ experienced python engineers, without compromising their ability to
119
+ make effective and timely contributions.
120
+
121
+ > To ft3, it is more important developers are able to make
122
+ > effective contributions while learning, rather than sacrifice
123
+ > any contribution at all until the developer fully understands
124
+ > why something that could be done many ways should only ever
125
+ > be done one way.
126
+
127
+ #### Exceptions
128
+
129
+ This is achieved primarily through the raising of exceptions.
130
+ In many cases, if a developer inadvertently deviaties from a known
131
+ best practice, ft3 will raise a code-breaking error (informing
132
+ the developer of the violation) until the developer implements
133
+ the optimal solution.
134
+
135
+ #### Logging
136
+
137
+ ft3 will commandeer your application's log.
138
+
139
+ * It will automatically redact sensitive data inadvertently introduced
140
+ to your log stream that would have made your application fail audits.
141
+ * It will intercept, warn once, and subsequently silence print statements,
142
+ debug statements, and other errant attempts at logging information in ways
143
+ certain to introduce a known anti-pattern, vulnerability, or otherwise
144
+ pollute your log stream.
145
+
146
+ > In short, if ft3 raises an error or otherwise does not support
147
+ > the thing you are trying to do: it is because the way in which you
148
+ > are trying to do it contains at least one anti-pattern to a known,
149
+ > optimal solution.
150
+
151
+ ## Example Usage
152
+
153
+ ```py
154
+ import ft3
155
+
156
+
157
+ class Flea(ft3.Object):
158
+ """A nuisance."""
159
+
160
+ name: ft3.Field[str] = 'FLEA'
161
+
162
+
163
+ class Pet(ft3.Object):
164
+ """A pet."""
165
+
166
+ id_: ft3.Field[str]
167
+ _alternate_id: ft3.Field[int]
168
+
169
+ name: ft3.Field[str]
170
+ type_: ft3.Field[str] = {
171
+ 'default': 'dog',
172
+ 'enum': ['cat', 'dog'],
173
+ 'nullable': False,
174
+ 'required': True,
175
+ }
176
+
177
+ in_: ft3.Field[str]
178
+ is_tail_wagging: ft3.Field[bool] = ft3.Field(
179
+ default=True,
180
+ enum=[True, False],
181
+ nullable=False,
182
+ required=True,
183
+ )
184
+
185
+ fleas: ft3.Field[list[Flea]] = [
186
+ Flea(name='flea1'),
187
+ Flea(name='flea2')
188
+ ]
189
+
190
+
191
+ # Automatic case handling.
192
+ request_body = {
193
+ 'id': 'abc123',
194
+ 'alternateId': 123,
195
+ 'name': 'Bob',
196
+ 'type': 'dog',
197
+ 'in': 'timeout',
198
+ 'isTailWagging': False
199
+ }
200
+ pet = Pet(request_body)
201
+
202
+ assert pet.is_snake_case == Pet.is_snake_case is True
203
+ assert pet.is_camel_case == Pet.is_camel_case is False
204
+ assert pet['alternate_id'] == pet._alternate_id == request_body['alternateId']
205
+ assert dict(pet) == {k: v for k, v in pet.items()} == pet.to_dict()
206
+
207
+ # Automatic, mutation-safe "default factory".
208
+ dog = Pet(id='abc321', alternate_id=321, name='Fido')
209
+ assert pet.fleas[0] is not dog.fleas[0]
210
+
211
+ # Automatic memory optimization.
212
+ assert Flea().__sizeof__() == (len(Flea.__slots__) * 8) + 16 == 32
213
+
214
+ class Flet(Flea, Pet):
215
+ ...
216
+
217
+ class Pea(Pet, Flea):
218
+ ...
219
+
220
+ assert Flet().__sizeof__() == (len(Flet.__base__.__slots__) * 8) + 16 == 80
221
+ assert Pea().__sizeof__() == (len(Pea.__base__.__slots__) * 8) + 16 == 80
222
+ assert Flet().name == 'FLEA' != Pea().name
223
+
224
+ # Intuitive, database agnostic query generation.
225
+ assert isinstance(Pet.is_tail_wagging, ft3.Field)
226
+ assert isinstance(Pet.type_, ft3.Field)
227
+
228
+ assert dog.type_ == Pet.type_.default == 'dog'
229
+
230
+ query = (
231
+ (
232
+ (Pet.type_ == 'dog')
233
+ & (Pet.name == 'Fido')
234
+ )
235
+ | Pet.name % ('fido', 0.75)
236
+ )
237
+ query += 'name'
238
+ assert dict(query) == {
239
+ 'limit': None,
240
+ 'or': [
241
+ {
242
+ 'and': [
243
+ {
244
+ 'eq': 'dog',
245
+ 'field': 'type',
246
+ 'limit': None,
247
+ 'sorting': []
248
+ },
249
+ {
250
+ 'eq': 'Fido',
251
+ 'field': 'name',
252
+ 'limit': None,
253
+ 'sorting': []
254
+ }
255
+ ],
256
+ 'limit': None,
257
+ 'sorting': []
258
+ },
259
+ {
260
+ 'field': 'name',
261
+ 'like': 'fido',
262
+ 'limit': None,
263
+ 'sorting': [],
264
+ 'threshold': 0.75
265
+ }
266
+ ],
267
+ 'sorting': [
268
+ {
269
+ 'direction': 'asc',
270
+ 'field': 'name'
271
+ }
272
+ ]
273
+ }
274
+
275
+ ```
276
+
277
+ ### Local Logging
278
+ ```py
279
+ import ft3
280
+
281
+
282
+ class AgentFlea(ft3.Object):
283
+ """Still a nuisance."""
284
+
285
+ name: ft3.Field[str] = 'FLEA'
286
+ api_key: ft3.Field[str] = '9ac868264f004600bdff50b7f5b3e8ad'
287
+ aws_access_key_id: ft3.Field[str] = 'falsePositive'
288
+ sneaky: ft3.Field[str] = 'AKIARJFBAG3EGHFG2FPN'
289
+
290
+
291
+ # Automatic log configuration, cleansing, and redaction.
292
+
293
+ print(AgentFlea())
294
+ # >>>
295
+ # {
296
+ # "level": WARNING,
297
+ # "time": 2024-02-26 18:50:20.317 UTC,
298
+ # "log": ft3.core.log,
299
+ # "data": {
300
+ # "message": "Calls to print() will be silenced by ft3."
301
+ # }
302
+ # }
303
+ # {
304
+ # "api_key": "[ REDACTED :: API KEY ]",
305
+ # "aws_access_key_id": "falsePositive",
306
+ # "name": "FLEA",
307
+ # "sneaky": "[ REDACTED :: AWS ACCESS KEY ID ]"
308
+ # }
309
+
310
+ print(AgentFlea())
311
+ # >>>
312
+ # {
313
+ # "api_key": "[ REDACTED :: API KEY ]",
314
+ # "aws_access_key_id": "falsePositive",
315
+ # "name": "FLEA",
316
+ # "sneaky": "[ REDACTED :: AWS ACCESS KEY ID ]"
317
+ # }
318
+
319
+ ```
320
+
321
+ ### Deployed Logging
322
+
323
+ ```py
324
+ import os
325
+ os.environ['ENV'] = 'DEV'
326
+
327
+ import ft3
328
+
329
+ assert (
330
+ ft3.core.constants.PackageConstants.ENV
331
+ in {
332
+ 'dev', 'develop',
333
+ 'qa', 'test', 'testing',
334
+ 'uat', 'stg', 'stage', 'staging',
335
+ 'prod', 'production',
336
+ }
337
+ )
338
+
339
+
340
+ class AgentFlea(ft3.Object):
341
+ """Still a nuisance."""
342
+
343
+ name: ft3.Field[str] = 'FLEA'
344
+ api_key: ft3.Field[str] = '9ac868264f004600bdff50b7f5b3e8ad'
345
+ aws_access_key_id: ft3.Field[str] = 'falsePositive'
346
+ sneaky: ft3.Field[str] = 'AKIARJFBAG3EGHFG2FPN'
347
+
348
+
349
+ print(AgentFlea())
350
+ # >>>
351
+ # {
352
+ # "level": WARNING,
353
+ # "time": 2024-02-26 19:02:29.020 UTC,
354
+ # "log": ft3.core.log,
355
+ # "data": {
356
+ # "message": "Call to print() silenced by ft3.",
357
+ # "printed": "{\n \"api_key\": \"[ REDACTED :: API KEY ]\",\n \"aws_access_key_id\": \"falsePositive\",\n \"name\": \"FLEA\",\n \"sneaky\": \"[ REDACTED :: AWS ACCESS KEY ID ]\"\n}"
358
+ # }
359
+ # }
360
+
361
+ print(AgentFlea())
362
+ # >>>
363
+
364
+ ft3.log.info(AgentFlea())
365
+ # >>>
366
+ # {
367
+ # "level": INFO,
368
+ # "time": 2024-02-26 19:13:21.726 UTC,
369
+ # "log": ft3.core.log,
370
+ # "data": {
371
+ # "AgentFlea": {
372
+ # "api_key": "[ REDACTED :: API KEY ]",
373
+ # "aws_access_key_id": "falsePositive",
374
+ # "name": "FLEA",
375
+ # "sneaky": "[ REDACTED :: AWS ACCESS KEY ID ]"
376
+ # }
377
+ # }
378
+ # }
379
+
380
+ ```
381
+
382
+ ## Planned Features
383
+
384
+ * #### RESTful Framework / OpenAPI Support
385
+ * ft3 should support all aspects of an OpenAPI specification and
386
+ provide corresponding framework functionality for HTTP request
387
+ handling.
388
+ * #### Template Packages
389
+ * ft3 should include a Pet shop style demo API and python package
390
+ as a template for developers to copy / paste from.
391
+ * #### Database Parse & Sync
392
+ * ft3 should be able to generate a python package with fully enumerated
393
+ and optimized `Objects` (and a corresponding ft3 API package) when
394
+ supplied with access to a database for which at least one schema may be
395
+ inferred.
396
+ * CLI commands like `$ ft3-api-from-sql ${api_name} ${sql_conn_string} .`
397
+ should instantly output two ideally structured package repositories for a
398
+ RESTful python API and corresponding object management package.
399
+ * The package could use any supplied credentials to either query a database
400
+ directly or make requests to a deployed API. This means the same package
401
+ used to power the API can be distributed and pip installed across an
402
+ organization so business intelligence, data science, and other technical
403
+ team members can manipulate data for their needs, while leaning on
404
+ the package to optimize queries and stay informed around permission
405
+ boundaries and request limits.
406
+ * #### Repo Generation
407
+ * ft3 should be expanded to optionally wrap any generated packages
408
+ in a repository pre-configured with essentials and CI that should:
409
+ * implement an ideal [trunk-based branch strategy](https://trunkbaseddevelopment.com/),
410
+ inline with current best practices for change management and
411
+ developer collaboration
412
+ * enforce python code style best practices through automated
413
+ [linting and formatting](https://docs.astral.sh/ruff)
414
+ * type-check python code and generate a report with [mypy](https://mypy.readthedocs.io/en/stable/index.html)
415
+ * run tests automatically, generate reports, and prevent commits that break tests
416
+ * automatically prevent commits that do not adhere to standardized commit
417
+ message [conventions](https://www.conventionalcommits.org/en/v1.0.0/)
418
+ * using those conventions, automatically [semantically version](https://python-semantic-release.readthedocs.io/en/stable/#getting-started)
419
+ each successful PR and automatically generate and update a
420
+ CHANGELOG.md file
421
+ * automatically generate and publish secure wiki documentation
422
+ * Generated repos may contain up to all of the following:
423
+ * CHANGELOG.md
424
+ * CODEOWNERS
425
+ * CONTRIBUTING.md
426
+ * .git
427
+ * .git/hooks/
428
+ * .github/workflows/
429
+ * Support planned for gitlab and bamboo.
430
+ * .gitignore
431
+ * LICENSE
432
+ * [.pre-commit-config.yaml](https://pre-commit.com/#intro)
433
+ * pyproject.toml
434
+ * README.md
435
+ * /src
436
+ * /package
437
+ * /tests
438
+
439
+ ## Acknowledgments
440
+
441
+ * #### @sol.courtney
442
+ * Teaching me the difference between chicken-scratch, duct tape, and bubble
443
+ gum versus actual engineering, and why it matters.