pydantic-fixturegen 1.0.0__tar.gz → 1.1.0__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 pydantic-fixturegen might be problematic. Click here for more details.

Files changed (148) hide show
  1. pydantic_fixturegen-1.1.0/PKG-INFO +173 -0
  2. pydantic_fixturegen-1.1.0/README.md +117 -0
  3. pydantic_fixturegen-1.1.0/docs/alternatives.md +13 -0
  4. pydantic_fixturegen-1.1.0/docs/api.md +96 -0
  5. pydantic_fixturegen-1.1.0/docs/architecture.md +42 -0
  6. pydantic_fixturegen-1.1.0/docs/cli.md +160 -0
  7. pydantic_fixturegen-1.1.0/docs/concepts.md +36 -0
  8. pydantic_fixturegen-1.1.0/docs/configuration.md +129 -0
  9. pydantic_fixturegen-1.1.0/docs/cookbook.md +137 -0
  10. pydantic_fixturegen-1.1.0/docs/discovery.md +43 -0
  11. pydantic_fixturegen-1.1.0/docs/doctor.md +51 -0
  12. pydantic_fixturegen-1.1.0/docs/emitters.md +61 -0
  13. pydantic_fixturegen-1.1.0/docs/explain.md +60 -0
  14. pydantic_fixturegen-1.1.0/docs/features.md +44 -0
  15. pydantic_fixturegen-1.1.0/docs/index.md +26 -0
  16. pydantic_fixturegen-1.1.0/docs/install.md +80 -0
  17. pydantic_fixturegen-1.1.0/docs/logging.md +49 -0
  18. pydantic_fixturegen-1.1.0/docs/output-paths.md +37 -0
  19. pydantic_fixturegen-1.1.0/docs/presets.md +32 -0
  20. pydantic_fixturegen-1.1.0/docs/providers.md +59 -0
  21. pydantic_fixturegen-1.1.0/docs/quickstart.md +177 -0
  22. pydantic_fixturegen-1.1.0/docs/security.md +33 -0
  23. pydantic_fixturegen-1.1.0/docs/seeds.md +43 -0
  24. pydantic_fixturegen-1.1.0/docs/strategies.md +48 -0
  25. pydantic_fixturegen-1.1.0/docs/troubleshooting.md +33 -0
  26. pydantic_fixturegen-1.1.0/pydantic_fixturegen/api/__init__.py +137 -0
  27. pydantic_fixturegen-1.1.0/pydantic_fixturegen/api/_runtime.py +726 -0
  28. pydantic_fixturegen-1.1.0/pydantic_fixturegen/api/models.py +73 -0
  29. {pydantic_fixturegen-1.0.0 → pydantic_fixturegen-1.1.0}/pydantic_fixturegen/cli/__init__.py +32 -1
  30. pydantic_fixturegen-1.1.0/pydantic_fixturegen/cli/check.py +230 -0
  31. pydantic_fixturegen-1.1.0/pydantic_fixturegen/cli/diff.py +992 -0
  32. pydantic_fixturegen-1.1.0/pydantic_fixturegen/cli/doctor.py +388 -0
  33. pydantic_fixturegen-1.1.0/pydantic_fixturegen/cli/gen/_common.py +266 -0
  34. pydantic_fixturegen-1.1.0/pydantic_fixturegen/cli/gen/explain.py +702 -0
  35. pydantic_fixturegen-1.1.0/pydantic_fixturegen/cli/gen/fixtures.py +415 -0
  36. pydantic_fixturegen-1.1.0/pydantic_fixturegen/cli/gen/json.py +353 -0
  37. pydantic_fixturegen-1.1.0/pydantic_fixturegen/cli/gen/schema.py +249 -0
  38. pydantic_fixturegen-1.1.0/pydantic_fixturegen/cli/init.py +333 -0
  39. pydantic_fixturegen-1.1.0/pydantic_fixturegen/cli/schema.py +45 -0
  40. pydantic_fixturegen-1.1.0/pydantic_fixturegen/cli/watch.py +126 -0
  41. {pydantic_fixturegen-1.0.0 → pydantic_fixturegen-1.1.0}/pydantic_fixturegen/core/config.py +137 -3
  42. pydantic_fixturegen-1.1.0/pydantic_fixturegen/core/config_schema.py +178 -0
  43. pydantic_fixturegen-1.1.0/pydantic_fixturegen/core/constraint_report.py +305 -0
  44. {pydantic_fixturegen-1.0.0 → pydantic_fixturegen-1.1.0}/pydantic_fixturegen/core/errors.py +42 -0
  45. pydantic_fixturegen-1.1.0/pydantic_fixturegen/core/field_policies.py +100 -0
  46. {pydantic_fixturegen-1.0.0 → pydantic_fixturegen-1.1.0}/pydantic_fixturegen/core/generate.py +241 -37
  47. {pydantic_fixturegen-1.0.0 → pydantic_fixturegen-1.1.0}/pydantic_fixturegen/core/io_utils.py +10 -2
  48. pydantic_fixturegen-1.1.0/pydantic_fixturegen/core/path_template.py +197 -0
  49. pydantic_fixturegen-1.1.0/pydantic_fixturegen/core/presets.py +73 -0
  50. {pydantic_fixturegen-1.0.0 → pydantic_fixturegen-1.1.0}/pydantic_fixturegen/core/providers/temporal.py +10 -0
  51. {pydantic_fixturegen-1.0.0 → pydantic_fixturegen-1.1.0}/pydantic_fixturegen/core/safe_import.py +146 -12
  52. pydantic_fixturegen-1.1.0/pydantic_fixturegen/core/seed_freeze.py +176 -0
  53. {pydantic_fixturegen-1.0.0 → pydantic_fixturegen-1.1.0}/pydantic_fixturegen/emitters/json_out.py +65 -16
  54. {pydantic_fixturegen-1.0.0 → pydantic_fixturegen-1.1.0}/pydantic_fixturegen/emitters/pytest_codegen.py +68 -13
  55. {pydantic_fixturegen-1.0.0 → pydantic_fixturegen-1.1.0}/pydantic_fixturegen/emitters/schema_out.py +27 -3
  56. pydantic_fixturegen-1.1.0/pydantic_fixturegen/logging.py +114 -0
  57. pydantic_fixturegen-1.1.0/pydantic_fixturegen/schemas/config.schema.json +244 -0
  58. {pydantic_fixturegen-1.0.0 → pydantic_fixturegen-1.1.0}/pyproject.toml +6 -1
  59. pydantic_fixturegen-1.1.0/tests/api/test_api_generate.py +251 -0
  60. pydantic_fixturegen-1.1.0/tests/cli/test_check.py +317 -0
  61. pydantic_fixturegen-1.1.0/tests/cli/test_diff.py +262 -0
  62. pydantic_fixturegen-1.1.0/tests/cli/test_diff_branches.py +610 -0
  63. pydantic_fixturegen-1.1.0/tests/cli/test_doctor.py +480 -0
  64. pydantic_fixturegen-1.1.0/tests/cli/test_explain.py +794 -0
  65. pydantic_fixturegen-1.1.0/tests/cli/test_gen_fixtures.py +590 -0
  66. pydantic_fixturegen-1.1.0/tests/cli/test_gen_json.py +700 -0
  67. pydantic_fixturegen-1.1.0/tests/cli/test_gen_schema.py +417 -0
  68. pydantic_fixturegen-1.1.0/tests/cli/test_init.py +262 -0
  69. {pydantic_fixturegen-1.0.0 → pydantic_fixturegen-1.1.0}/tests/cli/test_list.py +80 -0
  70. pydantic_fixturegen-1.1.0/tests/cli/test_logging.py +114 -0
  71. pydantic_fixturegen-1.1.0/tests/cli/test_schema_config.py +27 -0
  72. pydantic_fixturegen-1.1.0/tests/cli/test_seed_freeze_cli.py +176 -0
  73. pydantic_fixturegen-1.1.0/tests/cli/test_watch_mode.py +221 -0
  74. {pydantic_fixturegen-1.0.0 → pydantic_fixturegen-1.1.0}/tests/core/test_config.py +77 -0
  75. pydantic_fixturegen-1.1.0/tests/core/test_config_schema.py +26 -0
  76. pydantic_fixturegen-1.1.0/tests/core/test_constraint_reporter.py +271 -0
  77. pydantic_fixturegen-1.1.0/tests/core/test_field_policies.py +34 -0
  78. pydantic_fixturegen-1.1.0/tests/core/test_generate.py +252 -0
  79. pydantic_fixturegen-1.1.0/tests/core/test_path_template.py +58 -0
  80. {pydantic_fixturegen-1.0.0 → pydantic_fixturegen-1.1.0}/tests/core/test_providers.py +34 -0
  81. pydantic_fixturegen-1.1.0/tests/core/test_safe_import.py +153 -0
  82. pydantic_fixturegen-1.1.0/tests/core/test_seed_freeze.py +51 -0
  83. {pydantic_fixturegen-1.0.0 → pydantic_fixturegen-1.1.0}/tests/emitters/test_json_out.py +27 -0
  84. {pydantic_fixturegen-1.0.0 → pydantic_fixturegen-1.1.0}/tests/emitters/test_json_out_additional.py +23 -0
  85. {pydantic_fixturegen-1.0.0 → pydantic_fixturegen-1.1.0}/tests/emitters/test_pytest_codegen.py +36 -0
  86. pydantic_fixturegen-1.1.0/tests/emitters/test_schema_out.py +94 -0
  87. pydantic_fixturegen-1.0.0/PKG-INFO +0 -280
  88. pydantic_fixturegen-1.0.0/README.md +0 -228
  89. pydantic_fixturegen-1.0.0/docs/cookbook.md +0 -302
  90. pydantic_fixturegen-1.0.0/docs/quickstart.md +0 -240
  91. pydantic_fixturegen-1.0.0/pydantic_fixturegen/cli/doctor.py +0 -235
  92. pydantic_fixturegen-1.0.0/pydantic_fixturegen/cli/gen/_common.py +0 -139
  93. pydantic_fixturegen-1.0.0/pydantic_fixturegen/cli/gen/explain.py +0 -145
  94. pydantic_fixturegen-1.0.0/pydantic_fixturegen/cli/gen/fixtures.py +0 -283
  95. pydantic_fixturegen-1.0.0/pydantic_fixturegen/cli/gen/json.py +0 -262
  96. pydantic_fixturegen-1.0.0/pydantic_fixturegen/cli/gen/schema.py +0 -164
  97. pydantic_fixturegen-1.0.0/tests/cli/test_doctor.py +0 -222
  98. pydantic_fixturegen-1.0.0/tests/cli/test_explain.py +0 -160
  99. pydantic_fixturegen-1.0.0/tests/cli/test_gen_fixtures.py +0 -391
  100. pydantic_fixturegen-1.0.0/tests/cli/test_gen_json.py +0 -433
  101. pydantic_fixturegen-1.0.0/tests/cli/test_gen_schema.py +0 -314
  102. pydantic_fixturegen-1.0.0/tests/core/test_generate.py +0 -100
  103. pydantic_fixturegen-1.0.0/tests/core/test_safe_import.py +0 -74
  104. pydantic_fixturegen-1.0.0/tests/emitters/test_schema_out.py +0 -48
  105. {pydantic_fixturegen-1.0.0 → pydantic_fixturegen-1.1.0}/.gitignore +0 -0
  106. {pydantic_fixturegen-1.0.0 → pydantic_fixturegen-1.1.0}/LICENSE +0 -0
  107. {pydantic_fixturegen-1.0.0 → pydantic_fixturegen-1.1.0}/pydantic_fixturegen/__init__.py +0 -0
  108. {pydantic_fixturegen-1.0.0 → pydantic_fixturegen-1.1.0}/pydantic_fixturegen/cli/gen/__init__.py +0 -0
  109. {pydantic_fixturegen-1.0.0 → pydantic_fixturegen-1.1.0}/pydantic_fixturegen/cli/list.py +0 -0
  110. {pydantic_fixturegen-1.0.0 → pydantic_fixturegen-1.1.0}/pydantic_fixturegen/core/__init__.py +0 -0
  111. {pydantic_fixturegen-1.0.0 → pydantic_fixturegen-1.1.0}/pydantic_fixturegen/core/ast_discover.py +0 -0
  112. {pydantic_fixturegen-1.0.0 → pydantic_fixturegen-1.1.0}/pydantic_fixturegen/core/introspect.py +0 -0
  113. {pydantic_fixturegen-1.0.0 → pydantic_fixturegen-1.1.0}/pydantic_fixturegen/core/providers/__init__.py +0 -0
  114. {pydantic_fixturegen-1.0.0 → pydantic_fixturegen-1.1.0}/pydantic_fixturegen/core/providers/collections.py +0 -0
  115. {pydantic_fixturegen-1.0.0 → pydantic_fixturegen-1.1.0}/pydantic_fixturegen/core/providers/identifiers.py +0 -0
  116. {pydantic_fixturegen-1.0.0 → pydantic_fixturegen-1.1.0}/pydantic_fixturegen/core/providers/numbers.py +0 -0
  117. {pydantic_fixturegen-1.0.0 → pydantic_fixturegen-1.1.0}/pydantic_fixturegen/core/providers/registry.py +0 -0
  118. {pydantic_fixturegen-1.0.0 → pydantic_fixturegen-1.1.0}/pydantic_fixturegen/core/providers/strings.py +0 -0
  119. {pydantic_fixturegen-1.0.0 → pydantic_fixturegen-1.1.0}/pydantic_fixturegen/core/schema.py +0 -0
  120. {pydantic_fixturegen-1.0.0 → pydantic_fixturegen-1.1.0}/pydantic_fixturegen/core/seed.py +0 -0
  121. {pydantic_fixturegen-1.0.0 → pydantic_fixturegen-1.1.0}/pydantic_fixturegen/core/strategies.py +0 -0
  122. {pydantic_fixturegen-1.0.0 → pydantic_fixturegen-1.1.0}/pydantic_fixturegen/core/version.py +0 -0
  123. {pydantic_fixturegen-1.0.0 → pydantic_fixturegen-1.1.0}/pydantic_fixturegen/emitters/__init__.py +0 -0
  124. {pydantic_fixturegen-1.0.0 → pydantic_fixturegen-1.1.0}/pydantic_fixturegen/plugins/builtin.py +0 -0
  125. {pydantic_fixturegen-1.0.0 → pydantic_fixturegen-1.1.0}/pydantic_fixturegen/plugins/hookspecs.py +0 -0
  126. {pydantic_fixturegen-1.0.0 → pydantic_fixturegen-1.1.0}/pydantic_fixturegen/plugins/loader.py +0 -0
  127. {pydantic_fixturegen-1.0.0 → pydantic_fixturegen-1.1.0}/tests/cli/test_cli_entrypoint.py +0 -0
  128. {pydantic_fixturegen-1.0.0 → pydantic_fixturegen-1.1.0}/tests/cli/test_cli_errors.py +0 -0
  129. {pydantic_fixturegen-1.0.0 → pydantic_fixturegen-1.1.0}/tests/cli/test_common_helpers.py +0 -0
  130. {pydantic_fixturegen-1.0.0 → pydantic_fixturegen-1.1.0}/tests/cli/test_config_loader_errors.py +0 -0
  131. {pydantic_fixturegen-1.0.0 → pydantic_fixturegen-1.1.0}/tests/conftest.py +0 -0
  132. {pydantic_fixturegen-1.0.0 → pydantic_fixturegen-1.1.0}/tests/core/test_ast_discover.py +0 -0
  133. {pydantic_fixturegen-1.0.0 → pydantic_fixturegen-1.1.0}/tests/core/test_errors.py +0 -0
  134. {pydantic_fixturegen-1.0.0 → pydantic_fixturegen-1.1.0}/tests/core/test_introspect.py +0 -0
  135. {pydantic_fixturegen-1.0.0 → pydantic_fixturegen-1.1.0}/tests/core/test_io_utils.py +0 -0
  136. {pydantic_fixturegen-1.0.0 → pydantic_fixturegen-1.1.0}/tests/core/test_schema_constraints.py +0 -0
  137. {pydantic_fixturegen-1.0.0 → pydantic_fixturegen-1.1.0}/tests/core/test_seed.py +0 -0
  138. {pydantic_fixturegen-1.0.0 → pydantic_fixturegen-1.1.0}/tests/core/test_strategies.py +0 -0
  139. {pydantic_fixturegen-1.0.0 → pydantic_fixturegen-1.1.0}/tests/core/test_version.py +0 -0
  140. {pydantic_fixturegen-1.0.0 → pydantic_fixturegen-1.1.0}/tests/e2e/test_determinism.py +0 -0
  141. {pydantic_fixturegen-1.0.0 → pydantic_fixturegen-1.1.0}/tests/emitters/test_pytest_codegen_styles.py +0 -0
  142. {pydantic_fixturegen-1.0.0 → pydantic_fixturegen-1.1.0}/tests/perf/test_json_workers.py +0 -0
  143. {pydantic_fixturegen-1.0.0 → pydantic_fixturegen-1.1.0}/tests/plugins/test_hooks.py +0 -0
  144. {pydantic_fixturegen-1.0.0 → pydantic_fixturegen-1.1.0}/tests/providers/test_collections_additional.py +0 -0
  145. {pydantic_fixturegen-1.0.0 → pydantic_fixturegen-1.1.0}/tests/providers/test_numbers_additional.py +0 -0
  146. {pydantic_fixturegen-1.0.0 → pydantic_fixturegen-1.1.0}/tests/providers/test_strings_additional.py +0 -0
  147. {pydantic_fixturegen-1.0.0 → pydantic_fixturegen-1.1.0}/tests/security/test_sandbox.py +0 -0
  148. {pydantic_fixturegen-1.0.0 → pydantic_fixturegen-1.1.0}/tests/test_imports.py +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,117 @@
