Metadata-Version: 2.4
Name: pydantic-fixturegen
Version: 1.2.0
Summary: Deterministic fixture generator for Pydantic models.
Project-URL: Homepage, https://github.com/casper-kristiansson/pydantic-fixturegen
Project-URL: Documentation, https://github.com/casper-kristiansson/pydantic-fixturegen
Project-URL: Repository, https://github.com/casper-kristiansson/pydantic-fixturegen
Author: Fixturegen Developers
License: MIT
License-File: LICENSE
Classifier: Development Status :: 5 - Production/Stable
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Python: >=3.10
Requires-Dist: click>=8.1.7
Requires-Dist: faker>=3.0.0
Requires-Dist: pluggy>=1.5.0
Requires-Dist: pydantic>=2.12.4
Requires-Dist: tomli>=2.0.1; python_version < '3.11'
Requires-Dist: typer>=0.12.4
Provides-Extra: all
Requires-Dist: beanie>=2.0.0; extra == 'all'
Requires-Dist: datamodel-code-generator>=0.35.0; extra == 'all'
Requires-Dist: email-validator>=2.0.0; extra == 'all'
Requires-Dist: fastapi>=0.115.0; extra == 'all'
Requires-Dist: httpx>=0.28.1; extra == 'all'
Requires-Dist: hypothesis>=1.0.0; extra == 'all'
Requires-Dist: mongomock-motor>=0.0.36; extra == 'all'
Requires-Dist: motor>=3.7.1; extra == 'all'
Requires-Dist: numpy>=2.2.6; (python_version < '3.11') and extra == 'all'
Requires-Dist: numpy>=2.3.2; (python_version >= '3.11') and extra == 'all'
Requires-Dist: orjson>=3.11.1; extra == 'all'
Requires-Dist: polyfactory>=2.22.0; extra == 'all'
Requires-Dist: pyarrow>=17.0.0; extra == 'all'
Requires-Dist: pydantic-extra-types>=2.6.0; extra == 'all'
Requires-Dist: pytest-regressions>=2.8.3; extra == 'all'
Requires-Dist: python-ulid>=2.2.0; extra == 'all'
Requires-Dist: pyyaml>=6.0.1; extra == 'all'
Requires-Dist: rstr>=3.2.2; extra == 'all'
Requires-Dist: semver>=3.0.0; extra == 'all'
Requires-Dist: sqlalchemy>=2.0.44; extra == 'all'
Requires-Dist: sqlmodel>=0.0.27; extra == 'all'
Requires-Dist: uvicorn>=0.32.0; extra == 'all'
Requires-Dist: watchfiles>=0.20.0; extra == 'all'
Provides-Extra: all-dev
Requires-Dist: beanie>=2.0.0; extra == 'all-dev'
Requires-Dist: datamodel-code-generator>=0.35.0; extra == 'all-dev'
Requires-Dist: email-validator>=2.0.0; extra == 'all-dev'
Requires-Dist: fastapi>=0.115.0; extra == 'all-dev'
Requires-Dist: httpx>=0.28.1; extra == 'all-dev'
Requires-Dist: hypothesis>=1.0.0; extra == 'all-dev'
Requires-Dist: mongomock-motor>=0.0.36; extra == 'all-dev'
Requires-Dist: motor>=3.7.1; extra == 'all-dev'
Requires-Dist: mypy>=1.11; extra == 'all-dev'
Requires-Dist: numpy>=2.2.6; (python_version < '3.11') and extra == 'all-dev'
Requires-Dist: numpy>=2.3.2; (python_version >= '3.11') and extra == 'all-dev'
Requires-Dist: orjson>=3.11.1; extra == 'all-dev'
Requires-Dist: polyfactory>=2.22.0; extra == 'all-dev'
Requires-Dist: pyarrow>=17.0.0; extra == 'all-dev'
Requires-Dist: pydantic-extra-types>=2.6.0; extra == 'all-dev'
Requires-Dist: pytest-cov>=5.0; extra == 'all-dev'
Requires-Dist: pytest-regressions>=2.8.3; extra == 'all-dev'
Requires-Dist: pytest>=8.3; extra == 'all-dev'
Requires-Dist: python-ulid>=2.2.0; extra == 'all-dev'
Requires-Dist: pyyaml>=6.0.1; extra == 'all-dev'
Requires-Dist: rstr>=3.2.2; extra == 'all-dev'
Requires-Dist: ruff>=0.6.5; extra == 'all-dev'
Requires-Dist: semantic-version>=2.10.0; extra == 'all-dev'
Requires-Dist: semver>=3.0.0; extra == 'all-dev'
Requires-Dist: sqlalchemy>=2.0.44; extra == 'all-dev'
Requires-Dist: sqlmodel>=0.0.27; extra == 'all-dev'
Requires-Dist: uvicorn>=0.32.0; extra == 'all-dev'
Requires-Dist: watchfiles>=0.20.0; extra == 'all-dev'
Provides-Extra: beanie
Requires-Dist: beanie>=2.0.0; extra == 'beanie'
Requires-Dist: motor>=3.7.1; extra == 'beanie'
Provides-Extra: dataset
Requires-Dist: pyarrow>=17.0.0; extra == 'dataset'
Provides-Extra: dev
Requires-Dist: mypy>=1.11; extra == 'dev'
Provides-Extra: docs
Provides-Extra: email
Requires-Dist: email-validator>=2.0.0; extra == 'email'
Provides-Extra: fastapi
Requires-Dist: fastapi>=0.115.0; extra == 'fastapi'
Requires-Dist: httpx>=0.28.1; extra == 'fastapi'
Requires-Dist: uvicorn>=0.32.0; extra == 'fastapi'
Provides-Extra: hypothesis
Requires-Dist: hypothesis>=1.0.0; extra == 'hypothesis'
Provides-Extra: lint
Requires-Dist: ruff>=0.6.5; extra == 'lint'
Provides-Extra: numpy
Requires-Dist: numpy>=2.2.6; (python_version < '3.11') and extra == 'numpy'
Requires-Dist: numpy>=2.3.2; (python_version >= '3.11') and extra == 'numpy'
Provides-Extra: openapi
Requires-Dist: datamodel-code-generator>=0.35.0; extra == 'openapi'
Requires-Dist: pyyaml>=6.0.1; extra == 'openapi'
Provides-Extra: orjson
Requires-Dist: orjson>=3.11.1; extra == 'orjson'
Provides-Extra: payment
Requires-Dist: pydantic-extra-types>=2.6.0; extra == 'payment'
Requires-Dist: python-ulid>=2.2.0; extra == 'payment'
Requires-Dist: semantic-version>=2.10.0; extra == 'payment'
Requires-Dist: semver>=3.0.0; extra == 'payment'
Provides-Extra: polyfactory
Requires-Dist: polyfactory>=2.22.0; extra == 'polyfactory'
Provides-Extra: regex
Requires-Dist: rstr>=3.2.2; extra == 'regex'
Provides-Extra: seed
Requires-Dist: beanie>=2.0.0; extra == 'seed'
Requires-Dist: mongomock-motor>=0.0.36; extra == 'seed'
Requires-Dist: motor>=3.7.1; extra == 'seed'
Requires-Dist: sqlalchemy>=2.0.44; extra == 'seed'
Requires-Dist: sqlmodel>=0.0.27; extra == 'seed'
Provides-Extra: sqlmodel
Requires-Dist: sqlalchemy>=2.0.44; extra == 'sqlmodel'
Requires-Dist: sqlmodel>=0.0.27; extra == 'sqlmodel'
Provides-Extra: test
Requires-Dist: beanie>=2.0.0; extra == 'test'
Requires-Dist: mongomock-motor>=0.0.36; extra == 'test'
Requires-Dist: motor>=3.7.1; extra == 'test'
Requires-Dist: pyarrow>=17.0.0; extra == 'test'
Requires-Dist: pytest-cov>=5.0; extra == 'test'
Requires-Dist: pytest-regressions>=2.8.3; extra == 'test'
Requires-Dist: pytest>=8.3; extra == 'test'
Requires-Dist: sqlalchemy>=2.0.44; extra == 'test'
Requires-Dist: sqlmodel>=0.0.27; extra == 'test'
Provides-Extra: watch
Requires-Dist: watchfiles>=0.20.0; extra == 'watch'
Description-Content-Type: text/markdown

