You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: generate TypedDict types for input-side models (#738)
## Summary
Adds `TypedDict` counterparts for input-side models so users passing
plain dicts to resource-client methods get full type-checker support
without importing Pydantic models.
- Generate TypedDicts alongside Pydantic models via a second
`datamodel-code-generator` pass (`--output-model-type typing.TypedDict`)
in `poe generate-models`.
- Split generated content into `_models_generated.py` /
`_typeddicts_generated.py`. Hand-written `_models.py` / `_typeddicts.py`
now only hold shapes not exposed by the OpenAPI spec (e.g.
`RequestInput`, `RequestInputDict`).
- Extend `scripts/postprocess_generated_models.py` to trim the TypedDict
file to input-relevant classes (plus transitive deps), rename them with
a `Dict` suffix, and add `@docs_group('Typed dicts')`.
- Widen resource-client input parameters (`actor`, `task`,
`task_collection`, `request_queue`) to accept `TypedDict |
PydanticModel` unions.
- Update `.rules.md` and `manual_regenerate_models.yaml` to reflect the
new layout.
Closes#666.
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
BODY="This PR updates the auto-generated Pydantic models based on OpenAPI specification changes in [apify-docs PR #${DOCS_PR_NUMBER}](${DOCS_PR_URL})."
133
+
BODY="This PR updates the auto-generated Pydantic models and TypedDicts based on OpenAPI specification changes in [apify-docs PR #${DOCS_PR_NUMBER}](${DOCS_PR_URL})."
134
134
else
135
-
BODY="This PR updates the auto-generated Pydantic models from the [published OpenAPI specification](https://docs.apify.com/api/openapi.json)."
135
+
BODY="This PR updates the auto-generated Pydantic models and TypedDicts from the [published OpenAPI specification](https://docs.apify.com/api/openapi.json)."
Copy file name to clipboardExpand all lines: .rules.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,7 @@ uv run poe type-check # Run ty type checker
19
19
uv run poe unit-tests # Run unit tests
20
20
uv run poe check-docstrings # Verify async docstrings match sync
21
21
uv run poe fix-docstrings # Auto-fix async docstrings
22
-
uv run poe generate-models # Regenerate _models.py from live OpenAPI spec
22
+
uv run poe generate-models # Regenerate _models_generated.py and _typeddicts_generated.py from live OpenAPI spec
23
23
uv run poe generate-models-from-file <path># Regenerate from a local OpenAPI spec file
24
24
25
25
# Run a single test
@@ -73,7 +73,7 @@ Docstrings are written on sync clients and **automatically copied** to async cli
73
73
74
74
### Data Models
75
75
76
-
`src/apify_client/_models.py`is **auto-generated** — do not edit it manually.
76
+
`src/apify_client/_models_generated.py`and `src/apify_client/_typeddicts_generated.py` are **auto-generated** — do not edit them manually. The hand-maintained `src/apify_client/_models.py` and `src/apify_client/_typeddicts.py` hold only shapes that are not exposed by the OpenAPI spec (or that need local logic); import generated types directly from the `_*_generated` modules.
77
77
78
78
- Generated by `datamodel-code-generator` from the OpenAPI spec at `https://docs.apify.com/api/openapi.json` (config in `pyproject.toml` under `[tool.datamodel-codegen]`, aliases in `datamodel_codegen_aliases.json`)
79
79
- After generation, `scripts/postprocess_generated_models.py` is run to apply additional fixes
0 commit comments