1
+ # pydantic-fixturegen: deterministic Pydantic fixtures, JSON generator, secure sandbox
2
+
3
+ > Pydantic v2 deterministic fixtures, pytest fixtures, JSON generator, secure sandboxed CLI with Pluggy providers.
4
+
5
+ [![PyPI version](https://img.shields.io/pypi/v/pydantic-fixturegen.svg "PyPI")](https://pypi.org/project/pydantic-fixturegen/)
6
+ ![Python versions](https://img.shields.io/pypi/pyversions/pydantic-fixturegen.svg "Python 3.10–3.13")
7
+ ![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg "MIT License")
8
+
9
+ Generate deterministic Pydantic v2 data, pytest fixtures, and JSON quickly with a safe, task-focused CLI built for modern testing workflows.
10
+
11
+ ## Why
12
+
13
+ <a id="why"></a>
14
+ <a id="features"></a>
15
+
16
+ - You keep tests reproducible with cascaded seeds across `random`, Faker, and optional NumPy.
17
+ - You run untrusted models inside a safe-import sandbox with network, filesystem, and memory guards.
18
+ - You drive JSON, pytest fixtures, schemas, and explanations from the CLI or Python helpers.
19
+ - You extend generation with Pluggy providers and preset bundles without forking core code.
20
+
21
+ 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.
22
+
23
+ ## Install
24
+
25
+ ```bash
26
+ pip install pydantic-fixturegen
27
+ # Extras: orjson, regex, hypothesis, watch
28
+ pip install 'pydantic-fixturegen[all]'
29
+ ```
30
+
31
+ Other flows → [docs/install.md](./docs/install.md)
32
+
33
+ ## Quick start
34
+
35
+ <a id="quickstart"></a>
36
+
37
+ 1. Create a small Pydantic v2 model file.
38
+ 2. List models: `pfg list ./models.py`
39
+ 3. Generate JSON: `pfg gen json ./models.py --include models.User --n 2 --indent 2 --out ./out/User`
40
+ 4. Generate fixtures: `pfg gen fixtures ./models.py --out tests/fixtures/test_user.py --cases 3`
41
+ Full steps → [docs/quickstart.md](./docs/quickstart.md)
42
+
43
+ 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.
44
+
45
+ ## Basics
46
+
47
+ ### Core usage (top 5)
48
+
49
+ <a id="cli"></a>
50
+
51
+ ```bash
52
+ pfg list <path>
53
+ pfg gen json <target> [--n --jsonl --indent --out]
54
+ pfg gen fixtures <target> [--style --scope --cases --out]
55
+ pfg gen schema <target> --out <file>
56
+ pfg doctor <target>
57
+ ```
58
+
59
+ - `pfg list` discovers models with AST or safe-import; add `--ast` when you must avoid imports.
60
+ - `pfg gen json` emits JSON or JSONL; scale with `--n`, `--jsonl`, `--shard-size`, and `--freeze-seeds`.
61
+ - `pfg gen fixtures` writes pytest modules; tune `--style`, `--scope`, `--cases`, and `--return-type`.
62
+ - `pfg gen schema` dumps JSON Schema atomically; point `--out` at a file or directory template.
63
+ - `pfg doctor` audits coverage and sandbox warnings; fail builds with `--fail-on-gaps`.
64
+
65
+ All commands → [docs/cli.md](./docs/cli.md)
66
+
67
+ ### Basic configuration
68
+
69
+ <a id="configuration-precedence"></a>
70
+
71
+ | key | type | default | purpose |
72
+ | --------------------- | ------------------ | ------- | ------------- |
73
+ | seed | int \| str \| null | null | Global seed |
74
+ | locale | str | en_US | Faker locale |
75
+ | union_policy | enum | first | Union branch |
76
+ | enum_policy | enum | first | Enum choice |
77
+ | json.indent | int | 2 | Pretty JSON |
78
+ | json.orjson | bool | false | Fast JSON |
79
+ | emitters.pytest.style | enum | functions | Fixture style |
80
+ | emitters.pytest.scope | enum | function | Fixture scope |
81
+
82
+ ```toml
83
+ [tool.pydantic_fixturegen]
84
+ seed = 42
85
+ [tool.pydantic_fixturegen.json]
86
+ indent = 2
87
+ ```
88
+
89
+ Full matrix and precedence → [docs/configuration.md](./docs/configuration.md)
90
+
91
+ ### Common tasks
92
+
93
+ - Freeze seeds for CI determinism → [docs/seeds.md](./docs/seeds.md)
94
+ - Use watch mode → [docs/quickstart.md#watch-mode](./docs/quickstart.md#watch-mode)
95
+ - Templated output paths → [docs/output-paths.md](./docs/output-paths.md)
96
+ - Provider customization → [docs/providers.md](./docs/providers.md)
97
+ - Capture explain trees or JSON diagnostics for review → [docs/explain.md](./docs/explain.md)
98
+
99
+ ## Documentation
100
+
101
+ <a id="next-steps"></a>
102
+ <a id="architecture"></a>
103
+ <a id="comparison"></a>
104
+
105
+ [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)
106
+
107
+ ## Community
108
+
109
+ <a id="community"></a>
110
+
111
+ Open issues for bugs or ideas, start Discussions for design questions, and follow the security policy when you disclose sandbox bypasses.
112
+
113
+ ## License
114
+
115
+ <a id="license"></a>
116
+
117
+ MIT. See `LICENSE`.
@@ -0,0 +1,13 @@
1
+ # Alternatives: choose the right fixture tool
2
+
3
+ > Compare pydantic-fixturegen with common approaches so you can justify the switch.
4
+
5
+ | Tooling | Determinism | Plugin model | Sandboxing | CLI coverage | Best fit |
6
+ | --------------------------- | -------------------------------------------------- | --------------------------------------- | --------------------- | ------------------------------------- | ------------------------------------------------------- |
7
+ | **pydantic-fixturegen** | Strong: cascaded seeds across `random`/Faker/NumPy | Pluggy hooks (`pfg_register_providers`, `pfg_modify_strategy`, `pfg_emit_artifact`) | Yes (network, FS jail, caps) | Broad (`list`, `gen`, `diff`, `check`, `doctor`, `explain`) | Teams needing deterministic Pydantic fixtures and JSON artifacts |
8
+ | Hand-written fixtures | Manual discipline required | None | None | None | Small codebases with few models |
9
+ | `factory_boy` | Optional seeding | Class-based factories | None | N/A | ORM-backed object factories |
10
+ | `hypothesis.extra.pydantic` | Generative, not fixed by default | Strategy composition | None | N/A | Property-based exploration |
11
+ | Custom scripts | Depends on implementation | Ad hoc | Rare | Rare | One-off data dumps without reusable tooling |
12
+
13
+ When you need deterministic JSON/JSONL, pytest fixtures, and schema artefacts with a secure sandbox, pydantic-fixturegen keeps everything in one CLI. Use other tools when you prioritise interactive data exploration over reproducibility.
@@ -0,0 +1,96 @@
1
+ # Python API: call generators from code
2
+
3
+ > Use the same engine as the CLI while staying inside Python workflows.
4
+
5
+ Import helpers directly:
6
+
7
+ ```python
8
+ from pydantic_fixturegen.api import (
9
+ generate_json,
10
+ generate_fixtures,
11
+ generate_schema,
12
+ JsonGenerationResult,
13
+ FixturesGenerationResult,
14
+ SchemaGenerationResult,
15
+ )
16
+ ```
17
+
18
+ ## `generate_json`
19
+
20
+ ```python
21
+ result: JsonGenerationResult = generate_json(
22
+ "./models.py",
23
+ out="artifacts/{model}/sample-{case_index}.json",
24
+ count=3,
25
+ jsonl=True,
26
+ indent=0,
27
+ use_orjson=True,
28
+ shard_size=1000,
29
+ include=["app.models.User"],
30
+ seed=42,
31
+ preset="boundary",
32
+ freeze_seeds=True,
33
+ freeze_seeds_file=".pfg-seeds.json",
34
+ )
35
+ ```
36
+
37
+ - Parameters mirror `pfg gen json`.
38
+ - `out` accepts the same templated placeholders as the CLI.
39
+ - `freeze_seeds` and `freeze_seeds_file` manage deterministic per-model seeds.
40
+ - The result exposes `paths`, `base_output`, the selected `model`, a `ConfigSnapshot`, and any warnings.
41
+
42
+ ## `generate_fixtures`
43
+
44
+ ```python
45
+ fixtures: FixturesGenerationResult = generate_fixtures(
46
+ "./models.py",
47
+ out="tests/fixtures/{model}_fixtures.py",
48
+ style="factory",
49
+ scope="session",
50
+ cases=5,
51
+ return_type="dict",
52
+ seed=42,
53
+ p_none=0.2,
54
+ include=["app.models.User"],
55
+ preset="boundary-max",
56
+ )
57
+ ```
58
+
59
+ - Mirrors `pfg gen fixtures` options.
60
+ - Returns the path that was written (or `None` when skipped), resolved `style`, `scope`, `return_type`, and `cases`.
61
+ - Inspect `fixtures.metadata` for banner details such as digest and version.
62
+
63
+ ## `generate_schema`
64
+
65
+ ```python
66
+ schema: SchemaGenerationResult = generate_schema(
67
+ "./models.py",
68
+ out="schema/{model}.json",
69
+ indent=2,
70
+ include=["app.models.User", "app.models.Address"],
71
+ )
72
+ ```
73
+
74
+ - Writes JSON Schema files atomically.
75
+ - The result lists discovered `models`, shared config, and warnings.
76
+
77
+ ## Using the results
78
+
79
+ Each result dataclass includes:
80
+
81
+ - `paths` or `path` — filesystem locations written to disk.
82
+ - `base_output` — the original template base path for reference.
83
+ - `config` — `ConfigSnapshot` capturing seed, include/exclude patterns, and time anchor.
84
+ - `warnings` — tuple of warning identifiers surfaced during generation.
85
+ - `constraint_summary` (where applicable) — per-field constraint reports when constraints fail.
86
+ - `delegated` — indicates whether generation was handled by a plugin.
87
+
88
+ Because results are dataclasses, you can serialize them to JSON easily:
89
+
90
+ ```python
91
+ from dataclasses import asdict
92
+
93
+ summary = asdict(fixtures)
94
+ ```
95
+
96
+ Use these helpers inside build steps, pre-commit hooks, or custom orchestration without shelling out to the CLI. Pair them with [logging](./logging.md) if you need structured telemetry from embedded runs.
@@ -0,0 +1,42 @@
1
+ # Architecture: how the pipeline fits together
2
+
3
+ > Understand the stages that turn Pydantic models into deterministic artifacts.
4
+
5
+ ```text
6
+ Models
7
+
8
+ Discovery (AST ⟷ Safe-Import Sandbox)
9
+
10
+ Strategies (policies + presets + plugins)
11
+
12
+ ProviderRegistry (built-ins + pfg_register_providers)
13
+
14
+ Instance Builder (deterministic seeds)
15
+
16
+ Emitters (JSON | Fixtures | Schema, atomic IO)
17
+
18
+ Artifacts with metadata (seed/version/digest)
19
+ ```
20
+
21
+ ## Stage breakdown
22
+
23
+ - **Discovery**: Collects model metadata using AST, sandboxed imports, or hybrid mode. Emits warnings when imports misbehave.
24
+ - **Strategies**: `StrategyBuilder` summarises field constraints, applies presets, and calls plugin hooks to adjust strategy objects.
25
+ - **Provider registry**: Supplies concrete value generators. Plugins can register additional providers or override defaults.
26
+ - **Instance builder**: Cascades deterministic seeds across Faker and optional NumPy, respecting `p_none`, enum, and union policies.
27
+ - **Emitters**: Write JSON/JSONL, pytest fixtures, and schema files atomically, templating output paths as needed.
28
+ - **Metadata**: Banners and logs record seed, generator version, digests, style, scope, and constraint summaries.
29
+
30
+ ## Plugin touchpoints
31
+
32
+ - `pfg_register_providers` — add or replace providers before strategies run.
33
+ - `pfg_modify_strategy` — tweak per-field strategies after defaults are created.
34
+ - `pfg_emit_artifact` — intercept artifact writing; return `True` to skip the built-in emitter.
35
+
36
+ ## Observability
37
+
38
+ - Structured logging (`--log-json`) mirrors each stage with stable event names.
39
+ - `pfg doctor` reports coverage metrics and sandbox issues after discovery and strategy building.
40
+ - Diff/check commands reuse the same pipeline to ensure comparisons match real generation.
41
+
42
+ For extension guidance, continue to [providers](./providers.md), [strategies](./strategies.md), or [emitters](./emitters.md).
@@ -0,0 +1,160 @@
1
+ # CLI: drive generation from commands
2
+
3
+ > Learn every command, flag, and default so you can script generation with confidence.
4
+
5
+ ## Global options
6
+
7
+ ```bash
8
+ pfg --verbose # repeat -v to increase verbosity (info → debug)
9
+ pfg --quiet # repeat -q to reduce output (info → warning → error → silent)
10
+ pfg --log-json # emit structured JSON logs; combine with jq for CI parsing
11
+ ```
12
+
13
+ You can append `-- --help` after any proxy command to view native Typer help because `pfg` forwards arguments to sub-apps.
14
+
15
+ ## `pfg list`
16
+
17
+ ```bash
18
+ pfg list ./models.py --include pkg.User --public-only
19
+ ```
20
+
21
+ - Lists fully-qualified model names discovered via AST and safe-import by default.
22
+ - Use `--ast` to disable imports, `--hybrid` to combine AST with sandbox inspection, or `--timeout` / `--memory-limit-mb` to tune sandbox guards.
23
+ - `--json-errors` prints machine-readable payloads with error code `20`.
24
+
25
+ ## `pfg gen`
26
+
27
+ `gen` hosts multiple subcommands. Inspect them with `pfg gen -- --help`.
28
+
29
+ ### `pfg gen json`
30
+
31
+ ```bash
32
+ pfg gen json ./models.py \
33
+ --out ./out/users.json \
34
+ --include pkg.User \
35
+ --n 10 \
36
+ --jsonl \
37
+ --indent 0 \
38
+ --orjson \
39
+ --shard-size 1000 \
40
+ --seed 42 \
41
+ --freeze-seeds \
42
+ --preset boundary
43
+ ```
44
+
45
+ - `--out` is required and supports templates (`{model}`, `{case_index}`, `{timestamp}`).
46
+ - Control volume with `--n` (records) and `--shard-size` (records per file).
47
+ - Switch encoding with `--jsonl`, `--indent`, `--orjson/--no-orjson`.
48
+ - Determinism helpers: `--seed`, `--freeze-seeds`, `--freeze-seeds-file`, `--preset`.
49
+ - Observability: `--json-errors`, `--watch`, `--watch-debounce`, `--now`.
50
+
51
+ ### `pfg gen fixtures`
52
+
53
+ ```bash
54
+ pfg gen fixtures ./models.py \
55
+ --out tests/fixtures/test_models.py \
56
+ --style factory \
57
+ --scope module \
58
+ --cases 3 \
59
+ --return-type dict \
60
+ --p-none 0.2 \
61
+ --seed 42
62
+ ```
63
+
64
+ - `--out` is required and can use templates.
65
+ - `--style` controls structure (`functions`, `factory`, `class`).
66
+ - `--scope` sets fixture scope; `--cases` parametrises templates.
67
+ - `--return-type` chooses between returning the model or its dict representation.
68
+ - Determinism flags mirror `gen json`.
69
+
70
+ ### `pfg gen schema`
71
+
72
+ ```bash
73
+ pfg gen schema ./models.py --out ./schema --include pkg.User
74
+ ```
75
+
76
+ - Requires `--out` and writes JSON Schema files atomically.
77
+ - Combine with `--include`/`--exclude`, `--json-errors`, `--watch`, and `--now`.
78
+
79
+ ### `pfg gen explain`
80
+
81
+ ```bash
82
+ pfg gen explain ./models.py --tree --max-depth 2 --include pkg.User
83
+ ```
84
+
85
+ - `--tree` prints ASCII strategy diagrams.
86
+ - `--json` emits structured data suitable for tooling.
87
+ - Limit depth with `--max-depth`, filter models with `--include`/`--exclude`.
88
+ - Use `--json-errors` for machine-readable failures.
89
+
90
+ ## `pfg diff`
91
+
92
+ ```bash
93
+ pfg diff ./models.py \
94
+ --json-out out/users.json \
95
+ --fixtures-out tests/fixtures/test_models.py \
96
+ --schema-out schema \
97
+ --show-diff
98
+ ```
99
+
100
+ - Regenerates artifacts in-memory and compares them with existing files.
101
+ - Writes JSON summaries when you pass output paths.
102
+ - `--show-diff` streams unified diffs to stdout.
103
+ - Determinism helpers: `--seed`, `--freeze-seeds`.
104
+
105
+ ## `pfg check`
106
+
107
+ ```bash
108
+ pfg check ./models.py --json-errors --fixtures-out /tmp/fixtures.py
109
+ ```
110
+
111
+ - Validates configuration, discovery, and emitter destinations without writing artifacts.
112
+ - Mirrors `diff` output flags, including `--json-out`, `--fixtures-out`, and `--schema-out`.
113
+ - Use it in CI to block invalid configs before generation.
114
+
115
+ ## `pfg init`
116
+
117
+ ```bash
118
+ pfg init \
119
+ --pyproject-path pyproject.toml \
120
+ --yaml \
121
+ --yaml-path config/pydantic-fixturegen.yaml \
122
+ --seed 42 \
123
+ --union-policy weighted \
124
+ --enum-policy random \
125
+ --json-indent 2 \
126
+ --pytest-style functions \
127
+ --pytest-scope module
128
+ ```
129
+
130
+ - Scaffolds configuration files and optional fixture directories.
131
+ - Accepts `--no-pyproject` if you only want YAML.
132
+ - Adds `.gitkeep` inside `tests/fixtures/` unless you pass `--no-fixtures-dir`.
133
+
134
+ ## `pfg doctor`
135
+
136
+ ```bash
137
+ pfg doctor ./models.py --fail-on-gaps 0 --json-errors
138
+ ```
139
+
140
+ - Audits coverage gaps (fields without providers), risky imports, and sandbox findings.
141
+ - Use `--fail-on-gaps` to turn warnings into non-zero exits.
142
+ - Combine with `--include`/`--exclude` to focus on specific models.
143
+
144
+ ## `pfg schema`
145
+
146
+ ```bash
147
+ pfg schema config --out schema/config.schema.json
148
+ ```
149
+
150
+ - Dumps JSON Schemas describing configuration or model outputs.
151
+ - The `config` subcommand wraps the schema bundled under `pydantic_fixturegen/schemas/config.schema.json`.
152
+
153
+ ## Tips for scripting
154
+
155
+ - Append `--json-errors` anywhere you need machine-readable results; check exit codes for CI gating.
156
+ - Use `--now` when you want reproducible “current time” values in generated data.
157
+ - `--preset boundary` or `--preset boundary-max` applies opinionated strategies; combine with explicit overrides to fine-tune probability.
158
+ - When piping commands, pass `--` before flags for subcommands to avoid Typer proxy conflicts.
159
+
160
+ Continue to [output paths](./output-paths.md) for templating and [logging](./logging.md) for structured events that pair with automation.
@@ -0,0 +1,36 @@
1
+ # Concepts: why pydantic-fixturegen exists
2
+
3
+ > Ground yourself in the principles behind deterministic fixture generation.
4
+
5
+ ## Deterministic by design
6
+
7
+ - Seeds cascade across Python `random`, Faker, and optional NumPy RNGs.
8
+ - Freeze files (`.pfg-seeds.json`) store per-model seeds so regeneration stays identical everywhere.
9
+ - Metadata banners capture seed, version, and digest to prove provenance.
10
+
11
+ ## Sandbox-first safety
12
+
13
+ - Untrusted models run inside a safe-import sandbox that blocks network calls, jails filesystem writes, and caps memory.
14
+ - Exit code `40` signals timeouts; diagnostics flag risky imports.
15
+ - Discovery supports AST-only mode when you cannot run user code at all.
16
+
17
+ ## CLI-first workflow
18
+
19
+ - `pfg` wraps every task: list models, generate JSON, emit fixtures, diff outputs, check configs, explain strategies, and run doctors.
20
+ - Commands share consistent flag names (`--include`, `--exclude`, `--seed`, `--preset`) to reduce context switching.
21
+ - Watch mode (`[watch]` extra) keeps artifacts in sync during development.
22
+
23
+ ## Extensibility with Pluggy
24
+
25
+ - Provider registry accepts new generators via `pfg_register_providers`.
26
+ - Strategies can be adjusted per-field through `pfg_modify_strategy`.
27
+ - Emitters can be replaced or augmented with `pfg_emit_artifact`.
28
+ - Entry points allow third-party packages to ship plugins without forking.
29
+
30
+ ## Atomic, auditable output
31
+
32
+ - Emitters write to temp files and rename into place, eliminating partial artifacts.
33
+ - JSON and schema content uses sorted keys and trailing newlines for clean diffs.
34
+ - Fixture modules store digest metadata and align with formatters like Ruff/Black.
35
+
36
+ Keep these concepts in mind as you explore the [quickstart](./quickstart.md), dive into [configuration](./configuration.md), or extend the system via [providers](./providers.md).