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,137 @@
1
+ """Public Python API for pydantic-fixturegen."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from collections.abc import Sequence
6
+ from pathlib import Path
7
+
8
+ from pydantic_fixturegen.core.path_template import OutputTemplate
9
+
10
+ from ._runtime import (
11
+ generate_fixtures_artifacts,
12
+ generate_json_artifacts,
13
+ generate_schema_artifacts,
14
+ )
15
+ from .models import FixturesGenerationResult, JsonGenerationResult, SchemaGenerationResult
16
+
17
+ __all__ = [
18
+ "FixturesGenerationResult",
19
+ "JsonGenerationResult",
20
+ "SchemaGenerationResult",
21
+ "generate_fixtures",
22
+ "generate_json",
23
+ "generate_schema",
24
+ ]
25
+
26
+
27
+ def generate_json(
28
+ target: str | Path,
29
+ *,
30
+ out: str | Path,
31
+ count: int = 1,
32
+ jsonl: bool = False,
33
+ indent: int | None = None,
34
+ use_orjson: bool | None = None,
35
+ shard_size: int | None = None,
36
+ include: Sequence[str] | None = None,
37
+ exclude: Sequence[str] | None = None,
38
+ seed: int | None = None,
39
+ now: str | None = None,
40
+ freeze_seeds: bool = False,
41
+ freeze_seeds_file: str | Path | None = None,
42
+ preset: str | None = None,
43
+ ) -> JsonGenerationResult:
44
+ """Generate JSON artifacts for a single Pydantic model.
45
+
46
+ Parameters mirror the ``pfg gen json`` CLI command.
47
+ """
48
+
49
+ template = OutputTemplate(str(out))
50
+ freeze_path = Path(freeze_seeds_file) if freeze_seeds_file is not None else None
51
+
52
+ return generate_json_artifacts(
53
+ target=target,
54
+ output_template=template,
55
+ count=count,
56
+ jsonl=jsonl,
57
+ indent=indent,
58
+ use_orjson=use_orjson,
59
+ shard_size=shard_size,
60
+ include=_normalize_sequence(include),
61
+ exclude=_normalize_sequence(exclude),
62
+ seed=seed,
63
+ now=now,
64
+ freeze_seeds=freeze_seeds,
65
+ freeze_seeds_file=freeze_path,
66
+ preset=preset,
67
+ )
68
+
69
+
70
+ def generate_fixtures(
71
+ target: str | Path,
72
+ *,
73
+ out: str | Path,
74
+ style: str | None = None,
75
+ scope: str | None = None,
76
+ cases: int = 1,
77
+ return_type: str | None = None,
78
+ seed: int | None = None,
79
+ now: str | None = None,
80
+ p_none: float | None = None,
81
+ include: Sequence[str] | None = None,
82
+ exclude: Sequence[str] | None = None,
83
+ freeze_seeds: bool = False,
84
+ freeze_seeds_file: str | Path | None = None,
85
+ preset: str | None = None,
86
+ ) -> FixturesGenerationResult:
87
+ """Emit pytest fixtures for discovered models.
88
+
89
+ Returns a :class:`FixturesGenerationResult` describing the write outcome.
90
+ """
91
+
92
+ template = OutputTemplate(str(out))
93
+ freeze_path = Path(freeze_seeds_file) if freeze_seeds_file is not None else None
94
+
95
+ return generate_fixtures_artifacts(
96
+ target=target,
97
+ output_template=template,
98
+ style=style,
99
+ scope=scope,
100
+ cases=cases,
101
+ return_type=return_type,
102
+ seed=seed,
103
+ now=now,
104
+ p_none=p_none,
105
+ include=_normalize_sequence(include),
106
+ exclude=_normalize_sequence(exclude),
107
+ freeze_seeds=freeze_seeds,
108
+ freeze_seeds_file=freeze_path,
109
+ preset=preset,
110
+ )
111
+
112
+
113
+ def generate_schema(
114
+ target: str | Path,
115
+ *,
116
+ out: str | Path,
117
+ indent: int | None = None,
118
+ include: Sequence[str] | None = None,
119
+ exclude: Sequence[str] | None = None,
120
+ ) -> SchemaGenerationResult:
121
+ """Emit JSON Schema for one or more models."""
122
+
123
+ template = OutputTemplate(str(out))
124
+
125
+ return generate_schema_artifacts(
126
+ target=target,
127
+ output_template=template,
128
+ indent=indent,
129
+ include=_normalize_sequence(include),
130
+ exclude=_normalize_sequence(exclude),
131
+ )
132
+
133
+
134
+ def _normalize_sequence(values: Sequence[str] | None) -> Sequence[str] | None:
135
+ if values is None:
136
+ return None
137
+ return tuple(values)