Skip to content

feat: remove pydantic v1 output support#3031

Merged
koxudaxi merged 10 commits intomainfrom
split/pr2b-remove-v1-output-core
Mar 7, 2026
Merged

feat: remove pydantic v1 output support#3031
koxudaxi merged 10 commits intomainfrom
split/pr2b-remove-v1-output-core

Conversation

@koxudaxi
Copy link
Copy Markdown
Owner

@koxudaxi koxudaxi commented Mar 6, 2026

Summary

Validation

  • tox run -e 3.13-parallel
  • .tox/3.13-parallel/bin/diff-cover --compare-branch split/pr2c-v2-test-baseline .tox/coverage.3.13-parallel.xml

Summary by CodeRabbit

  • Breaking Changes

    • Pydantic v1 output removed — Pydantic v2 is now the only supported output.
  • Documentation

    • All example code migrated to Pydantic v2 patterns (RootModel, model_rebuild, TypeAliasType); timestamps in examples now use AwareDatetime; some examples show fields with explicit aliases.
  • Improvements

    • CLI/help text clarified for --use-pendulum, --enable-faux-immutability and --use-frozen-field to reference Pydantic v2 semantics.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 6, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR removes Pydantic v1 support and migrates the codebase and docs to Pydantic v2: deletes v1 generator modules/tests, updates examples to RootModel/ConfigDict/TypeAliasType/model_rebuild, replaces parse_obj with model_validate, and removes Pydantic v1 compatibility shims.

Changes

