Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (6)
🚧 Files skipped from review as they are similar to previous changes (4)
📝 WalkthroughWalkthroughThis PR removes Pydantic v1 references and support from docs, examples, tests, and configuration, and standardizes supported output-model-type values to Pydantic v2 (including pydantic_v2.dataclass), dataclasses, TypedDict, and msgspec. It also adds validation and ordering helpers to the CLI docs build script and updates test markers accordingly. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Merging this PR will not alter performance
|
1dcb07b to
babe1a0
Compare
927fa33 to
850d006
Compare
babe1a0 to
139bde3
Compare
a63d588 to
5ccfb23
Compare
139bde3 to
f141d7e
Compare
5ccfb23 to
29e75b7
Compare
f141d7e to
845e5a1
Compare
845e5a1 to
e923030
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3030 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 86 86
Lines 17710 17710
Branches 2069 2069
=========================================
Hits 17710 17710
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 5
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
docs/openapi.md (1)
273-278:⚠️ Potential issue | 🟡 MinorMissing
pydantic_v2.dataclassin supported output formats.The list should include
pydantic_v2.dataclassfor completeness with the available output model types.📝 Proposed fix
This option works with all output formats: - `pydantic_v2.BaseModel` +- `pydantic_v2.dataclass` - `dataclasses.dataclass` - `typing.TypedDict` - `msgspec.Struct`🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@docs/openapi.md` around lines 273 - 278, The documented list of supported output formats is missing the pydantic_v2.dataclass entry; update the list that currently shows `pydantic_v2.BaseModel`, `dataclasses.dataclass`, `typing.TypedDict`, and `msgspec.Struct` to also include `pydantic_v2.dataclass` so the docs reflect all available output model types.
🧹 Nitpick comments (3)
docs/cli-reference/manual/profile.md (1)
30-33: Clarify purpose of "legacy" profile example.With Pydantic v1 removed, a "legacy" profile using
pydantic_v2.BaseModelno longer demonstrates a distinct use case—it's the same as the default. Consider either:
- Removing this example profile entirely
- Repurposing it to show a different configuration (e.g., older Python version compatibility, specific field options)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@docs/cli-reference/manual/profile.md` around lines 30 - 33, The "legacy" profile shown as [tool.datamodel-codegen.profiles.legacy] with output-model-type = "pydantic_v2.BaseModel" is redundant now that Pydantic v1 is removed; either delete the entire legacy profile example or change it to demonstrate a genuinely different configuration (e.g., show compatibility settings such as an older Python target, custom field options, or an alternate output-model-type) by replacing the block under [tool.datamodel-codegen.profiles.legacy] with the new meaningful settings and update the surrounding text to explain its purpose.docs/cli-reference/utility-options.md (1)
164-167: Same clarification needed for "legacy" profile.This is the same example as in
profile.md. As noted there, a "legacy" profile withpydantic_v2.BaseModeldoesn't convey a meaningful use case. Consider updating both locations consistently.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@docs/cli-reference/utility-options.md` around lines 164 - 167, Clarify the purpose of the "legacy" profile shown by the TOML block with the header [tool.datamodel-codegen.profiles.legacy] and the example setting output-model-type = "pydantic_v2.BaseModel": update this doc (and the same example in profile.md) to either replace the example with a realistic legacy use-case or add a short note explaining why pydantic_v2.BaseModel is shown (e.g., compatibility with older codebases, illustrative only), and ensure both locations use identical wording so readers understand the intended scenario for the "legacy" profile.docs/faq.md (1)
218-226: Duplicate "See" reference and outdated filename.Line 218 and Line 225 both contain "See [Output Model Types]..." which appears redundant. Also, the link target
what_is_the_difference_between_v1_and_v2.mdseems semantically outdated now that v1 is removed—consider renaming this file in a follow-up if it hasn't already been updated.📝 Proposed fix to remove duplicate
See [Output Model Types](what_is_the_difference_between_v1_and_v2.md) for a detailed comparison. ```bash # For new projects datamodel-codegen --output-model-type pydantic_v2.BaseModel ...-See Output Model Types for more details.
📎 Related:
#803</details> <details> <summary>🤖 Prompt for AI Agents</summary>Verify each finding against the current code and only fix it if needed.
In
@docs/faq.mdaround lines 218 - 226, Remove the duplicated "See Output Model
Types" reference (the second
occurrence after the code block) and update the link target to the current,
semantically correct filename used in the repo (replace
what_is_the_difference_between_v1_and_v2.md with the new Output Model Types doc
name if it was renamed); ensure the code block with "datamodel-codegen
--output-model-type pydantic_v2.BaseModel ..." remains unchanged and only the
duplicate reference and outdated link are removed/updated.</details> </blockquote></details> </blockquote></details> <details> <summary>🤖 Prompt for all review comments with AI agents</summary>Verify each finding against the current code and only fix it if needed.
Inline comments:
In@action.yml:
- Around line 17-19: The action output description for the input named
"output-model-type" is missing the "pydantic_v2.dataclass" option; update the
description string for output-model-type to include "pydantic_v2.dataclass" so
it matches the DataModelType enum (DataModelType) values used by the codebase
and accurately documents supported types.In
@docs/ci-cd.md:
- Line 36: The docs table for the CLI option
output-model-typeis missing the
pydantic_v2.dataclassoption; update the options list foroutput-model-type
to includepydantic_v2.dataclassalongsidepydantic_v2.BaseModel,
dataclasses.dataclass,typing.TypedDict, andmsgspec.Structso the
documented choices match the actual CLI behavior.In
@docs/dynamic-model-generation.md:
- Line 283: Update the table row that currently reads "Pydantic v2 only | Only
Pydantic v2 is supported" to avoid redundant phrasing; replace the right-hand
cell with a clearer alternative such as "Pydantic v2 is the only supported
output" (locate the row by the exact string "Pydantic v2 only | Only Pydantic v2
is supported" and update the second cell text accordingly).In
@docs/index.md:
- Line 19: Update the summary bullet that currently reads "Generates Pydantic
v2, dataclasses, TypedDict, or msgspec output" to explicitly
include the Pydantic dataclass variant by adding "pydantic_v2.dataclass" (or
wording like "Pydantic v2 (BaseModel and pydantic_v2.dataclass)") so the docs
match the rest of the PR wherepydantic_v2.dataclassis treated as a distinct
output type; locate and edit the bullet in docs/index.md to reflect the
additional supported output.In
@scripts/build_cli_docs.py:
- Around line 458-465: The code currently silently skips legacy model keys like
"pydantic_v1" when iterating sorted_models (constructed from
example.model_outputs using the order list ["pydantic_v2", "dataclass",
"typeddict", "msgspec"]); instead, add explicit validation that fails fast: when
encountering any deprecated/unknown keys (e.g., model_key == "pydantic_v1" or
model_key not in the allowed set), raise a clear ValueError (or SystemExit) with
context including the example identifier and the offending key so stale
.cli_doc_collection.json data is surfaced; apply the same guard/change for the
second occurrence handling the same logic (the block around the other occurrence
corresponding to lines 511-518) so validation happens before rendering.
Outside diff comments:
In@docs/openapi.md:
- Around line 273-278: The documented list of supported output formats is
missing the pydantic_v2.dataclass entry; update the list that currently shows
pydantic_v2.BaseModel,dataclasses.dataclass,typing.TypedDict, and
msgspec.Structto also includepydantic_v2.dataclassso the docs reflect all
available output model types.
Nitpick comments:
In@docs/cli-reference/manual/profile.md:
- Around line 30-33: The "legacy" profile shown as
[tool.datamodel-codegen.profiles.legacy] with output-model-type =
"pydantic_v2.BaseModel" is redundant now that Pydantic v1 is removed; either
delete the entire legacy profile example or change it to demonstrate a genuinely
different configuration (e.g., show compatibility settings such as an older
Python target, custom field options, or an alternate output-model-type) by
replacing the block under [tool.datamodel-codegen.profiles.legacy] with the new
meaningful settings and update the surrounding text to explain its purpose.In
@docs/cli-reference/utility-options.md:
- Around line 164-167: Clarify the purpose of the "legacy" profile shown by the
TOML block with the header [tool.datamodel-codegen.profiles.legacy] and the
example setting output-model-type = "pydantic_v2.BaseModel": update this doc
(and the same example in profile.md) to either replace the example with a
realistic legacy use-case or add a short note explaining why
pydantic_v2.BaseModel is shown (e.g., compatibility with older codebases,
illustrative only), and ensure both locations use identical wording so readers
understand the intended scenario for the "legacy" profile.In
@docs/faq.md:
- Around line 218-226: Remove the duplicated "See Output Model
Types" reference (the second
occurrence after the code block) and update the link target to the current,
semantically correct filename used in the repo (replace
what_is_the_difference_between_v1_and_v2.md with the new Output Model Types doc
name if it was renamed); ensure the code block with "datamodel-codegen
--output-model-type pydantic_v2.BaseModel ..." remains unchanged and only the
duplicate reference and outdated link are removed/updated.</details> --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> **Configuration used**: Path: .coderabbit.yaml **Review profile**: CHILL **Plan**: Pro **Run ID**: `0cc7e1de-a354-4c43-bfd2-186ae870c109` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 01c2f418250f0e05bdfe24beb01b52148ea504f5 and e9230304e47657baea8973a5fe8ee5e8d3674a35. </details> <details> <summary>⛔ Files ignored due to path filters (2)</summary> * `docs/llms-full.txt` is excluded by none and included by none * `uv.lock` is excluded by `!**/*.lock`, `!**/*.lock` and included by none </details> <details> <summary>📒 Files selected for processing (15)</summary> * `README.md` * `action.yml` * `docs/ci-cd.md` * `docs/cli-reference/manual/profile.md` * `docs/cli-reference/utility-options.md` * `docs/dynamic-model-generation.md` * `docs/faq.md` * `docs/index.md` * `docs/openapi.md` * `docs/python-version-compatibility.md` * `docs/root-model-and-type-alias.md` * `docs/using_as_module.md` * `docs/what_is_the_difference_between_v1_and_v2.md` * `pyproject.toml` * `scripts/build_cli_docs.py` </details> <details> <summary>💤 Files with no reviewable changes (3)</summary> * docs/python-version-compatibility.md * docs/root-model-and-type-alias.md * pyproject.toml </details> </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
🤖 Generated by GitHub Actions
There was a problem hiding this comment.
🧹 Nitpick comments (1)
docs/cli-reference/utility-options.md (1)
164-167: Consider centralizing duplicated profile examples.The exact same profile configuration example appears in both
docs/cli-reference/manual/profile.md(lines 30-33) and here. While this duplication might be intentional for self-contained documentation pages, it creates a maintenance burden—future updates would need to be synchronized across both files.Consider using a documentation include/snippet mechanism if your documentation framework supports it, or add a cross-reference comment noting the duplication.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@docs/cli-reference/utility-options.md` around lines 164 - 167, The dataclass profile example ([tool.datamodel-codegen.profiles.dataclass] with output-model-type = "dataclasses.dataclass") is duplicated across documentation; please centralize it by extracting this snippet into a single reusable include/snippet (or a shared docs partial) and replace the copies with an include reference, or alternatively add a clear cross-reference comment pointing to the canonical snippet location so future edits only need to be made in one place.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@docs/cli-reference/utility-options.md`:
- Around line 164-167: The dataclass profile example
([tool.datamodel-codegen.profiles.dataclass] with output-model-type =
"dataclasses.dataclass") is duplicated across documentation; please centralize
it by extracting this snippet into a single reusable include/snippet (or a
shared docs partial) and replace the copies with an include reference, or
alternatively add a clear cross-reference comment pointing to the canonical
snippet location so future edits only need to be made in one place.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 51cc985b-ba5b-477f-be99-dc47e84bf6f1
⛔ Files ignored due to path filters (1)
docs/llms-full.txtis excluded by none and included by none
📒 Files selected for processing (2)
docs/cli-reference/manual/profile.mddocs/cli-reference/utility-options.md
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@docs/cli-reference/quick-reference.md`:
- Line 118: The quick-reference entry for `--output-model-type` (link:
model-customization.md#output-model-type) is truncated because the source
description includes a newline; fix by either making the first line of the
source description in model-customization.md self-contained (complete text on
the first line) or update the summary generation to collapse embedded newlines
into a single line before building the table (so the table cell shows the full
list). Target the code that generates the quick-reference summaries (or edit the
markdown heading/first-paragraph for `output-model-type`) so the description no
longer breaks after "Pydantic v2 dataclass," and the full set of supported
variants appears in the table.
In `@scripts/build_cli_docs.py`:
- Around line 995-1002: The check compares normalized_content to the raw on-disk
text, so files that only differ by trailing whitespace or missing final newline
still report mismatches; update the comparison in the block that uses
output_path, normalized_content, and existing to normalize the existing file
before comparing (e.g., apply the same rstrip()+ "\n" normalization to existing)
so the equality check uses normalized_content == normalized_existing.
- Around line 404-411: The validator validated_model_outputs currently uses a
hard-coded display_order tuple with "dataclass" which prevents recognizing both
"pydantic_v2.dataclass" and "dataclasses.dataclass"; change display_order into a
single ordered list or tuple that includes both "pydantic_v2.dataclass" and
"dataclasses.dataclass" (e.g. include those explicit keys alongside
"pydantic_v2", "typeddict", "msgspec"), then validate unexpected_keys against
that set and sort example.model_outputs.items() using that order (still via
display_order.index). Additionally extract that ordered key→label mapping into a
shared variable (e.g. ORDERED_MODEL_OUTPUT_LABELS) so the same canonical keys
are reused when building tab labels elsewhere instead of collapsing or rejecting
the new dataclass variants. Ensure validated_model_outputs and the tab rendering
code reference this shared mapping.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 4c35e796-0059-407b-a07f-7f9387c80610
⛔ Files ignored due to path filters (2)
docs/llms-full.txtis excluded by none and included by nonedocs/llms.txtis excluded by none and included by none
📒 Files selected for processing (22)
README.mdaction.ymldocs/ci-cd.mddocs/cli-reference/base-options.mddocs/cli-reference/field-customization.mddocs/cli-reference/general-options.mddocs/cli-reference/graphql-only-options.mddocs/cli-reference/model-customization.mddocs/cli-reference/openapi-only-options.mddocs/cli-reference/quick-reference.mddocs/cli-reference/template-customization.mddocs/cli-reference/typing-customization.mddocs/cli-reference/utility-options.mddocs/dynamic-model-generation.mddocs/faq.mddocs/index.mddocs/openapi.mddocs/output-model-types.mddocs/python-version-compatibility.mdscripts/build_cli_docs.pytests/main/jsonschema/test_main_jsonschema.pyzensical.toml
💤 Files with no reviewable changes (7)
- docs/cli-reference/base-options.md
- docs/cli-reference/general-options.md
- docs/cli-reference/field-customization.md
- docs/cli-reference/graphql-only-options.md
- docs/cli-reference/typing-customization.md
- docs/cli-reference/template-customization.md
- docs/cli-reference/openapi-only-options.md
✅ Files skipped from review due to trivial changes (1)
- docs/output-model-types.md
🚧 Files skipped from review as they are similar to previous changes (5)
- docs/python-version-compatibility.md
- docs/faq.md
- action.yml
- docs/ci-cd.md
- docs/index.md
Breaking Change AnalysisResult: No breaking changes detected Reasoning: This PR is documentation-only. No library source code files (datamodel_code_generator/) were changed. The PR updates documentation, build scripts, test fixtures, and project metadata to remove Pydantic v1 references, but the actual breaking change (removal of Pydantic v1 output support) is implemented in PR #3031. This PR explicitly keeps documentation changes separate from code changes for easier review. Changes to pyproject.toml (removing pydantic1 dev dependency group), scripts/build_cli_docs.py (doc tooling), and tests/conftest.py (test infrastructure) are internal development changes that don't affect end users. This analysis was performed by Claude Code Action |
|
🎉 Released in 0.55.0 This PR is now available in the latest release. See the release notes for details. |
Summary
Validation
Summary by CodeRabbit
Documentation
Chores