pydantic-fixturegen 1.0.0__py3-none-any.whl → 1.1.0__py3-none-any.whl

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 pydantic-fixturegen might be problematic. Click here for more details.

Files changed (39) hide show
  1. pydantic_fixturegen/api/__init__.py +137 -0
  2. pydantic_fixturegen/api/_runtime.py +726 -0
  3. pydantic_fixturegen/api/models.py +73 -0
  4. pydantic_fixturegen/cli/__init__.py +32 -1
  5. pydantic_fixturegen/cli/check.py +230 -0
  6. pydantic_fixturegen/cli/diff.py +992 -0
  7. pydantic_fixturegen/cli/doctor.py +188 -35
  8. pydantic_fixturegen/cli/gen/_common.py +134 -7
  9. pydantic_fixturegen/cli/gen/explain.py +597 -40
  10. pydantic_fixturegen/cli/gen/fixtures.py +244 -112
  11. pydantic_fixturegen/cli/gen/json.py +229 -138
  12. pydantic_fixturegen/cli/gen/schema.py +170 -85
  13. pydantic_fixturegen/cli/init.py +333 -0
  14. pydantic_fixturegen/cli/schema.py +45 -0
  15. pydantic_fixturegen/cli/watch.py +126 -0
  16. pydantic_fixturegen/core/config.py +137 -3
  17. pydantic_fixturegen/core/config_schema.py +178 -0
  18. pydantic_fixturegen/core/constraint_report.py +305 -0
  19. pydantic_fixturegen/core/errors.py +42 -0
  20. pydantic_fixturegen/core/field_policies.py +100 -0
  21. pydantic_fixturegen/core/generate.py +241 -37
  22. pydantic_fixturegen/core/io_utils.py +10 -2
  23. pydantic_fixturegen/core/path_template.py +197 -0
  24. pydantic_fixturegen/core/presets.py +73 -0
  25. pydantic_fixturegen/core/providers/temporal.py +10 -0
  26. pydantic_fixturegen/core/safe_import.py +146 -12
  27. pydantic_fixturegen/core/seed_freeze.py +176 -0
  28. pydantic_fixturegen/emitters/json_out.py +65 -16
  29. pydantic_fixturegen/emitters/pytest_codegen.py +68 -13
  30. pydantic_fixturegen/emitters/schema_out.py +27 -3
  31. pydantic_fixturegen/logging.py +114 -0
  32. pydantic_fixturegen/schemas/config.schema.json +244 -0
  33. pydantic_fixturegen-1.1.0.dist-info/METADATA +173 -0
  34. pydantic_fixturegen-1.1.0.dist-info/RECORD +57 -0
  35. pydantic_fixturegen-1.0.0.dist-info/METADATA +0 -280
  36. pydantic_fixturegen-1.0.0.dist-info/RECORD +0 -41
  37. {pydantic_fixturegen-1.0.0.dist-info → pydantic_fixturegen-1.1.0.dist-info}/WHEEL +0 -0
  38. {pydantic_fixturegen-1.0.0.dist-info → pydantic_fixturegen-1.1.0.dist-info}/entry_points.txt +0 -0
  39. {pydantic_fixturegen-1.0.0.dist-info → pydantic_fixturegen-1.1.0.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,173 @@
1
+ Metadata-Version: 2.4
2
+ Name: pydantic-fixturegen
3
+ Version: 1.1.0
4
+ Summary: Deterministic fixture generator for Pydantic models.
5
+ Project-URL: Homepage, https://github.com/casper-kristiansson/pydantic-fixturegen
6
+ Project-URL: Documentation, https://github.com/casper-kristiansson/pydantic-fixturegen
7
+ Project-URL: Repository, https://github.com/casper-kristiansson/pydantic-fixturegen
8
+ Author: Fixturegen Developers
9
+ License: MIT
10
+ License-File: LICENSE
11
+ Classifier: Development Status :: 5 - Production/Stable
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3 :: Only
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Requires-Python: <3.14,>=3.10
20
+ Requires-Dist: faker>=24.0.0
21
+ Requires-Dist: pluggy>=1.5.0
22
+ Requires-Dist: pydantic>=2.8.0
23
+ Requires-Dist: tomli>=2.0.1; python_version < '3.11'
24
+ Requires-Dist: typer>=0.12.3
25
+ Provides-Extra: all
26
+ Requires-Dist: hypothesis>=6.100.0; extra == 'all'
27
+ Requires-Dist: orjson>=3.10.0; extra == 'all'
28
+ Requires-Dist: rstr>=3.2.0; extra == 'all'
29
+ Requires-Dist: watchfiles>=0.22.0; extra == 'all'
30
+ Provides-Extra: all-dev
31
+ Requires-Dist: hypothesis>=6.100.0; extra == 'all-dev'
32
+ Requires-Dist: mypy>=1.11; extra == 'all-dev'
33
+ Requires-Dist: orjson>=3.10.0; extra == 'all-dev'
34
+ Requires-Dist: pytest-cov>=5.0; extra == 'all-dev'
35
+ Requires-Dist: pytest>=8.3; extra == 'all-dev'
36
+ Requires-Dist: rstr>=3.2.0; extra == 'all-dev'
37
+ Requires-Dist: ruff>=0.6.5; extra == 'all-dev'
38
+ Requires-Dist: watchfiles>=0.22.0; extra == 'all-dev'
39
+ Provides-Extra: dev
40
+ Requires-Dist: mypy>=1.11; extra == 'dev'
41
+ Provides-Extra: docs
42
+ Provides-Extra: hypothesis
43
+ Requires-Dist: hypothesis>=6.100.0; extra == 'hypothesis'
44
+ Provides-Extra: lint
45
+ Requires-Dist: ruff>=0.6.5; extra == 'lint'
46
+ Provides-Extra: orjson
47
+ Requires-Dist: orjson>=3.10.0; extra == 'orjson'
48
+ Provides-Extra: regex
49
+ Requires-Dist: rstr>=3.2.0; extra == 'regex'
50
+ Provides-Extra: test
51
+ Requires-Dist: pytest-cov>=5.0; extra == 'test'
52
+ Requires-Dist: pytest>=8.3; extra == 'test'
53
+ Provides-Extra: watch
54
+ Requires-Dist: watchfiles>=0.22.0; extra == 'watch'
55
+ Description-Content-Type: text/markdown
56
+
57
+ # pydantic-fixturegen: deterministic Pydantic fixtures, JSON generator, secure sandbox
58
+
59
+ > Pydantic v2 deterministic fixtures, pytest fixtures, JSON generator, secure sandboxed CLI with Pluggy providers.
60
+
61
+ [![PyPI version](https://img.shields.io/pypi/v/pydantic-fixturegen.svg "PyPI")](https://pypi.org/project/pydantic-fixturegen/)
62
+ ![Python versions](https://img.shields.io/pypi/pyversions/pydantic-fixturegen.svg "Python 3.10–3.13")
63
+ ![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg "MIT License")
64
+
65
+ Generate deterministic Pydantic v2 data, pytest fixtures, and JSON quickly with a safe, task-focused CLI built for modern testing workflows.
66
+
67
+ ## Why
68
+
69
+ <a id="why"></a>
70
+ <a id="features"></a>
71
+
72
+ - You keep tests reproducible with cascaded seeds across `random`, Faker, and optional NumPy.
73
+ - You run untrusted models inside a safe-import sandbox with network, filesystem, and memory guards.
74
+ - You drive JSON, pytest fixtures, schemas, and explanations from the CLI or Python helpers.
75
+ - You extend generation with Pluggy providers and preset bundles without forking core code.
76
+
77
+ You also stay observant while you work: every command can emit structured logs, diff artifacts against disk, and surface sandbox warnings so you catch regressions before they land.
78
+
79
+ ## Install
80
+
81
+ ```bash
82
+ pip install pydantic-fixturegen
83
+ # Extras: orjson, regex, hypothesis, watch
84
+ pip install 'pydantic-fixturegen[all]'
85
+ ```
86
+
87
+ Other flows → [docs/install.md](./docs/install.md)
88
+
89
+ ## Quick start
90
+
91
+ <a id="quickstart"></a>
92
+
93
+ 1. Create a small Pydantic v2 model file.
94
+ 2. List models: `pfg list ./models.py`
95
+ 3. Generate JSON: `pfg gen json ./models.py --include models.User --n 2 --indent 2 --out ./out/User`
96
+ 4. Generate fixtures: `pfg gen fixtures ./models.py --out tests/fixtures/test_user.py --cases 3`
97
+ Full steps → [docs/quickstart.md](./docs/quickstart.md)
98
+
99
+ JSON, fixtures, and schema commands all share flags like `--include`, `--exclude`, `--seed`, `--preset`, and `--watch`, so once you learn one flow you can handle the rest without re-reading the help pages.
100
+
101
+ ## Basics
102
+
103
+ ### Core usage (top 5)
104
+
105
+ <a id="cli"></a>
106
+
107
+ ```bash
108
+ pfg list <path>
109
+ pfg gen json <target> [--n --jsonl --indent --out]
110
+ pfg gen fixtures <target> [--style --scope --cases --out]
111
+ pfg gen schema <target> --out <file>
112
+ pfg doctor <target>
113
+ ```
114
+
115
+ - `pfg list` discovers models with AST or safe-import; add `--ast` when you must avoid imports.
116
+ - `pfg gen json` emits JSON or JSONL; scale with `--n`, `--jsonl`, `--shard-size`, and `--freeze-seeds`.
117
+ - `pfg gen fixtures` writes pytest modules; tune `--style`, `--scope`, `--cases`, and `--return-type`.
118
+ - `pfg gen schema` dumps JSON Schema atomically; point `--out` at a file or directory template.
119
+ - `pfg doctor` audits coverage and sandbox warnings; fail builds with `--fail-on-gaps`.
120
+
121
+ All commands → [docs/cli.md](./docs/cli.md)
122
+
123
+ ### Basic configuration
124
+
125
+ <a id="configuration-precedence"></a>
126
+
127
+ | key | type | default | purpose |
128
+ | --------------------- | ------------------ | ------- | ------------- |
129
+ | seed | int \| str \| null | null | Global seed |
130
+ | locale | str | en_US | Faker locale |
131
+ | union_policy | enum | first | Union branch |
132
+ | enum_policy | enum | first | Enum choice |
133
+ | json.indent | int | 2 | Pretty JSON |
134
+ | json.orjson | bool | false | Fast JSON |
135
+ | emitters.pytest.style | enum | functions | Fixture style |
136
+ | emitters.pytest.scope | enum | function | Fixture scope |
137
+
138
+ ```toml
139
+ [tool.pydantic_fixturegen]
140
+ seed = 42
141
+ [tool.pydantic_fixturegen.json]
142
+ indent = 2
143
+ ```
144
+
145
+ Full matrix and precedence → [docs/configuration.md](./docs/configuration.md)
146
+
147
+ ### Common tasks
148
+
149
+ - Freeze seeds for CI determinism → [docs/seeds.md](./docs/seeds.md)
150
+ - Use watch mode → [docs/quickstart.md#watch-mode](./docs/quickstart.md#watch-mode)
151
+ - Templated output paths → [docs/output-paths.md](./docs/output-paths.md)
152
+ - Provider customization → [docs/providers.md](./docs/providers.md)
153
+ - Capture explain trees or JSON diagnostics for review → [docs/explain.md](./docs/explain.md)
154
+
155
+ ## Documentation
156
+
157
+ <a id="next-steps"></a>
158
+ <a id="architecture"></a>
159
+ <a id="comparison"></a>
160
+
161
+ [Index](./docs/index.md) · [Quickstart](./docs/quickstart.md) · [Cookbook](./docs/cookbook.md) · [Configuration](./docs/configuration.md) · [CLI](./docs/cli.md) · [Concepts](./docs/concepts.md) · [Features](./docs/features.md) · [Security](./docs/security.md) · [Architecture](./docs/architecture.md) · [Troubleshooting](./docs/troubleshooting.md) · [Alternatives](./docs/alternatives.md)
162
+
163
+ ## Community
164
+
165
+ <a id="community"></a>
166
+
167
+ Open issues for bugs or ideas, start Discussions for design questions, and follow the security policy when you disclose sandbox bypasses.
168
+
169
+ ## License
170
+
171
+ <a id="license"></a>
172
+
173
+ MIT. See `LICENSE`.
@@ -0,0 +1,57 @@
1
+ pydantic_fixturegen/__init__.py,sha256=RBdIGSjuX3ZY94EuMR2OFxSXGDAofEU-OFnfacOSZoY,174
2
+ pydantic_fixturegen/logging.py,sha256=hwjFachrgTvQo4hkMceypCRs9U4AXW020G9_PfHGThE,3277
3
+ pydantic_fixturegen/api/__init__.py,sha256=OoaFvzxoabObwT1KG9TmJIefZxudMQmrntVoNoK_Vuw,3702
4
+ pydantic_fixturegen/api/_runtime.py,sha256=HbmBgX6Eh3bt9b6OxAhBfN_juSH1yHIou3Wbit3LJpA,24103
5
+ pydantic_fixturegen/api/models.py,sha256=OvBRV8MmpOt12qCm4w5UdJaJKsr88huly2yp-iY5waw,1685
6
+ pydantic_fixturegen/cli/__init__.py,sha256=t-bNBG4f2oBDgHdMRVkFzvoG8FgIDU02zHqeRi-0C4M,3316
7
+ pydantic_fixturegen/cli/check.py,sha256=1mSwUIVx3VrywhBxyQCWj8MZkASp1k-Feizwx5oICpI,6452
8
+ pydantic_fixturegen/cli/diff.py,sha256=3erh6F5WxTShRYHystJmzqgiDcq3U2i1Gf2M1URG1Bo,31077
9
+ pydantic_fixturegen/cli/doctor.py,sha256=RQ5f57GoWWeUcLFI4QGMH54qmgB27QunxcTPbnvCkdg,11522
10
+ pydantic_fixturegen/cli/init.py,sha256=v0wZvP7IIe18fmQB-bFq9CWnAIfyUkmB5nyoaLWLS3I,11111
11
+ pydantic_fixturegen/cli/list.py,sha256=zwjI6U5YpAZqxRnI5ZjS8gOLIjmFx2PhFFdpyHz67ZA,4267
12
+ pydantic_fixturegen/cli/schema.py,sha256=lTzapqp2QHGLuMzA7PINRP2V9hgk-p4VbgQCPrzUiBs,1107
13
+ pydantic_fixturegen/cli/watch.py,sha256=ZqlsMbRhl1HZEJHzMlwkkePKm-OHio-PGwbgiktsBeQ,3661
14
+ pydantic_fixturegen/cli/gen/__init__.py,sha256=iiBXZtBsMiEE4yiNRhZ23AXEWAGg6IGxdCeoNjiBcd4,554
15
+ pydantic_fixturegen/cli/gen/_common.py,sha256=mnpPXpnsN3y2zzxCKeT-NyZVjmyoj34kYNu4BzY7VQ0,7716
16
+ pydantic_fixturegen/cli/gen/explain.py,sha256=j4NRkENsiPJOMLTdUoZjE33wzI9RdSWGMlpCvjmwQUk,22750
17
+ pydantic_fixturegen/cli/gen/fixtures.py,sha256=s10eE7n5-ea2537-riOwO3KRwr1FP3PSCWfy1yTJ0ZE,12077
18
+ pydantic_fixturegen/cli/gen/json.py,sha256=DgSX5ynvayP7xUqCyJvK3uCe1rZo49i1VBP_hS-O4L0,10259
19
+ pydantic_fixturegen/cli/gen/schema.py,sha256=pkawyNBERe5-DeZwhVah5w2bUkfRWxh5KiXpVNZS-PQ,7343
20
+ pydantic_fixturegen/core/__init__.py,sha256=Ak5JH-aPopNnWGWGsoIwszs6Qx2gLS5bxPbCB9tjK6A,2749
21
+ pydantic_fixturegen/core/ast_discover.py,sha256=2D3GD6pol6Irrt1tnQnIQ5vna1u4Ak73hIcbqEnvMxs,5475
22
+ pydantic_fixturegen/core/config.py,sha256=RmtldQ6s-N1kLelJIcIarefTuNBR1KYX4vCkKkwt7vM,19428
23
+ pydantic_fixturegen/core/config_schema.py,sha256=-HA9txcFUxy-Na3jMBuC47ClRGu67yNdqvWzcTXZN8c,5837
24
+ pydantic_fixturegen/core/constraint_report.py,sha256=6clUOjrTw_w1T1v4dQGOK9NkPx9BsntYZvIltVSyB-g,10514
25
+ pydantic_fixturegen/core/errors.py,sha256=NvVsq5SGGvsJMzK-3ymPnjuRCczYxW_ZLv4KhGetUBE,3985
26
+ pydantic_fixturegen/core/field_policies.py,sha256=OIZpiccQu8mB4rCDJSk5wSfezu-y4yNoBy3bsEPE6hc,3439
27
+ pydantic_fixturegen/core/generate.py,sha256=OzlPuiPL7PoqDcTcS8C1rLJ-ukccLTOWwabezYvd8Oo,18055
28
+ pydantic_fixturegen/core/introspect.py,sha256=yqmuo5FyXCJuLxIifmN8m7WOjffbbt36g7cEv5lktl0,4267
29
+ pydantic_fixturegen/core/io_utils.py,sha256=l5OLIrE7_iuuSOpkQUKR2GstTGymETLWoQXNGG4bhcY,2164
30
+ pydantic_fixturegen/core/path_template.py,sha256=7F57ZSQUROAuicYSQg_QAwcpEaWD9G2hCS5HQ8pap30,6225
31
+ pydantic_fixturegen/core/presets.py,sha256=CmjgTMxwh1zCOLQOQJRwuQOIHIhthx2hHkEf63Mey6o,1932
32
+ pydantic_fixturegen/core/safe_import.py,sha256=1w6_gNKwCKM_gWFsRDA9o6-HgvXW0_eJXRTzHHmpH6E,17480
33
+ pydantic_fixturegen/core/schema.py,sha256=53JZLDLg5Az4NOL4maydMspO6W0nEDIrFnaHaKTcP78,11834
34
+ pydantic_fixturegen/core/seed.py,sha256=KyYsotIc8YOwD81pAym8bTRBDSNW1Jas2SnqKs6q5xE,5167
35
+ pydantic_fixturegen/core/seed_freeze.py,sha256=J6U_ZpcNlujAHcazOMvbIcddVK_sn1LuigeDzAEEJyM,5232
36
+ pydantic_fixturegen/core/strategies.py,sha256=mOJY4IF7W9ufw1cZbtP9vMeICtbCdlhzSJwuJdzCBLM,6635
37
+ pydantic_fixturegen/core/version.py,sha256=WhbxwTDgLR4t3ge8M2W32tvQQJDg5gySYWWaSrwbpkw,1563
38
+ pydantic_fixturegen/core/providers/__init__.py,sha256=n5QHG09ISzJ0olTnbZMS_vBWBQWVghhtGR9KlTM6NxE,1029
39
+ pydantic_fixturegen/core/providers/collections.py,sha256=P6hJKYcwT4q-olGiM4TR0-eOF8mdufJjkqo7W0rXfVk,2370
40
+ pydantic_fixturegen/core/providers/identifiers.py,sha256=WUEVgXevMs6c_IAqVv5vSgmfbIWWQlNNGiukoVd6zKc,1915
41
+ pydantic_fixturegen/core/providers/numbers.py,sha256=bJDT6qJlBXzpiHHIpAi2tmtmW2i3kmLTFyrTdz1Ktqk,3861
42
+ pydantic_fixturegen/core/providers/registry.py,sha256=-MOh22IimiBx99tqxRxuHJKA_F2bV3ZOEk4r9UU_K00,3091
43
+ pydantic_fixturegen/core/providers/strings.py,sha256=JOYGnpfn_UyIErQJ2KwCtT-_58pQSKAfVl4Sy5veRHc,3572
44
+ pydantic_fixturegen/core/providers/temporal.py,sha256=0JOcW-XeHUN0Vnhr-AbdSZUaNFW1-pAmA5rzjWse9xo,1457
45
+ pydantic_fixturegen/emitters/__init__.py,sha256=RhttiS4btcXFLYA8MDcTFI1gMj8wx8kUQtENZgUPn-k,458
46
+ pydantic_fixturegen/emitters/json_out.py,sha256=R3mQolmSLAI6mip5UA7WiVACxsY_FzFvax7TVlctqHE,12754
47
+ pydantic_fixturegen/emitters/pytest_codegen.py,sha256=tKOQ9EebuF6h1ETpuzmHLgqgU4mMTcXRAeF8FYg6Ylk,14700
48
+ pydantic_fixturegen/emitters/schema_out.py,sha256=FeDjIS8xVgwuYIiKQ4sjf7HhmE7R3h1A3zeefA4G4gE,3154
49
+ pydantic_fixturegen/plugins/builtin.py,sha256=AFX62HJyX_x-WKNSgsH1nR3xRl8KY7trAB8Vk4eKZd8,1500
50
+ pydantic_fixturegen/plugins/hookspecs.py,sha256=SrVIA-ZVY50retrLcSvC_psSdew63p4QtNkTGuv5vdk,1528
51
+ pydantic_fixturegen/plugins/loader.py,sha256=buhRN3m0oHlP9kJae_Qm6dZ1MmsCBGpOnrhr4o0M7f4,2016
52
+ pydantic_fixturegen/schemas/config.schema.json,sha256=dl-4HNlULvDPQ-0cLsrnheDO2C0RUJi5GXBRfFIUYEQ,6533
53
+ pydantic_fixturegen-1.1.0.dist-info/METADATA,sha256=SzpQ687vDopXWKDEp6ElDU9Ks7e3rIqP-Ox9Zbesb1U,7240
54
+ pydantic_fixturegen-1.1.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
55
+ pydantic_fixturegen-1.1.0.dist-info/entry_points.txt,sha256=DJnzWHrqxajizJMESs50F3giJe6g7AE5uYFu5H5maXY,121
56
+ pydantic_fixturegen-1.1.0.dist-info/licenses/LICENSE,sha256=mPdJP5TSS7c6-5BB9kkinAX2dmW_kbb6xLniY_VfbpQ,1089
57
+ pydantic_fixturegen-1.1.0.dist-info/RECORD,,
@@ -1,280 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: pydantic-fixturegen
3
- Version: 1.0.0
4
- Summary: Deterministic fixture generator for Pydantic models.
5
- Project-URL: Homepage, https://github.com/casper-kristiansson/pydantic-fixturegen
6
- Project-URL: Documentation, https://github.com/casper-kristiansson/pydantic-fixturegen
7
- Project-URL: Repository, https://github.com/casper-kristiansson/pydantic-fixturegen
8
- Author: Fixturegen Developers
9
- License: MIT
10
- License-File: LICENSE
11
- Classifier: Development Status :: 5 - Production/Stable
12
- Classifier: License :: OSI Approved :: MIT License
13
- Classifier: Programming Language :: Python :: 3
14
- Classifier: Programming Language :: Python :: 3 :: Only
15
- Classifier: Programming Language :: Python :: 3.10
16
- Classifier: Programming Language :: Python :: 3.11
17
- Classifier: Programming Language :: Python :: 3.12
18
- Classifier: Programming Language :: Python :: 3.13
19
- Requires-Python: <3.14,>=3.10
20
- Requires-Dist: faker>=24.0.0
21
- Requires-Dist: pluggy>=1.5.0
22
- Requires-Dist: pydantic>=2.8.0
23
- Requires-Dist: tomli>=2.0.1; python_version < '3.11'
24
- Requires-Dist: typer>=0.12.3
25
- Provides-Extra: all
26
- Requires-Dist: hypothesis>=6.100.0; extra == 'all'
27
- Requires-Dist: orjson>=3.10.0; extra == 'all'
28
- Requires-Dist: rstr>=3.2.0; extra == 'all'
29
- Provides-Extra: all-dev
30
- Requires-Dist: hypothesis>=6.100.0; extra == 'all-dev'
31
- Requires-Dist: mypy>=1.11; extra == 'all-dev'
32
- Requires-Dist: orjson>=3.10.0; extra == 'all-dev'
33
- Requires-Dist: pytest-cov>=5.0; extra == 'all-dev'
34
- Requires-Dist: pytest>=8.3; extra == 'all-dev'
35
- Requires-Dist: rstr>=3.2.0; extra == 'all-dev'
36
- Requires-Dist: ruff>=0.6.5; extra == 'all-dev'
37
- Provides-Extra: dev
38
- Requires-Dist: mypy>=1.11; extra == 'dev'
39
- Provides-Extra: docs
40
- Provides-Extra: hypothesis
41
- Requires-Dist: hypothesis>=6.100.0; extra == 'hypothesis'
42
- Provides-Extra: lint
43
- Requires-Dist: ruff>=0.6.5; extra == 'lint'
44
- Provides-Extra: orjson
45
- Requires-Dist: orjson>=3.10.0; extra == 'orjson'
46
- Provides-Extra: regex
47
- Requires-Dist: rstr>=3.2.0; extra == 'regex'
48
- Provides-Extra: test
49
- Requires-Dist: pytest-cov>=5.0; extra == 'test'
50
- Requires-Dist: pytest>=8.3; extra == 'test'
51
- Description-Content-Type: text/markdown
52
-
53
- # pydantic-fixturegen: Deterministic Pydantic fixtures for fast, safe tests (pydantic-fixturegen)
54
-
55
- > Deterministic Pydantic fixtures and JSON generation via a secure sandboxed CLI and Pluggy plugins.
56
-
57
- [![PyPI version](https://img.shields.io/pypi/v/pydantic-fixturegen.svg "PyPI")](https://pypi.org/project/pydantic-fixturegen/)
58
- ![Python versions](https://img.shields.io/pypi/pyversions/pydantic-fixturegen.svg "Python 3.10–3.13")
59
- ![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg "MIT License")
60
-
61
- `pydantic-fixturegen` is a **deterministic data generation toolkit for Pydantic v2 models**. It discovers models, builds generation strategies, creates instances, and **emits artifacts**—JSON, **pytest fixtures**, and JSON Schema—through a composable CLI and a **Pluggy** plugin layer.
62
-
63
- - **Deterministic seeds** cascade per model/field across Python `random`, **Faker**, and optional **NumPy** RNGs.
64
- - **Safe-import sandbox** executes untrusted model modules with **network lockdown**, **filesystem jail**, and **resource caps**.
65
- - **Emitters** write JSON/JSONL, pytest fixture modules, and schema files with **atomic writes** and reproducibility metadata.
66
- - **Config precedence**: **CLI args** → **`PFG_*` env vars** → **`[tool.pydantic_fixturegen]`** in `pyproject.toml` or YAML → defaults.
67
-
68
- ---
69
-
70
- ## Why pydantic-fixturegen (why)
71
-
72
- - **Deterministic test data** for reproducible CI.
73
- - **Secure safe-import sandbox** for third-party models.
74
- - **Pluggy-powered data providers** for extension without forks.
75
- - **CLI first**: `pfg list | gen json | gen fixtures | gen schema | gen explain | doctor`.
76
-
77
- ---
78
-
79
- ## Features at a glance (features)
80
-
81
- | Area | Highlights |
82
- | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
83
- | **Discovery** | `pfg list` via AST or sandboxed import; include/exclude patterns; public-only; machine-readable errors (`--json-errors`, code `20`). |
84
- | **Generation** | Depth-first builder with recursion/instance budgets; per-field policies (enums/unions/`p_none`). |
85
- | **Emitters** | JSON/JSONL with optional **orjson**, sharding, metadata header when indenting; pytest fixtures with banner (seed/version/digest) and Ruff/Black formatting; JSON Schema via `model_json_schema()` with **atomic writes**. |
86
- | **Providers** | Built-in numbers, strings (regex via optional `rstr`), collections, temporal, identifiers. Extensible via `pfg_register_providers`. |
87
- | **Strategies** | `core/strategies.py` merges schema, policies, and plugin adjustments (`pfg_modify_strategy`). |
88
- | **Security** | Sandbox blocks sockets, scrubs env (`NO_PROXY=*`, proxies cleared, `PYTHONSAFEPATH=1`), redirects HOME/tmp, jails filesystem writes, caps memory (`RLIMIT_AS`, `RLIMIT_DATA`), **timeout exit code 40**. |
89
- | **Config** | CLI > `PFG_*` env > `pyproject`/YAML > defaults. String booleans accepted (`true/false/1/0`). |
90
- | **Quality** | Mypy + Ruff; pytest across Linux/macOS/Windows, Python **3.10–3.13**; coverage ≥ **90%**. |
91
- | **Release** | Hatch builds; GitHub Actions matrices; PyPI **Trusted Publishing** with signing + attestations. |
92
-
93
- ---
94
-
95
- ## Install
96
-
97
- ### pip
98
-
99
- ```bash
100
- pip install pydantic-fixturegen
101
- # Extras
102
- pip install 'pydantic-fixturegen[orjson]'
103
- pip install 'pydantic-fixturegen[regex]'
104
- pip install 'pydantic-fixturegen[hypothesis]'
105
- pip install 'pydantic-fixturegen[all]' # runtime extras bundle
106
- pip install 'pydantic-fixturegen[all-dev]' # dev tools + runtime extras
107
- ```
108
-
109
- ### Poetry
110
-
111
- ```bash
112
- poetry add pydantic-fixturegen
113
- poetry run pfg --help
114
- ```
115
-
116
- ### Hatch
117
-
118
- ```toml
119
- # pyproject.toml
120
- [project]
121
- dependencies = ["pydantic-fixturegen"]
122
- ```
123
-
124
- ```bash
125
- hatch run pfg --help
126
- ```
127
-
128
- ---
129
-
130
- ## 60-second quickstart (quickstart)
131
-
132
- **1) Define models**
133
-
134
- ```python
135
- # models.py
136
- from pydantic import BaseModel
137
-
138
- class Address(BaseModel):
139
- street: str
140
-
141
- class User(BaseModel):
142
- id: int
143
- name: str
144
- nickname: str | None = None
145
- address: Address
146
- ```
147
-
148
- **2) Discover models**
149
-
150
- ```bash
151
- pfg list ./models.py
152
- # outputs:
153
- # models.User
154
- # models.Address
155
- ```
156
-
157
- **3) Generate JSON samples**
158
-
159
- ```bash
160
- pfg gen json ./models.py --include models.User --n 2 --indent 2 --out ./out/User
161
- # writes out/User.json with a metadata header comment when indenting
162
-
163
- > **Note:** When a module declares more than one model, `--include` narrows generation to the desired `module.Model`.
164
- ```
165
-
166
- Example file (excerpt):
167
-
168
- ```json
169
- /* seed=42 version=1.0.0 digest=<sha256> */
170
- [
171
- {
172
- "id": 1,
173
- "name": "Alice",
174
- "nickname": null,
175
- "address": { "street": "42 Main St" }
176
- },
177
- {
178
- "id": 2,
179
- "name": "Bob",
180
- "nickname": "b",
181
- "address": { "street": "1 Side Rd" }
182
- }
183
- ]
184
- ```
185
-
186
- **4) Generate pytest fixtures**
187
-
188
- ```bash
189
- pfg gen fixtures ./models.py \
190
- --out tests/fixtures/test_user_fixtures.py \
191
- --style functions --scope module --cases 3 --return-type model
192
- # produces a module with a banner and deduped imports, formatted by Ruff/Black
193
- ```
194
-
195
- Fixture excerpt:
196
-
197
- ```python
198
- # pydantic-fixturegen v1.0.0 seed=42 digest=<sha256>
199
- import pytest
200
- from models import User, Address
201
-
202
- @pytest.fixture(scope="module", params=[0,1,2], ids=lambda i: f"user_case_{i}")
203
- def user(request) -> User:
204
- # deterministic across runs/machines
205
- ...
206
- ```
207
-
208
- ---
209
-
210
- ## Configuration precedence (configuration-precedence)
211
-
212
- ```toml
213
- # pyproject.toml
214
- [tool.pydantic_fixturegen]
215
- seed = 42
216
- locale = "en_US"
217
- union_policy = "weighted"
218
- enum_policy = "random"
219
- emitters.json.indent = 2
220
- emitters.json.orjson = false
221
- fixtures.style = "functions"
222
- fixtures.scope = "module"
223
- ```
224
-
225
- Environment variables mirror keys using `PFG_` (e.g., `PFG_SEED=99`). **CLI flags override everything**.
226
-
227
- ---
228
-
229
- ## CLI overview (cli)
230
-
231
- - `pfg list <module_or_path>` — enumerate models (AST and/or sandboxed import).
232
- - `pfg gen json <target>` — deterministic JSON/JSONL (`--n`, `--jsonl`, `--indent`, `--orjson/--no-orjson`, `--shard-size`, `--out`, `--seed`).
233
- - `pfg gen schema <target>` — emit JSON Schema (`--out` required; atomic writes; `--json-errors`).
234
- - `pfg gen fixtures <target>` — emit pytest fixtures (`--style {functions,factory,class}`, `--scope {function,module,session}`, `--p-none`, `--cases`, `--return-type {model,dict}`).
235
- - `pfg gen explain <target>` — print provider/strategy tree per field; optional `--json` if exposed.
236
- - `pfg doctor <target>` — audit coverage, constraints, risky imports (`--fail-on-warn`, `--json-errors`).
237
-
238
- ---
239
-
240
- ## Architecture in one diagram (architecture)
241
-
242
- ```
243
- Models → Discovery (AST ⟷ Safe-Import Sandbox) → Strategies (policies + hooks)
244
- → ProviderRegistry (built-ins + plugins) → Instance Builder
245
- → Emitters (JSON | Fixtures | Schema, atomic IO, worker pools)
246
- → Artifacts on disk (with seed/version/digest metadata)
247
- ```
248
-
249
- **Sandbox guards**: sockets blocked; env scrubbed (`NO_PROXY=*`, proxies cleared, `PYTHONSAFEPATH=1`); HOME/tmp redirected; writes outside workdir denied; memory caps (`RLIMIT_AS`, `RLIMIT_DATA`); **timeout exit code 40**.
250
-
251
- ---
252
-
253
- ## Comparison: pydantic-fixturegen vs alternatives (comparison)
254
-
255
- | Use Case | Learning Curve | Determinism | Security Controls | Best Fit |
256
- | ------------------------------------- | -------------- | -------------------------------------------------- | --------------------------------------- | -------------------------------------------------------------------- |
257
- | **pydantic-fixturegen** | Low | Strong, cascaded seeds across `random`/Faker/NumPy | Sandbox, atomic IO, JSON error taxonomy | Teams needing **deterministic Pydantic fixtures** and CLI automation |
258
- | Hand-written fixtures | Medium–High | Depends on reviewer discipline | None by default | Small codebases with few models |
259
- | Factory libraries (e.g., factory_boy) | Medium | Often stochastic unless manually seeded | Varies, not sandboxed | App-level object factories where ORM integration is key |
260
- | `hypothesis.extra.pydantic` | Medium–High | Property-based, not fixed by default | Not sandboxed | Generative testing exploring model spaces |
261
-
262
- ---
263
-
264
- ## Community & support (community)
265
-
266
- - Issues and contributions are welcome. Open an issue for bugs or feature discussions, and submit PRs with tests and docs.
267
- - Security posture includes a sandbox and atomic writes; please report any bypass findings responsibly.
268
-
269
- ---
270
-
271
- ## License (license)
272
-
273
- MIT. See `LICENSE`.
274
-
275
- ---
276
-
277
- ## Next steps (next-steps)
278
-
279
- - Start with the **[Quickstart](./docs/quickstart.md)**.
280
- - Dive deeper with the **[Cookbook](./docs/cookbook.md)**.
@@ -1,41 +0,0 @@
1
- pydantic_fixturegen/__init__.py,sha256=RBdIGSjuX3ZY94EuMR2OFxSXGDAofEU-OFnfacOSZoY,174
2
- pydantic_fixturegen/cli/__init__.py,sha256=KLI5pIb7LdDWWETXVc8HzlFtSTak1yeXX8baIplth3w,2143
3
- pydantic_fixturegen/cli/doctor.py,sha256=uRbYR31MXi3BfVKXvWtLFv7zYEYpAiJds335e9rOgiI,6924
4
- pydantic_fixturegen/cli/list.py,sha256=zwjI6U5YpAZqxRnI5ZjS8gOLIjmFx2PhFFdpyHz67ZA,4267
5
- pydantic_fixturegen/cli/gen/__init__.py,sha256=iiBXZtBsMiEE4yiNRhZ23AXEWAGg6IGxdCeoNjiBcd4,554
6
- pydantic_fixturegen/cli/gen/_common.py,sha256=wpyZTSYn4ElqKWytvhdkQeEQR0SeHSVDQVdXabFep2o,3945
7
- pydantic_fixturegen/cli/gen/explain.py,sha256=3qzFHX0RlOPsDGBBzJv_cVou6SjqGD9LVarZiNUYk8I,4560
8
- pydantic_fixturegen/cli/gen/fixtures.py,sha256=-oh3iTRQt7T4R4O0Q82TwlufzzyO3nTYDl78awVSnNU,7938
9
- pydantic_fixturegen/cli/gen/json.py,sha256=IeVLZxATTh9n85rEPsZ81puNxRYXtDbroUb_QI2fYIw,7530
10
- pydantic_fixturegen/cli/gen/schema.py,sha256=6RCpFlA68YWAnDTV3HcVBgCVihc7DodhYCCXnDI9sFc,4631
11
- pydantic_fixturegen/core/__init__.py,sha256=Ak5JH-aPopNnWGWGsoIwszs6Qx2gLS5bxPbCB9tjK6A,2749
12
- pydantic_fixturegen/core/ast_discover.py,sha256=2D3GD6pol6Irrt1tnQnIQ5vna1u4Ak73hIcbqEnvMxs,5475
13
- pydantic_fixturegen/core/config.py,sha256=lzO4oYsndUen7rg01V0Owu-lOUE0s48qk17ptc3_d_8,14131
14
- pydantic_fixturegen/core/errors.py,sha256=yAMApYp2rjWIoRfVroubJON0PKMp7GK4Ny1f_qeOFn8,3065
15
- pydantic_fixturegen/core/generate.py,sha256=yr9mbEj1ylCAfHg0oXiuSqpgydw12UDxOeMw9WWXe4Y,10885
16
- pydantic_fixturegen/core/introspect.py,sha256=yqmuo5FyXCJuLxIifmN8m7WOjffbbt36g7cEv5lktl0,4267
17
- pydantic_fixturegen/core/io_utils.py,sha256=uFWJ5EAlPkm80bIMZplEKhFA696ShU8hyuRYiVYs4vU,1973
18
- pydantic_fixturegen/core/safe_import.py,sha256=pTK5GtmNMhr9ZcVyVNrS7Mx05r1HcBMuYi5jZdel58o,12910
19
- pydantic_fixturegen/core/schema.py,sha256=53JZLDLg5Az4NOL4maydMspO6W0nEDIrFnaHaKTcP78,11834
20
- pydantic_fixturegen/core/seed.py,sha256=KyYsotIc8YOwD81pAym8bTRBDSNW1Jas2SnqKs6q5xE,5167
21
- pydantic_fixturegen/core/strategies.py,sha256=mOJY4IF7W9ufw1cZbtP9vMeICtbCdlhzSJwuJdzCBLM,6635
22
- pydantic_fixturegen/core/version.py,sha256=WhbxwTDgLR4t3ge8M2W32tvQQJDg5gySYWWaSrwbpkw,1563
23
- pydantic_fixturegen/core/providers/__init__.py,sha256=n5QHG09ISzJ0olTnbZMS_vBWBQWVghhtGR9KlTM6NxE,1029
24
- pydantic_fixturegen/core/providers/collections.py,sha256=P6hJKYcwT4q-olGiM4TR0-eOF8mdufJjkqo7W0rXfVk,2370
25
- pydantic_fixturegen/core/providers/identifiers.py,sha256=WUEVgXevMs6c_IAqVv5vSgmfbIWWQlNNGiukoVd6zKc,1915
26
- pydantic_fixturegen/core/providers/numbers.py,sha256=bJDT6qJlBXzpiHHIpAi2tmtmW2i3kmLTFyrTdz1Ktqk,3861
27
- pydantic_fixturegen/core/providers/registry.py,sha256=-MOh22IimiBx99tqxRxuHJKA_F2bV3ZOEk4r9UU_K00,3091
28
- pydantic_fixturegen/core/providers/strings.py,sha256=JOYGnpfn_UyIErQJ2KwCtT-_58pQSKAfVl4Sy5veRHc,3572
29
- pydantic_fixturegen/core/providers/temporal.py,sha256=q1Cxb0K2ux-AMbSSAekrDE_npu4LxptXELqM3MzS_hs,1115
30
- pydantic_fixturegen/emitters/__init__.py,sha256=RhttiS4btcXFLYA8MDcTFI1gMj8wx8kUQtENZgUPn-k,458
31
- pydantic_fixturegen/emitters/json_out.py,sha256=ftX5I0wsz-upOHynz-sdYLOkFX76yrQQTbyfibDXzVI,10977
32
- pydantic_fixturegen/emitters/pytest_codegen.py,sha256=rmlQ-s5qXOperVBe8AAnr2Ea-R2IYojCpW5-PS8fjrU,12392
33
- pydantic_fixturegen/emitters/schema_out.py,sha256=UaB_Qp_l_vFGWc9IvAY6ffvznEHmfMnpWJU7hz23tQ8,2178
34
- pydantic_fixturegen/plugins/builtin.py,sha256=AFX62HJyX_x-WKNSgsH1nR3xRl8KY7trAB8Vk4eKZd8,1500
35
- pydantic_fixturegen/plugins/hookspecs.py,sha256=SrVIA-ZVY50retrLcSvC_psSdew63p4QtNkTGuv5vdk,1528
36
- pydantic_fixturegen/plugins/loader.py,sha256=buhRN3m0oHlP9kJae_Qm6dZ1MmsCBGpOnrhr4o0M7f4,2016
37
- pydantic_fixturegen-1.0.0.dist-info/METADATA,sha256=Edq9UWsoMGHMGAhV2DV1cHAOn_QynBvWqDqev46Koxs,12130
38
- pydantic_fixturegen-1.0.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
39
- pydantic_fixturegen-1.0.0.dist-info/entry_points.txt,sha256=DJnzWHrqxajizJMESs50F3giJe6g7AE5uYFu5H5maXY,121
40
- pydantic_fixturegen-1.0.0.dist-info/licenses/LICENSE,sha256=mPdJP5TSS7c6-5BB9kkinAX2dmW_kbb6xLniY_VfbpQ,1089
41
- pydantic_fixturegen-1.0.0.dist-info/RECORD,,