# pydantic-fixturegen: deterministic Pydantic fixtures, JSON generator, secure sandbox

> Pydantic v2 deterministic fixtures, pytest fixtures, JSON generator, secure sandboxed CLI with Pluggy providers.

[![PyPI version](https://img.shields.io/pypi/v/pydantic-fixturegen.svg "PyPI")](https://pypi.org/project/pydantic-fixturegen/)
![Python versions](https://img.shields.io/pypi/pyversions/pydantic-fixturegen.svg "Python 3.10–3.14")
![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg "MIT License")

Generate deterministic Pydantic v2 data, pytest fixtures, and JSON quickly with a safe, task-focused CLI built for modern testing workflows.

📘 Read the full docs and examples at [pydantic-fixturegen.kitgrid.dev](https://pydantic-fixturegen.kitgrid.dev/).

## Why

<a id="why"></a>
<a id="features"></a>

- You keep tests reproducible with cascaded seeds across `random`, Faker, and optional NumPy.
- You run untrusted models inside a safe-import sandbox with network, filesystem, and memory guards.
- You drive JSON, pytest fixtures, schemas, and explanations from the CLI or Python helpers.
- You extend generation with Pluggy providers and preset bundles without forking core code.

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.

## Install

```bash
pip install pydantic-fixturegen
# Extras: orjson, regex, hypothesis, watch
pip install 'pydantic-fixturegen[all]'
```

Other flows → [docs/install.md](https://github.com/CasperKristiansson/pydantic-fixturegen/blob/main/docs/install.md)

## Quick start

<a id="quickstart"></a>

1. Create a small Pydantic v2 model file.
2. List models: `pfg list ./models.py`
3. Generate JSON: `pfg gen json ./models.py --include models.User --n 2 --indent 2 --out ./out/User`
4. Generate fixtures: `pfg gen fixtures ./models.py --out tests/fixtures/test_user.py --cases 3`
   Full steps → [docs/quickstart.md](https://github.com/CasperKristiansson/pydantic-fixturegen/blob/main/docs/quickstart.md)

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.

## Basics

### Core usage (top 5)

<a id="cli"></a>

```bash
pfg list <path>
pfg gen json <target> [--n --jsonl --indent --out]
pfg gen fixtures <target> [--style --scope --cases --out]
pfg gen schema <target> --out <file>
pfg doctor <target>
```

- `pfg list` discovers models with AST or safe-import; add `--ast` when you must avoid imports.
- `pfg gen json` emits JSON or JSONL; scale with `--n`, `--jsonl`, `--shard-size`, and `--freeze-seeds`.
- `pfg gen fixtures` writes pytest modules; tune `--style`, `--scope`, `--cases`, and `--return-type`.
- `pfg gen schema` dumps JSON Schema atomically; point `--out` at a file or directory template.
- `pfg doctor` audits coverage and sandbox warnings; fail builds with `--fail-on-gaps`.

All commands → [docs/cli.md](https://github.com/CasperKristiansson/pydantic-fixturegen/blob/main/docs/cli.md)

### Basic configuration

<a id="configuration-precedence"></a>

| key                   | type             | default   | purpose       |
| --------------------- | ---------------- | --------- | ------------- |
| seed                  | int \ str \ null | null      | Global seed   |
| locale                | str              | en_US     | Faker locale  |
| union_policy          | enum             | first     | Union branch  |
| enum_policy           | enum             | first     | Enum choice   |
| json.indent           | int              | 2         | Pretty JSON   |
| json.orjson           | bool             | false     | Fast JSON     |
| emitters.pytest.style | enum             | functions | Fixture style |
| emitters.pytest.scope | enum             | function  | Fixture scope |

```toml
[tool.pydantic_fixturegen]
seed = 42
[tool.pydantic_fixturegen.json]
indent = 2
```

Full matrix and precedence → [docs/configuration.md](https://github.com/CasperKristiansson/pydantic-fixturegen/blob/main/docs/configuration.md)

### Common tasks

- Freeze seeds for CI determinism → [docs/seeds.md](https://github.com/CasperKristiansson/pydantic-fixturegen/blob/main/docs/seeds.md)
- Use watch mode → [docs/quickstart.md#watch-mode](https://github.com/CasperKristiansson/pydantic-fixturegen/blob/main/docs/quickstart.md#watch-mode)
- Templated output paths → [docs/output-paths.md](https://github.com/CasperKristiansson/pydantic-fixturegen/blob/main/docs/output-paths.md)
- Provider customization → [docs/providers.md](https://github.com/CasperKristiansson/pydantic-fixturegen/blob/main/docs/providers.md)
- Capture explain trees or JSON diagnostics for review → [docs/explain.md](https://github.com/CasperKristiansson/pydantic-fixturegen/blob/main/docs/explain.md)

## Documentation

<a id="next-steps"></a>
<a id="architecture"></a>
<a id="comparison"></a>

[Index](https://github.com/CasperKristiansson/pydantic-fixturegen/blob/main/docs/index.md) · [Quickstart](https://github.com/CasperKristiansson/pydantic-fixturegen/blob/main/docs/quickstart.md) · [Cookbook](https://github.com/CasperKristiansson/pydantic-fixturegen/blob/main/docs/cookbook.md) · [Configuration](https://github.com/CasperKristiansson/pydantic-fixturegen/blob/main/docs/configuration.md) · [CLI](https://github.com/CasperKristiansson/pydantic-fixturegen/blob/main/docs/cli.md) · [Concepts](https://github.com/CasperKristiansson/pydantic-fixturegen/blob/main/docs/concepts.md) · [Features](https://github.com/CasperKristiansson/pydantic-fixturegen/blob/main/docs/features.md) · [Security](https://github.com/CasperKristiansson/pydantic-fixturegen/blob/main/docs/security.md) · [Architecture](https://github.com/CasperKristiansson/pydantic-fixturegen/blob/main/docs/architecture.md) · [Troubleshooting](https://github.com/CasperKristiansson/pydantic-fixturegen/blob/main/docs/troubleshooting.md) · [Alternatives](https://github.com/CasperKristiansson/pydantic-fixturegen/blob/main/docs/alternatives.md)

## Community

<a id="community"></a>

Open issues for bugs or ideas, start Discussions for design questions, and follow the security policy when you disclose sandbox bypasses.

## License

<a id="license"></a>

MIT. See [`LICENSE`](https://github.com/CasperKristiansson/pydantic-fixturegen/blob/main/LICENSE).