Cohort / File(s) Summary
Docs — Pydantic v2 migration
docs/cli-reference/.../base-options.md, docs/cli-reference/.../field-customization.md, docs/cli-reference/.../general-options.md, docs/cli-reference/.../model-customization.md, docs/cli-reference/.../openapi-only-options.md, docs/cli-reference/.../template-customization.md, docs/cli-reference/.../typing-customization.md
Rewrote generated examples from Pydantic v1 → v2: replaced __root__ with RootModel[...] + root fields, update_forward_refs()model_rebuild(), TypeAliasTypeAliasType, example/regexexamples/pattern, added ConfigDict/model_config and adjusted imports.
Docs — help text & examples
docs/cli-reference/quick-reference.md, docs/cli-reference/graphql-only-options.md, docs/cli-reference/base-options.md
Updated option descriptions (pendulum mapping wording, faux immutability wording), adjusted examples to use AwareDatetime and Field(..., alias=...) where applicable.
Removed Pydantic v1 generator modules
src/datamodel_code_generator/model/pydantic/__init__.py, src/datamodel_code_generator/model/pydantic/base_model.py, src/datamodel_code_generator/model/pydantic/custom_root_type.py, src/datamodel_code_generator/model/pydantic/imports.py, src/datamodel_code_generator/model/pydantic/types.py
Deleted entire Pydantic v1 generation surface: BaseModel/custom root logic, v1-specific import constants and type manager, forward-ref helpers and exported v1 symbols.
Core code changes
src/datamodel_code_generator/__main__.py, src/datamodel_code_generator/arguments.py, src/datamodel_code_generator/enums.py, src/datamodel_code_generator/input_model.py, src/datamodel_code_generator/model/__init__.py, src/datamodel_code_generator/prompt_data.py, src/datamodel_code_generator/util.py, src/datamodel_code_generator/model/pydantic_base.py, src/datamodel_code_generator/model/base.py, src/datamodel_code_generator/types.py
Removed DataModelType.PydanticBaseModel and associated branches; removed compatibility wrappers (model_dump/model_validate/model_copy/get_fields_set); replaced parse_objmodel_validate; simplified is_pydantic_v2; removed process_const side-effects; adjusted DataType/func-call behavior and removed value-based type inference helper.
Tests — expected fixtures updated/removed
tests/data/expected/.../jsonschema/*_pydantic_v1.py, tests/data/expected/main/input_model/*.py, tests/data/expected/main/jsonschema/cli_doc/titles_use_title_as_name.py
Removed Pydantic v1 expected fixtures; added/updated Pydantic v2 expected outputs (RootModel-based files), removed unique_items=True in set/frozenset Field examples, updated DataModelType literals.
Tests — test removals & harness updates
tests/model/pydantic/*, tests/main/jsonschema/test_main_jsonschema.py, tests/main/openapi/test_main_openapi.py, tests/test_input_model.py, tests/conftest.py, tests/main/graphql/test_annotated.py, tests/test_main_kr.py
Deleted v1-specific unit tests; updated test helpers and expectations to target pydantic_v2, removed pydantic_v1 from valid keys, removed default_output_model_type helper param, and adjusted docstrings/expectations (uniqueItems/pendulum text).
Small targeted edits & docs/output tweaks
src/datamodel_code_generator/arguments.py, src/datamodel_code_generator/__main__.py, src/datamodel_code_generator/model/pydantic_base.py, src/datamodel_code_generator/types.py, various tests
Help string tweak for --use-frozen-field, removed Config.parse_obj, use bound model_dump call, narrowed function-type emission behavior, and a number of test/fixture path updates.

Sequence Diagram(s)

(Skipped)

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested labels

breaking-change-analyzed, breaking-change

Suggested reviewers

  • ilovelinux

Poem

🐰 I hopped through code both old and new,

I nudged out root and welcomed RootModel too.
parse_obj waved a gentle goodbye,
model_rebuild now hops high and spry.
Pydantic v2 sprouts carrots in view.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: remove pydantic v1 output support' directly and clearly summarizes the main change: removal of Pydantic v1 output model support from the codebase.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch split/pr2b-remove-v1-output-core

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 6, 2026

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Mar 6, 2026

Merging this PR will not alter performance

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

✅ 11 untouched benchmarks
⏩ 98 skipped benchmarks1


Comparing split/pr2b-remove-v1-output-core (23a36ce) with main (cd3569b)

Open in CodSpeed

Footnotes

  1. 98 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@koxudaxi koxudaxi force-pushed the split/pr2b-switch-default-v2 branch from b547ca6 to e6902a6 Compare March 6, 2026 15:13
@koxudaxi koxudaxi force-pushed the split/pr2b-remove-v1-output-core branch from 68cfffd to 927fa33 Compare March 6, 2026 15:14
Base automatically changed from split/pr2b-switch-default-v2 to main March 6, 2026 15:19
@koxudaxi koxudaxi marked this pull request as ready for review March 6, 2026 15:20
@koxudaxi koxudaxi force-pushed the split/pr2b-remove-v1-output-core branch 2 times, most recently from a63d588 to 5ccfb23 Compare March 6, 2026 15:36
@koxudaxi koxudaxi changed the base branch from main to split/pr2c-v2-test-baseline March 6, 2026 15:36
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (cd3569b) to head (23a36ce).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##              main     #3031    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files           95        86     -9     
  Lines        18095     17710   -385     
  Branches      2094      2069    -25     
==========================================
- Hits         18095     17710   -385     
Flag Coverage Δ
unittests 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Base automatically changed from split/pr2c-v2-test-baseline to main March 7, 2026 03:19
@koxudaxi koxudaxi force-pushed the split/pr2b-remove-v1-output-core branch from 5ccfb23 to 29e75b7 Compare March 7, 2026 03:24
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/datamodel_code_generator/util.py (1)

302-306: ⚠️ Potential issue | 🟡 Minor

Remove the unused model_validate() utility function or document its purpose.

This function is not used anywhere in the codebase. All .model_validate() calls are on Pydantic model instances (e.g., JsonSchemaObject.model_validate(...), Config.model_validate(...)), not calls to this utility wrapper. If this function is intended as a public API for external users or for future use, it should have explicit documentation, tests, and either be removed from # pragma: no cover or marked as intentionally uncovered with a comment explaining why.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/datamodel_code_generator/util.py` around lines 302 - 306, The helper
function model_validate is unused and should be removed or explicitly
documented/tested: either delete the model_validate function and any related
unused imports/usages, or keep it but add a clear docstring explaining its
public purpose, remove the "# pragma: no cover" (or add a comment why coverage
is excluded), add unit tests exercising model_validate (covering both pydantic
v1 and v2 paths), and, if it's part of the public API, include it in module
exports (e.g., __all__) so callers can find it; locate the function by name
model_validate in this module to apply the change.
src/datamodel_code_generator/model/base.py (1)

189-197: ⚠️ Potential issue | 🟡 Minor

Don’t exempt process_const() from coverage.

This is active field-initialization logic, not a dead branch: it changes default, required, and nullable for const fields. Marking the whole method no cover makes const regressions invisible to diff-cover instead of exercising them with a targeted test.

Suggested change
-    def process_const(self) -> None:  # pragma: no cover
+    def process_const(self) -> None:
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/datamodel_code_generator/model/base.py` around lines 189 - 197, Remove
the coverage exemption on process_const and add a targeted unit test: delete the
"# pragma: no cover" on the process_const method in the class defined in
src/datamodel_code_generator/model/base.py so the method is measured by
coverage, and add a unit test that constructs the model with extras containing
"const" and asserts that process_const sets self.default to extras["const"],
self.const is True, self.required is False, and self.nullable is False (call the
method via the same public initializer/path used in production to ensure
behavior is exercised).
🧹 Nitpick comments (1)
src/datamodel_code_generator/__main__.py (1)

394-410: Remove redundant @classmethod decorators for consistency.

In Pydantic v2, @field_validator implicitly handles classmethod behavior. The explicit @classmethod decorator is redundant. Other validators in this file (e.g., lines 159, 174, 187) don't use @classmethod, so removing it here would improve consistency.

♻️ Proposed fix
 `@field_validator`("input_model", mode="before")
-@classmethod
-def coerce_input_model_to_list(cls, v: str | list[str] | None) -> list[str] | None:  # ty: ignore
+def coerce_input_model_to_list(cls, v: str | list[str] | None) -> list[str] | None:  # noqa: N805  # ty: ignore
     """Convert string input_model to list for backwards compatibility."""
     if isinstance(v, str):
         return [v]
     return v

 `@field_validator`("class_name_affix_scope", mode="before")
-@classmethod
-def validate_class_name_affix_scope(cls, v: str | ClassNameAffixScope | None) -> ClassNameAffixScope:  # ty: ignore
+def validate_class_name_affix_scope(cls, v: str | ClassNameAffixScope | None) -> ClassNameAffixScope:  # noqa: N805  # ty: ignore
     """Convert string to ClassNameAffixScope enum."""
     if v is None:  # pragma: no cover
         return ClassNameAffixScope.All
     if isinstance(v, str):
         return ClassNameAffixScope(v)
     return v  # pragma: no cover
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/datamodel_code_generator/__main__.py` around lines 394 - 410, Remove the
redundant `@classmethod` decorators on the two Pydantic validators:
coerce_input_model_to_list and validate_class_name_affix_scope; keep the
`@field_validator`(...) decorators (mode="before") intact so Pydantic v2 treats
them as class-level validators, and ensure the function signatures and return
types remain unchanged to preserve behavior.
🤖 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/field-customization.md`:
- Around line 3705-3712: Replace the incorrect construction
ExtendedProcessingTask('COMPLETED') in the default_factory of
ProcessingStatusUnionTitle with the union-appropriate variant
ProcessingStatusUnionTitle('COMPLETED'); the literal 'COMPLETED' corresponds to
the ProcessingStatusTitle enum branch (not ExtendedProcessingTask which expects
ProcessingTasksTitle or NestedCommentTitle), so update the Field default_factory
to instantiate ProcessingStatusUnionTitle('COMPLETED') to match the union type
and the example at line 3681.

In `@docs/cli-reference/typing-customization.md`:
- Around line 3835-3842: The docs overstate pendulum support: update the
--use-pendulum option description to state it only maps OpenAPI date, time and
duration to pendulum.Date, pendulum.Time and pendulum.Duration, and that
date-time fields continue to use pydantic.AwareDatetime (not pendulum.DateTime);
also mention that users can change the generated datetime type via the
--output-datetime-class option if they need a different datetime class. Ensure
references to AwareDatetime, Date, Duration, --use-pendulum, and
--output-datetime-class are present so readers can find the related examples and
flags.
- Around line 3145-3147: The example showing class Pets(RootModel[list[Pet]]):
root: Annotated[list[Pet], Field(max_length=10, min_length=1)] hides the fact
that the original schema's uniqueItems: true is not preserved when using
--use-annotated; update the docs text near this example to explicitly state that
--use-annotated alone will not enforce uniqueItems and either add a short note
explaining this or add a cross-reference/link to the --use-unique-items-as-set
option so readers know to use that flag to preserve uniqueness constraints for
the Pets root type.

---

Outside diff comments:
In `@src/datamodel_code_generator/model/base.py`:
- Around line 189-197: Remove the coverage exemption on process_const and add a
targeted unit test: delete the "# pragma: no cover" on the process_const method
in the class defined in src/datamodel_code_generator/model/base.py so the method
is measured by coverage, and add a unit test that constructs the model with
extras containing "const" and asserts that process_const sets self.default to
extras["const"], self.const is True, self.required is False, and self.nullable
is False (call the method via the same public initializer/path used in
production to ensure behavior is exercised).

In `@src/datamodel_code_generator/util.py`:
- Around line 302-306: The helper function model_validate is unused and should
be removed or explicitly documented/tested: either delete the model_validate
function and any related unused imports/usages, or keep it but add a clear
docstring explaining its public purpose, remove the "# pragma: no cover" (or add
a comment why coverage is excluded), add unit tests exercising model_validate
(covering both pydantic v1 and v2 paths), and, if it's part of the public API,
include it in module exports (e.g., __all__) so callers can find it; locate the
function by name model_validate in this module to apply the change.

---

Nitpick comments:
In `@src/datamodel_code_generator/__main__.py`:
- Around line 394-410: Remove the redundant `@classmethod` decorators on the two
Pydantic validators: coerce_input_model_to_list and
validate_class_name_affix_scope; keep the `@field_validator`(...) decorators
(mode="before") intact so Pydantic v2 treats them as class-level validators, and
ensure the function signatures and return types remain unchanged to preserve
behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: fef37158-673f-4bc7-8650-27abd8ead56a

📥 Commits

Reviewing files that changed from the base of the PR and between cd3569b and 29e75b7.

⛔ Files ignored due to path filters (4)
  • docs/llms-full.txt is excluded by none and included by none
  • src/datamodel_code_generator/model/template/pydantic/BaseModel.jinja2 is excluded by none and included by none
  • src/datamodel_code_generator/model/template/pydantic/BaseModel_root.jinja2 is excluded by none and included by none
  • src/datamodel_code_generator/model/template/pydantic/Config.jinja2 is excluded by none and included by none
📒 Files selected for processing (43)
  • docs/cli-reference/base-options.md
  • docs/cli-reference/field-customization.md
  • docs/cli-reference/general-options.md
  • docs/cli-reference/graphql-only-options.md
  • docs/cli-reference/model-customization.md
  • docs/cli-reference/openapi-only-options.md
  • docs/cli-reference/quick-reference.md
  • docs/cli-reference/template-customization.md
  • docs/cli-reference/typing-customization.md
  • src/datamodel_code_generator/__main__.py
  • src/datamodel_code_generator/arguments.py
  • src/datamodel_code_generator/enums.py
  • src/datamodel_code_generator/input_model.py
  • src/datamodel_code_generator/model/__init__.py
  • src/datamodel_code_generator/model/base.py
  • src/datamodel_code_generator/model/pydantic/__init__.py
  • src/datamodel_code_generator/model/pydantic/base_model.py
  • src/datamodel_code_generator/model/pydantic/custom_root_type.py
  • src/datamodel_code_generator/model/pydantic/imports.py
  • src/datamodel_code_generator/model/pydantic/types.py
  • src/datamodel_code_generator/model/pydantic_base.py
  • src/datamodel_code_generator/prompt_data.py
  • src/datamodel_code_generator/types.py
  • src/datamodel_code_generator/util.py
  • tests/conftest.py
  • tests/data/expected/main/input_model/config_class.py
  • tests/data/expected/main/input_model/dataclass_with_python_types.py
  • tests/data/expected/main/input_model/model_with_python_types.py
  • tests/data/expected/main/input_model/multiple_with_pydantic_output.py
  • tests/data/expected/main/input_model/recursive_model_types.py
  • tests/data/expected/main/jsonschema/additional_properties_false_pydantic_v1.py
  • tests/data/expected/main/jsonschema/additional_properties_true_pydantic_v1.py
  • tests/data/expected/main/jsonschema/unevaluated_properties_pydantic_v1.py
  • tests/data/expected/main/jsonschema/unevaluated_properties_true_pydantic_v1.py
  • tests/data/expected/main/jsonschema/use_frozen_field_v1.py
  • tests/main/jsonschema/test_main_jsonschema.py
  • tests/main/openapi/test_main_openapi.py
  • tests/model/pydantic/__init__.py
  • tests/model/pydantic/test_base_model.py
  • tests/model/pydantic/test_constraint.py
  • tests/model/pydantic/test_custom_root_type.py
  • tests/model/pydantic/test_types.py
  • tests/test_input_model.py
💤 Files with no reviewable changes (21)
  • src/datamodel_code_generator/enums.py
  • src/datamodel_code_generator/model/pydantic/types.py
  • tests/data/expected/main/input_model/config_class.py
  • tests/model/pydantic/init.py
  • tests/data/expected/main/jsonschema/use_frozen_field_v1.py
  • src/datamodel_code_generator/model/init.py
  • tests/data/expected/main/jsonschema/additional_properties_false_pydantic_v1.py
  • tests/model/pydantic/test_base_model.py
  • tests/data/expected/main/jsonschema/unevaluated_properties_true_pydantic_v1.py
  • src/datamodel_code_generator/model/pydantic/base_model.py
  • src/datamodel_code_generator/input_model.py
  • tests/model/pydantic/test_custom_root_type.py
  • tests/model/pydantic/test_types.py
  • tests/model/pydantic/test_constraint.py
  • src/datamodel_code_generator/model/pydantic/custom_root_type.py
  • tests/data/expected/main/jsonschema/unevaluated_properties_pydantic_v1.py
  • tests/main/jsonschema/test_main_jsonschema.py
  • tests/data/expected/main/jsonschema/additional_properties_true_pydantic_v1.py
  • src/datamodel_code_generator/model/pydantic/init.py
  • src/datamodel_code_generator/model/pydantic/imports.py
  • tests/main/openapi/test_main_openapi.py

Comment thread docs/cli-reference/field-customization.md
Comment thread docs/cli-reference/typing-customization.md
Comment thread docs/cli-reference/typing-customization.md
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
docs/cli-reference/field-customization.md (1)

3708-3712: ⚠️ Potential issue | 🟠 Major

Fix the default_factory to return the inner union member, not the RootModel wrapper.

In Pydantic v2, RootModel validates the root field against its inner type. Here, root is typed as ProcessingStatusDetail | ExtendedProcessingTask | ProcessingStatusTitle, but the factory returns ProcessingStatusUnionTitle(...) (the wrapper class). The factory must produce a value matching the inner union type instead.

🛠️ Suggested doc fix
     class ProcessingStatusUnionTitle(
         RootModel[ProcessingStatusDetail | ExtendedProcessingTask | ProcessingStatusTitle]
     ):
         root: ProcessingStatusDetail | ExtendedProcessingTask | ProcessingStatusTitle = (
             Field(
-                default_factory=lambda: ProcessingStatusUnionTitle('COMPLETED'),
+                default_factory=lambda: ProcessingStatusTitle('COMPLETED'),
                 title='Processing Status Union Title',
             )
         )
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/cli-reference/field-customization.md` around lines 3708 - 3712, The
default_factory for the root field is returning a RootModel wrapper
(ProcessingStatusUnionTitle(...)) instead of the inner union member; change the
default_factory to return the inner type value (e.g., an instance of
ProcessingStatusTitle) so the root field (typed as ProcessingStatusDetail |
ExtendedProcessingTask | ProcessingStatusTitle) receives a matching inner union
member; update the default_factory lambda to construct and return
ProcessingStatusTitle('COMPLETED') (or the appropriate
ProcessingStatusDetail/ExtendedProcessingTask instance) rather than
ProcessingStatusUnionTitle.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@docs/cli-reference/field-customization.md`:
- Around line 3708-3712: The default_factory for the root field is returning a
RootModel wrapper (ProcessingStatusUnionTitle(...)) instead of the inner union
member; change the default_factory to return the inner type value (e.g., an
instance of ProcessingStatusTitle) so the root field (typed as
ProcessingStatusDetail | ExtendedProcessingTask | ProcessingStatusTitle)
receives a matching inner union member; update the default_factory lambda to
construct and return ProcessingStatusTitle('COMPLETED') (or the appropriate
ProcessingStatusDetail/ExtendedProcessingTask instance) rather than
ProcessingStatusUnionTitle.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 655d9b32-56d3-45d7-ba2e-114182ec2475

📥 Commits

Reviewing files that changed from the base of the PR and between 29e75b7 and 344f179.

⛔ Files ignored due to path filters (1)
  • docs/llms-full.txt is excluded by none and included by none
📒 Files selected for processing (9)
  • docs/cli-reference/field-customization.md
  • docs/cli-reference/quick-reference.md
  • docs/cli-reference/typing-customization.md
  • src/datamodel_code_generator/prompt_data.py
  • tests/data/expected/main/jsonschema/titles_use_title_as_name_cli_doc.py
  • tests/main/graphql/test_annotated.py
  • tests/main/jsonschema/test_main_jsonschema.py
  • tests/main/openapi/test_main_openapi.py
  • tests/test_main_kr.py
✅ Files skipped from review due to trivial changes (2)
  • tests/main/graphql/test_annotated.py
  • tests/data/expected/main/jsonschema/titles_use_title_as_name_cli_doc.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • docs/cli-reference/quick-reference.md
  • src/datamodel_code_generator/prompt_data.py

@koxudaxi koxudaxi merged commit 01c2f41 into main Mar 7, 2026
37 checks passed
@koxudaxi koxudaxi deleted the split/pr2b-remove-v1-output-core branch March 7, 2026 16:45
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 7, 2026

Breaking Change Analysis

Result: Breaking changes detected

Reasoning: PR #3031 removes all Pydantic v1 output support including: (1) the DataModelType.PydanticBaseModel enum value which breaks the --output-model-type pydantic.BaseModel CLI option, (2) the entire model.pydantic module with v1-specific classes, (3) three Jinja2 templates for v1 output (BaseModel.jinja2, BaseModel_root.jinja2, Config.jinja2), and (4) v1/v2 compatibility utility functions (model_dump, model_validate, get_fields_set, model_copy). Users relying on v1 output generation, custom templates based on v1, or the compatibility utilities will need to migrate.

Content for Release Notes

Code Generation Changes

  • Pydantic v1 output support removed - The pydantic.BaseModel output model type has been completely removed. Generated code now only supports Pydantic v2 patterns including RootModel instead of __root__, model_rebuild() instead of update_forward_refs(), and model_config instead of class Config. Users generating Pydantic v1 models must migrate to v2 output. (feat: remove pydantic v1 output support #3031)

Custom Template Update Required

  • Pydantic v1 templates removed - The following Jinja2 templates have been deleted and users with custom templates extending them must migrate to v2 equivalents:
    • pydantic/BaseModel.jinja2 → use pydantic_v2/BaseModel.jinja2
    • pydantic/BaseModel_root.jinja2 → use pydantic_v2/RootModel.jinja2
    • pydantic/Config.jinja2 → removed (v2 uses model_config dict)
      (feat: remove pydantic v1 output support #3031)

API/CLI Changes

  • --output-model-type pydantic.BaseModel removed - The pydantic.BaseModel value for --output-model-type is no longer valid. Use pydantic_v2.BaseModel instead (now the default). (feat: remove pydantic v1 output support #3031)
  • Pydantic v1 compatibility utilities removed from Python API - The following functions were removed from datamodel_code_generator.util: model_dump(), model_validate(), get_fields_set(), model_copy(). Use Pydantic v2 methods directly (obj.model_dump(), cls.model_validate(), etc.). (feat: remove pydantic v1 output support #3031)
  • datamodel_code_generator.model.pydantic module removed - The entire Pydantic v1 model module including BaseModel, CustomRootType, DataModelField, DataTypeManager, and dump_resolve_reference_action has been removed. Use datamodel_code_generator.model.pydantic_v2 instead. (feat: remove pydantic v1 output support #3031)

This analysis was performed by Claude Code Action

@github-actions
Copy link
Copy Markdown
Contributor

🎉 Released in 0.55.0

This PR is now available in the latest release. See the release notes for details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant