pytypeform 0.2.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.
Potentially problematic release.
This version of pytypeform might be problematic. Click here for more details.
- pytypeform-0.2.1/.gitignore +147 -0
- pytypeform-0.2.1/LICENSE +186 -0
- pytypeform-0.2.1/NOTICE +5 -0
- pytypeform-0.2.1/PKG-INFO +145 -0
- pytypeform-0.2.1/README.md +105 -0
- pytypeform-0.2.1/pyproject.toml +112 -0
- pytypeform-0.2.1/src/pytypeform/__init__.py +4 -0
- pytypeform-0.2.1/src/pytypeform/core.py +280 -0
- pytypeform-0.2.1/src/typeform/__init__.py +4 -0
- pytypeform-0.2.1/src/typeform/core.py +280 -0
- pytypeform-0.2.1/tests/test_core.py +111 -0
- pytypeform-0.2.1/tests/test_extended.py +91 -0
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py,cover
|
|
50
|
+
.組合
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
pytestdebug.log
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the Python version is usually managed by the user.
|
|
87
|
+
# .python-version
|
|
88
|
+
|
|
89
|
+
# pipenv
|
|
90
|
+
# According to pypa/pipenv#1185, it is recommended to include Pipfile.lock in version control.
|
|
91
|
+
# However, in case of collaboration, if you want to keep your development environment from being shared with others, you can ignore these files.
|
|
92
|
+
# Pipfile.lock
|
|
93
|
+
|
|
94
|
+
# poetry
|
|
95
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
96
|
+
# poetry.lock
|
|
97
|
+
|
|
98
|
+
# pdm
|
|
99
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
100
|
+
# pdm.lock
|
|
101
|
+
|
|
102
|
+
# PEP 582; used by e.g. github.com/pdm-project/pdm
|
|
103
|
+
__pypackages__/
|
|
104
|
+
|
|
105
|
+
# Celery stuff
|
|
106
|
+
celerybeat-schedule
|
|
107
|
+
celerybeat.pid
|
|
108
|
+
|
|
109
|
+
# SageMath stuff
|
|
110
|
+
*.sage.py
|
|
111
|
+
|
|
112
|
+
# Environments
|
|
113
|
+
.env
|
|
114
|
+
.venv
|
|
115
|
+
env/
|
|
116
|
+
venv/
|
|
117
|
+
ENV/
|
|
118
|
+
env.bak/
|
|
119
|
+
venv.bak/
|
|
120
|
+
|
|
121
|
+
# Spyder project settings
|
|
122
|
+
.spyderproject
|
|
123
|
+
.spyproject
|
|
124
|
+
|
|
125
|
+
# Rope project settings
|
|
126
|
+
.ropeproject
|
|
127
|
+
|
|
128
|
+
# mkdocs documentation
|
|
129
|
+
/site
|
|
130
|
+
|
|
131
|
+
# mypy
|
|
132
|
+
.mypy_cache/
|
|
133
|
+
.dmypy.json
|
|
134
|
+
dmypy.json
|
|
135
|
+
|
|
136
|
+
# Pyre type checker
|
|
137
|
+
.pyre/
|
|
138
|
+
|
|
139
|
+
# pytype static analyzer
|
|
140
|
+
.pytype/
|
|
141
|
+
|
|
142
|
+
# Cython debug symbols
|
|
143
|
+
cython_debug/
|
|
144
|
+
|
|
145
|
+
# OS metadata
|
|
146
|
+
.DS_Store
|
|
147
|
+
Thumbs.db
|
pytypeform-0.2.1/LICENSE
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
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 made available under
|
|
36
|
+
the License, as indicated by a copyright notice that is included in
|
|
37
|
+
or attached to the work (an example is provided in the Appendix below).
|
|
38
|
+
|
|
39
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
40
|
+
form, that is based on (or derived from) the Work and for which the
|
|
41
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
42
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
43
|
+
of this License, Derivative Works shall not include works that remain
|
|
44
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
45
|
+
the Work and Derivative Works thereof.
|
|
46
|
+
|
|
47
|
+
"Contribution" shall mean, as submitted to the Licensor for inclusion
|
|
48
|
+
in the Work by the copyright owner or by an individual or Legal Entity
|
|
49
|
+
authorized to submit on behalf of the copyright owner. For the purposes
|
|
50
|
+
of this definition, "submit" means any form of electronic, verbal, or
|
|
51
|
+
written communication sent to the Licensor or its representatives,
|
|
52
|
+
including but not limited to communication on electronic mailing lists,
|
|
53
|
+
source code control systems, and issue tracking systems that are managed
|
|
54
|
+
by, or on behalf of, the Licensor for the purpose of discussing and
|
|
55
|
+
improving the Work, but excluding communication that is conspicuously
|
|
56
|
+
marked or designated in writing by the copyright owner as "Not a
|
|
57
|
+
Contribution."
|
|
58
|
+
|
|
59
|
+
"Contributor" shall mean Licensor and any Legal Entity on behalf of
|
|
60
|
+
whom a Contribution has been received by the Licensor and included
|
|
61
|
+
within the Work.
|
|
62
|
+
|
|
63
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
64
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
65
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
66
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
67
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
68
|
+
Work and such Derivative Works in Source or Object form.
|
|
69
|
+
|
|
70
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
71
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
72
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
73
|
+
(except as stated in this section) patent license to make, have made,
|
|
74
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
75
|
+
where such license applies only to those patent contributions
|
|
76
|
+
Licensable by such Contributor that are necessarily infringed by their
|
|
77
|
+
Contribution(s) alone or by the combination of their Contribution(s)
|
|
78
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
79
|
+
institute patent litigation against any entity (including a cross-claim
|
|
80
|
+
or counterclaim in a lawsuit) alleging that the Work or any
|
|
81
|
+
Contribution embodied within the Work constitutes direct or contributory
|
|
82
|
+
patent infringement, then any patent licenses granted to You under this
|
|
83
|
+
License for that Work shall terminate as of the date such litigation is
|
|
84
|
+
filed.
|
|
85
|
+
|
|
86
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
87
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
88
|
+
modifications, and in Source or Object form, provided that You
|
|
89
|
+
meet the following conditions:
|
|
90
|
+
|
|
91
|
+
(a) You must give any other recipients of the Work or Derivative
|
|
92
|
+
Works a copy of this License; and
|
|
93
|
+
|
|
94
|
+
(b) You must cause any modified files to carry prominent notices
|
|
95
|
+
stating that You changed the files; and
|
|
96
|
+
|
|
97
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
98
|
+
that You distribute, all copyright, patent, trademark, and
|
|
99
|
+
attribution notices from the Source form of the Work,
|
|
100
|
+
excluding those notices that do not pertain to any part of
|
|
101
|
+
the Derivative Works; and
|
|
102
|
+
|
|
103
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
104
|
+
distribution, You must include a readable copy of the
|
|
105
|
+
attribution notices contained within such NOTICE file, in
|
|
106
|
+
at least one of the following places: within a NOTICE text
|
|
107
|
+
file distributed as part of the Derivative Works; within
|
|
108
|
+
the Source form or documentation, if provided along with the
|
|
109
|
+
Derivative Works; or, within a display generated by the
|
|
110
|
+
Derivative Works, if and wherever such third-party notices
|
|
111
|
+
normally appear. The contents of the NOTICE file are for
|
|
112
|
+
informational purposes only and do not modify the License.
|
|
113
|
+
You may add Your own attribution notices within Derivative
|
|
114
|
+
Works that You distribute, alongside or in addition to the
|
|
115
|
+
NOTICE text from the Work, provided that such additional
|
|
116
|
+
attribution notices cannot be construed as modifying the
|
|
117
|
+
License.
|
|
118
|
+
|
|
119
|
+
You may add Your own license statement for Your modifications and
|
|
120
|
+
may provide additional grant of rights to use, copy, modify, merge,
|
|
121
|
+
publish, distribute, sublicense, and/or sell copies of the
|
|
122
|
+
Derivative Works, as opposed to the original Work.
|
|
123
|
+
|
|
124
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
125
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
126
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
127
|
+
this License, without any additional terms or conditions.
|
|
128
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
129
|
+
the terms of any separate license agreement you may have executed
|
|
130
|
+
with Licensor regarding such Contributions.
|
|
131
|
+
|
|
132
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
133
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
134
|
+
except as required for reasonable and customary use in describing the
|
|
135
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
136
|
+
|
|
137
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
138
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
139
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
140
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
141
|
+
implied, including, without limitation, any conditions of TITLE,
|
|
142
|
+
MERCHANTIBILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely
|
|
143
|
+
responsible for determining the appropriateness of using or
|
|
144
|
+
redistributing the Work and assume any risks associated with Your
|
|
145
|
+
exercise of permissions under this License.
|
|
146
|
+
|
|
147
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
148
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
149
|
+
unless required by applicable law (such as deliberate and grossly
|
|
150
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
151
|
+
liable to You for damages, including any direct, indirect, special,
|
|
152
|
+
incidental, or exemplary damages of any character arising as a
|
|
153
|
+
result of this License or out of the use or inability to use the
|
|
154
|
+
Work (even if such Contributor has been advised of the possibility
|
|
155
|
+
of such damages).
|
|
156
|
+
|
|
157
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
158
|
+
the Work or Derivative Works thereof, You may choose to offer, and
|
|
159
|
+
charge a fee for, acceptance of support, warranty, indemnity,
|
|
160
|
+
or other liability obligations and/or rights consistent with this
|
|
161
|
+
License. However, in accepting such obligations, You may offer only
|
|
162
|
+
conditions consistent with this License and charge a reasonable fee.
|
|
163
|
+
|
|
164
|
+
END OF TERMS AND CONDITIONS
|
|
165
|
+
|
|
166
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
167
|
+
|
|
168
|
+
To apply the Apache License to your work, attach the following
|
|
169
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
170
|
+
replaced with your own identifying information. (Don't include
|
|
171
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
172
|
+
comment syntax for the file format in question.
|
|
173
|
+
|
|
174
|
+
Copyright 2026 Sthitaprajna Sahoo
|
|
175
|
+
|
|
176
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
177
|
+
you may not use this file except in compliance with the License.
|
|
178
|
+
You may obtain a copy of the License at
|
|
179
|
+
|
|
180
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
181
|
+
|
|
182
|
+
Unless required by applicable law or agreed to in writing, software
|
|
183
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
184
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
185
|
+
See the License for the specific language governing permissions and
|
|
186
|
+
limitations under the License.
|
pytypeform-0.2.1/NOTICE
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pytypeform
|
|
3
|
+
Version: 0.2.1
|
|
4
|
+
Summary: A Type-Safe UI/CLI Generator powered by Pydantic.
|
|
5
|
+
Project-URL: Homepage, https://github.com/sthitaprajnas/pytypeform
|
|
6
|
+
Project-URL: Repository, https://github.com/sthitaprajnas/pytypeform
|
|
7
|
+
Project-URL: Documentation, https://github.com/sthitaprajnas/pytypeform#readme
|
|
8
|
+
Project-URL: Issues, https://github.com/sthitaprajnas/pytypeform/issues
|
|
9
|
+
Author-email: Sthitaprajna Sahoo <papu.sahoo@gmail.com>
|
|
10
|
+
Maintainer-email: Sthitaprajna Sahoo <papu.sahoo@gmail.com>
|
|
11
|
+
License: Apache-2.0
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
License-File: NOTICE
|
|
14
|
+
Keywords: cli,form,prompt,pydantic,rich,type-safe,wizard
|
|
15
|
+
Classifier: Development Status :: 4 - Beta
|
|
16
|
+
Classifier: Intended Audience :: Developers
|
|
17
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
18
|
+
Classifier: Operating System :: OS Independent
|
|
19
|
+
Classifier: Programming Language :: Python :: 3
|
|
20
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
25
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
26
|
+
Classifier: Topic :: Software Development :: User Interfaces
|
|
27
|
+
Classifier: Typing :: Typed
|
|
28
|
+
Requires-Python: <3.14,>=3.10
|
|
29
|
+
Requires-Dist: prompt-toolkit>=3.0.0
|
|
30
|
+
Requires-Dist: pydantic>=2.0.0
|
|
31
|
+
Requires-Dist: rich>=13.0.0
|
|
32
|
+
Provides-Extra: dev
|
|
33
|
+
Requires-Dist: build>=1.0; extra == 'dev'
|
|
34
|
+
Requires-Dist: mypy>=1.10; extra == 'dev'
|
|
35
|
+
Requires-Dist: pytest-cov>=5.0; extra == 'dev'
|
|
36
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
37
|
+
Requires-Dist: ruff>=0.4; extra == 'dev'
|
|
38
|
+
Requires-Dist: twine>=5.0; extra == 'dev'
|
|
39
|
+
Description-Content-Type: text/markdown
|
|
40
|
+
|
|
41
|
+
# Typerform
|
|
42
|
+
|
|
43
|
+
A Type-Safe UI/CLI Generator powered by Pydantic and Prompt-Toolkit.
|
|
44
|
+
|
|
45
|
+
[](https://pypi.org/project/typeform/)
|
|
46
|
+
[](https://pypi.org/project/typeform/)
|
|
47
|
+
[](https://github.com/sthitaprajnas/typeform/actions/workflows/ci.yml)
|
|
48
|
+
[](LICENSE)
|
|
49
|
+
[](src/typeform/py.typed)
|
|
50
|
+
|
|
51
|
+
Typerform transforms your Pydantic models into professional, interactive CLI wizards. Stop writing boilerplate input loops and manual validation—let your schemas drive the user experience.
|
|
52
|
+
|
|
53
|
+
## Features
|
|
54
|
+
|
|
55
|
+
| Feature | Description |
|
|
56
|
+
|---------|-------------|
|
|
57
|
+
| **Zero Boilerplate** | Just one line of code to generate an entire multi-step wizard. |
|
|
58
|
+
| **Type-Safe** | Inherits all constraints (min_length, ge, EmailStr) from Pydantic. |
|
|
59
|
+
| **Backtracking** | Full backtracking support—type :b or :back to edit previous fields. |
|
|
60
|
+
| **Conditional Logic** | Dynamically skip fields based on previous answers using 'when' metadata. |
|
|
61
|
+
| **Secure by Default** | Automatic masking for SecretStr fields (API keys, passwords). |
|
|
62
|
+
| **Enterprise Ready** | Pluggable prompt engines for 100% automated testing in CI/CD. |
|
|
63
|
+
| **Smart Autocomplete**| Fuzzy search and real-time suggestions for Enums and Literals. |
|
|
64
|
+
| **Hydration** | Pre-fill forms from Environment variables or configuration files. |
|
|
65
|
+
|
|
66
|
+
## Installation
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
pip install typeform
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Quick Start
|
|
73
|
+
|
|
74
|
+
```python
|
|
75
|
+
from typing import Literal
|
|
76
|
+
from pydantic import BaseModel, Field
|
|
77
|
+
from typeform import form
|
|
78
|
+
|
|
79
|
+
class SetupConfig(BaseModel):
|
|
80
|
+
project_name: str = Field(description="Project Name", min_length=3)
|
|
81
|
+
environment: Literal["dev", "staging", "prod"] = Field(default="dev")
|
|
82
|
+
enable_telemetry: bool = Field(default=True, description="Enable Telemetry")
|
|
83
|
+
|
|
84
|
+
# Generate the wizard!
|
|
85
|
+
config = form(SetupConfig, title="Project Setup")
|
|
86
|
+
|
|
87
|
+
print(config.model_dump())
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Advanced Usage
|
|
91
|
+
|
|
92
|
+
### Backtracking and Navigation
|
|
93
|
+
Typerform maintains a navigation stack. At any prompt, you can use special commands:
|
|
94
|
+
* `:back` or `:b` - Move to the previous field.
|
|
95
|
+
* `:?` - Show extended help text (if provided in `json_schema_extra`).
|
|
96
|
+
|
|
97
|
+
### Conditional Logic
|
|
98
|
+
Hide or show fields dynamically based on the current state of the form:
|
|
99
|
+
|
|
100
|
+
```python
|
|
101
|
+
class CloudConfig(BaseModel):
|
|
102
|
+
provider: Literal["aws", "gcp"]
|
|
103
|
+
# Only asked if provider is 'aws'
|
|
104
|
+
aws_region: str = Field(
|
|
105
|
+
"us-east-1",
|
|
106
|
+
json_schema_extra={"when": "provider == 'aws'"}
|
|
107
|
+
)
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Collection Wizard (Lists)
|
|
111
|
+
Typerform handles `List[T]` by entering a collection loop:
|
|
112
|
+
|
|
113
|
+
```python
|
|
114
|
+
class Team(BaseModel):
|
|
115
|
+
members: list[str] = Field(description="Team Members")
|
|
116
|
+
|
|
117
|
+
# User will be prompted to add multiple items sequentially.
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Hydration (Auto-filling)
|
|
121
|
+
Speed up workflows by pre-filling fields from the environment:
|
|
122
|
+
|
|
123
|
+
```python
|
|
124
|
+
import os
|
|
125
|
+
config = form(MyModel, hydrate_from=[os.environ])
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Contributing
|
|
129
|
+
|
|
130
|
+
Contributions are welcome! Whether it's bug reports, feature requests, or new prompt engines.
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
git clone https://github.com/sthitaprajnas/typeform.git
|
|
134
|
+
cd typeform
|
|
135
|
+
pip install -e ".[dev]"
|
|
136
|
+
pytest # run test suite
|
|
137
|
+
ruff check src/typeform # lint
|
|
138
|
+
mypy src/typeform # type-check
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## License
|
|
142
|
+
|
|
143
|
+
This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.
|
|
144
|
+
|
|
145
|
+
Copyright (c) 2026 Sthitaprajna Sahoo and contributors.
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# Typerform
|
|
2
|
+
|
|
3
|
+
A Type-Safe UI/CLI Generator powered by Pydantic and Prompt-Toolkit.
|
|
4
|
+
|
|
5
|
+
[](https://pypi.org/project/typeform/)
|
|
6
|
+
[](https://pypi.org/project/typeform/)
|
|
7
|
+
[](https://github.com/sthitaprajnas/typeform/actions/workflows/ci.yml)
|
|
8
|
+
[](LICENSE)
|
|
9
|
+
[](src/typeform/py.typed)
|
|
10
|
+
|
|
11
|
+
Typerform transforms your Pydantic models into professional, interactive CLI wizards. Stop writing boilerplate input loops and manual validation—let your schemas drive the user experience.
|
|
12
|
+
|
|
13
|
+
## Features
|
|
14
|
+
|
|
15
|
+
| Feature | Description |
|
|
16
|
+
|---------|-------------|
|
|
17
|
+
| **Zero Boilerplate** | Just one line of code to generate an entire multi-step wizard. |
|
|
18
|
+
| **Type-Safe** | Inherits all constraints (min_length, ge, EmailStr) from Pydantic. |
|
|
19
|
+
| **Backtracking** | Full backtracking support—type :b or :back to edit previous fields. |
|
|
20
|
+
| **Conditional Logic** | Dynamically skip fields based on previous answers using 'when' metadata. |
|
|
21
|
+
| **Secure by Default** | Automatic masking for SecretStr fields (API keys, passwords). |
|
|
22
|
+
| **Enterprise Ready** | Pluggable prompt engines for 100% automated testing in CI/CD. |
|
|
23
|
+
| **Smart Autocomplete**| Fuzzy search and real-time suggestions for Enums and Literals. |
|
|
24
|
+
| **Hydration** | Pre-fill forms from Environment variables or configuration files. |
|
|
25
|
+
|
|
26
|
+
## Installation
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
pip install typeform
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Quick Start
|
|
33
|
+
|
|
34
|
+
```python
|
|
35
|
+
from typing import Literal
|
|
36
|
+
from pydantic import BaseModel, Field
|
|
37
|
+
from typeform import form
|
|
38
|
+
|
|
39
|
+
class SetupConfig(BaseModel):
|
|
40
|
+
project_name: str = Field(description="Project Name", min_length=3)
|
|
41
|
+
environment: Literal["dev", "staging", "prod"] = Field(default="dev")
|
|
42
|
+
enable_telemetry: bool = Field(default=True, description="Enable Telemetry")
|
|
43
|
+
|
|
44
|
+
# Generate the wizard!
|
|
45
|
+
config = form(SetupConfig, title="Project Setup")
|
|
46
|
+
|
|
47
|
+
print(config.model_dump())
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Advanced Usage
|
|
51
|
+
|
|
52
|
+
### Backtracking and Navigation
|
|
53
|
+
Typerform maintains a navigation stack. At any prompt, you can use special commands:
|
|
54
|
+
* `:back` or `:b` - Move to the previous field.
|
|
55
|
+
* `:?` - Show extended help text (if provided in `json_schema_extra`).
|
|
56
|
+
|
|
57
|
+
### Conditional Logic
|
|
58
|
+
Hide or show fields dynamically based on the current state of the form:
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
class CloudConfig(BaseModel):
|
|
62
|
+
provider: Literal["aws", "gcp"]
|
|
63
|
+
# Only asked if provider is 'aws'
|
|
64
|
+
aws_region: str = Field(
|
|
65
|
+
"us-east-1",
|
|
66
|
+
json_schema_extra={"when": "provider == 'aws'"}
|
|
67
|
+
)
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Collection Wizard (Lists)
|
|
71
|
+
Typerform handles `List[T]` by entering a collection loop:
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
class Team(BaseModel):
|
|
75
|
+
members: list[str] = Field(description="Team Members")
|
|
76
|
+
|
|
77
|
+
# User will be prompted to add multiple items sequentially.
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Hydration (Auto-filling)
|
|
81
|
+
Speed up workflows by pre-filling fields from the environment:
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
import os
|
|
85
|
+
config = form(MyModel, hydrate_from=[os.environ])
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Contributing
|
|
89
|
+
|
|
90
|
+
Contributions are welcome! Whether it's bug reports, feature requests, or new prompt engines.
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
git clone https://github.com/sthitaprajnas/typeform.git
|
|
94
|
+
cd typeform
|
|
95
|
+
pip install -e ".[dev]"
|
|
96
|
+
pytest # run test suite
|
|
97
|
+
ruff check src/typeform # lint
|
|
98
|
+
mypy src/typeform # type-check
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## License
|
|
102
|
+
|
|
103
|
+
This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.
|
|
104
|
+
|
|
105
|
+
Copyright (c) 2026 Sthitaprajna Sahoo and contributors.
|