Skip to content

Remove pydantic v1 runtime compat layer#3025

Merged
koxudaxi merged 12 commits intomainfrom
pr2a-remove-v1-compat
Mar 6, 2026
Merged

Remove pydantic v1 runtime compat layer#3025
koxudaxi merged 12 commits intomainfrom
pr2a-remove-v1-compat

Conversation

@koxudaxi
Copy link
Copy Markdown
Owner

@koxudaxi koxudaxi commented Mar 5, 2026

Summary by CodeRabbit

  • Breaking Changes

    • Pydantic v1 support removed — Pydantic v2 is now required.
  • Improvements

    • Unified configuration and validation to a single Pydantic v2 flow for more consistent behavior and clearer validation.
    • Simplified runtime behavior with fewer deprecation branches and reduced warning suppression.
  • Tests / CI

    • Removed Pydantic v1–specific tests and removed the py312-pydantic1 CI matrix/environment and related pytest warning filter.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 5, 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 branching across code and CI, unifies models and validators to Pydantic v2 APIs (ConfigDict, .model_validate, .model_dump, field/model validators), updates configuration and parser internals to v2 idioms, and removes pydantic1-specific tests and CI matrix entries.

Changes

Cohort / File(s) Summary
CI & Test Configuration
/.github/workflows/test.yaml, tox.ini
Removed py312-pydantic1 matrix/env entries and related tox references, dropping Pydantic v1 CI runs.
Project Config
pyproject.toml
Removed pytest filter that ignored the "Pydantic v1 runtime support is deprecated" warning.
Package Init & Exports
src/datamodel_code_generator/__init__.py
Unconditionally export GenerateConfig; removed conditional lazy-import guards and version-branch logic.
CLI / Main Config
src/datamodel_code_generator/__main__.py
Rewrote Config to use ConfigDict and unified model/field validators; added parse_obj, get_fields, __getitem__, and consolidated validation flow to v2-style validators.
Config Models
src/datamodel_code_generator/config.py
Set model_config = ConfigDict(...) on GenerateConfig, ParserConfig, and ParseConfig; simplified ExtraTemplateDataType to a single definition.
Input Model Loading
src/datamodel_code_generator/input_model.py
Removed runtime guards around Pydantic v2; use TypeAdapter unconditionally for schema generation and removed ImportError-based branches.
Core Models & Utilities
src/datamodel_code_generator/model/...
src/datamodel_code_generator/model/base.py, .../msgspec.py, .../pydantic_v2/*
Added uniform model_config via ConfigDict, replaced module-level model_copy/model_dump utilities with instance methods, unified rebuild/copy logic to v2 APIs, and adjusted dict/model methods to use .model_dump/.model_validate.
Parser Layer
src/datamodel_code_generator/parser/...
.../base.py, .../jsonschema.py, .../openapi.py
Replaced module-level model_validate/model_dump with class/instance methods, removed v1/v2 branches, standardized JsonSchema/OpenAPI parsing to Pydantic v2 idioms and updated public get_fields/dict surfaces.
Reference & Types
src/datamodel_code_generator/reference.py, src/datamodel_code_generator/types.py
Unified dict/model config to ConfigDict, removed legacy v1 validators (e.g., UnionIntFloat.__get_validators__), added model_config on DataType, and removed v1/v2 conditional logic.
Validators
src/datamodel_code_generator/validators.py
Made ValidatorsConfig an unconditional RootModel[...], removing TYPE_CHECKING and version guards.
Tests
tests/...
tests/main/test_main_general.py, tests/parser/*, tests/test_input_model.py, tests/main/jsonschema/*
Removed Pydantic v1-specific tests and guards; updated tests to use class/instance .model_validate/.model_dump and unguarded v2-related baseline checks.

Sequence Diagram(s)

sequenceDiagram
    participant CLI as CLI (user)
    participant Config as Config (model_validate)
    participant Parser as Parser
    participant SchemaModel as JsonSchema/OpenAPI Model
    participant Generator as Code Generator / Output

    CLI->>Config: parse args / files
    Config->>Config: model_validate(options) (ConfigDict / validators)
    Config->>Parser: provide parser/config options
    Parser->>SchemaModel: SchemaModel.model_validate(raw schema)
    SchemaModel->>Parser: .model_dump() normalized schema
    Parser->>Generator: generate code from normalized schema
    Generator->>CLI: return files / exit status
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

Possibly related PRs

Suggested labels

breaking-change-analyzed, breaking-change

Poem

"I'm a rabbit in the code burrow, nibbling branches away,
ConfigDict lights the tunnel and validators now play.
Models hop in tidy rows, no v1 forks to find,
Tests and CI trimmed and neat — a snug warren in my mind. 🥕"

🚥 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 'Remove pydantic v1 runtime compat layer' directly and accurately describes the main objective of this pull request, which systematically removes Pydantic v1 compatibility code throughout the codebase.
Docstring Coverage ✅ Passed Docstring coverage is 93.55% 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 pr2a-remove-v1-compat

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 5, 2026

📚 Docs Preview: https://pr-3025.datamodel-code-generator.pages.dev

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Mar 5, 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 pr2a-remove-v1-compat (3e47b62) with main (06edfad)

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.

Base automatically changed from pr1-extract-pydantic-base to main March 5, 2026 16:05
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 5, 2026

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff             @@
##              main     #3025    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files           95        95            
  Lines        18389     18165   -224     
  Branches      2129      2097    -32     
==========================================
- Hits         18389     18165   -224     
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.

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: 1

🧹 Nitpick comments (1)
src/datamodel_code_generator/validators.py (1)

37-38: Clean up stale ValidatorsConfig is None compatibility branch in call sites.

Since Line 37 now guarantees ValidatorsConfig is always defined, the if ValidatorsConfig is None check in src/datamodel_code_generator/__main__.py:843 is dead code and keeps obsolete v1 messaging.

Suggested follow-up diff in src/datamodel_code_generator/__main__.py
-    if ValidatorsConfig is None:
-        return None, "--validators option requires Pydantic v2. Please upgrade to Pydantic v2 or remove the option."
-
     with file_handle as data:
         try:
             raw = json.load(data)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/datamodel_code_generator/validators.py` around lines 37 - 38, Remove the
dead compatibility branch that checks "if ValidatorsConfig is None" in
src/datamodel_code_generator/__main__.py (around the code path that references
ValidatorsConfig when building/validating models); since ValidatorsConfig is now
always defined (class ValidatorsConfig in validators.py), delete the conditional
and its obsolete v1 messaging and simplify the flow to unconditionally use
ValidatorsConfig (update any related log/error text to remove v1 compatibility
wording).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/datamodel_code_generator/__main__.py`:
- Around line 150-152: Config.__getitem__ currently delegates to get() which
raises AttributeError for missing keys, violating mapping semantics; update
Config.__getitem__ to catch AttributeError from self.get(item) and re-raise a
KeyError(item) (preserving the original exception as the __cause__) so consumers
receive KeyError for missing keys; reference the Config.__getitem__ and get
methods when making the change.

---

Nitpick comments:
In `@src/datamodel_code_generator/validators.py`:
- Around line 37-38: Remove the dead compatibility branch that checks "if
ValidatorsConfig is None" in src/datamodel_code_generator/__main__.py (around
the code path that references ValidatorsConfig when building/validating models);
since ValidatorsConfig is now always defined (class ValidatorsConfig in
validators.py), delete the conditional and its obsolete v1 messaging and
simplify the flow to unconditionally use ValidatorsConfig (update any related
log/error text to remove v1 compatibility wording).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 0ab264d0-14e0-4070-b8d2-fb894c80cab1

📥 Commits

Reviewing files that changed from the base of the PR and between 06edfad and 42821fe.

📒 Files selected for processing (21)
  • .github/workflows/test.yaml
  • pyproject.toml
  • src/datamodel_code_generator/__init__.py
  • src/datamodel_code_generator/__main__.py
  • src/datamodel_code_generator/config.py
  • src/datamodel_code_generator/input_model.py
  • src/datamodel_code_generator/model/base.py
  • src/datamodel_code_generator/model/msgspec.py
  • src/datamodel_code_generator/model/pydantic_v2/__init__.py
  • src/datamodel_code_generator/model/pydantic_v2/base_model.py
  • src/datamodel_code_generator/parser/base.py
  • src/datamodel_code_generator/parser/jsonschema.py
  • src/datamodel_code_generator/parser/openapi.py
  • src/datamodel_code_generator/reference.py
  • src/datamodel_code_generator/types.py
  • src/datamodel_code_generator/validators.py
  • tests/main/test_main_general.py
  • tests/parser/test_jsonschema.py
  • tests/parser/test_openapi.py
  • tests/test_input_model.py
  • tox.ini
💤 Files with no reviewable changes (4)
  • .github/workflows/test.yaml
  • tox.ini
  • tests/test_input_model.py
  • pyproject.toml

Comment thread src/datamodel_code_generator/__main__.py
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)
src/datamodel_code_generator/__main__.py (1)

146-152: ⚠️ Potential issue | 🟡 Minor

__getitem__ should raise KeyError for missing keys.

At Line 152, __getitem__ forwards to getattr() via get(), so missing fields raise AttributeError instead of KeyError, which breaks mapping-like behavior.

Suggested fix
-    def __getitem__(self, item: str) -> Any:  # pragma: no cover
-        """Get item by key."""
-        return self.get(item)  # ty: ignore
+    def __getitem__(self, item: str) -> Any:  # pragma: no cover
+        """Get item by key."""
+        try:
+            return getattr(self, item)
+        except AttributeError as exc:
+            raise KeyError(item) from exc
🤖 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 146 - 152, The
__getitem__ currently delegates to get/getattr which causes AttributeError for
missing keys; change __getitem__(self, item: str) to attempt to return the
attribute (e.g., via getattr or calling get) but catch AttributeError (or check
with hasattr) and raise KeyError(item) instead (use "raise KeyError(item) from
None" if preserving exception chaining is desired); update the __getitem__
implementation in the class that defines get and __getitem__ accordingly so
mapping-like access raises KeyError for absent keys.
🧹 Nitpick comments (1)
tests/main/test_public_api_signature_baseline.py (1)

38-40: Consider removing PYDANTIC_V2_SKIP and related decorators.

Since this PR removes Pydantic v1 support, the PYDANTIC_V2_SKIP marker and is_pydantic_v2 import become effectively dead code—is_pydantic_v2() will always return True. The tests decorated with @PYDANTIC_V2_SKIP (lines 577, 588, 602, 613, 624, 638, 652, 669, 689, 706) will never be skipped.

Consider removing these decorators and the import for consistency with the unconditional execution in test_generate_signature_matches_baseline and test_parser_signature_matches_baseline.

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

In `@tests/main/test_public_api_signature_baseline.py` around lines 38 - 40,
Remove the now-dead Pydantic v2 skip machinery: delete the import
"is_pydantic_v2" and the PYDANTIC_V2_SKIP assignment, and remove all usages of
the `@PYDANTIC_V2_SKIP` decorator from the tests (including the decorators applied
near test_generate_signature_matches_baseline and
test_parser_signature_matches_baseline); this cleans up the unused symbol
PYDANTIC_V2_SKIP and the never-false is_pydantic_v2() check.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@src/datamodel_code_generator/__main__.py`:
- Around line 146-152: The __getitem__ currently delegates to get/getattr which
causes AttributeError for missing keys; change __getitem__(self, item: str) to
attempt to return the attribute (e.g., via getattr or calling get) but catch
AttributeError (or check with hasattr) and raise KeyError(item) instead (use
"raise KeyError(item) from None" if preserving exception chaining is desired);
update the __getitem__ implementation in the class that defines get and
__getitem__ accordingly so mapping-like access raises KeyError for absent keys.

---

Nitpick comments:
In `@tests/main/test_public_api_signature_baseline.py`:
- Around line 38-40: Remove the now-dead Pydantic v2 skip machinery: delete the
import "is_pydantic_v2" and the PYDANTIC_V2_SKIP assignment, and remove all
usages of the `@PYDANTIC_V2_SKIP` decorator from the tests (including the
decorators applied near test_generate_signature_matches_baseline and
test_parser_signature_matches_baseline); this cleans up the unused symbol
PYDANTIC_V2_SKIP and the never-false is_pydantic_v2() check.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: afc57a34-9af2-4afd-86ca-185f936edf66

📥 Commits

Reviewing files that changed from the base of the PR and between c0d64cb and d8811eb.

📒 Files selected for processing (3)
  • src/datamodel_code_generator/__main__.py
  • tests/main/jsonschema/test_main_jsonschema.py
  • tests/main/test_public_api_signature_baseline.py
💤 Files with no reviewable changes (1)
  • tests/main/jsonschema/test_main_jsonschema.py

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)
src/datamodel_code_generator/__main__.py (1)

146-152: ⚠️ Potential issue | 🟡 Minor

Config.__getitem__ should raise KeyError for missing keys.

The __getitem__ method delegates to get(), which uses getattr(). For missing attributes, this raises AttributeError instead of KeyError, breaking standard mapping semantics.

Suggested fix
-    def get(self, item: str) -> Any:
+    def get(self, item: str, default: Any = None) -> Any:
         """Get attribute value by name."""
-        return getattr(self, item)
+        return getattr(self, item, default)

     def __getitem__(self, item: str) -> Any:
         """Get item by key."""
-        return self.get(item)  # ty: ignore
+        try:
+            return getattr(self, item)
+        except AttributeError as exc:
+            raise KeyError(item) from exc
🤖 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 146 - 152,
Config.__getitem__ currently delegates to get() which uses getattr() and lets
AttributeError bubble up; change __getitem__ to catch AttributeError (or check
existence with hasattr) and raise KeyError for missing keys so it follows
mapping semantics: inside Config.__getitem__ (and/or adjust Config.get signature
to accept a default), attempt to retrieve the attribute via getattr(self, item)
in a try/except and convert any AttributeError into KeyError(f"{item}") so
callers receive a KeyError for missing keys instead of AttributeError.
🧹 Nitpick comments (1)
src/datamodel_code_generator/__main__.py (1)

399-417: Consider moving the import outside the class.

Re-importing field_validator as _field_validator inside the class body (Line 399) is unusual. This could be moved to the module-level imports for consistency and clarity.

Suggested refactor

Move the import to line 49 with the other pydantic imports, and use field_validator directly:

-from pydantic import BaseModel, ConfigDict, ValidationError, field_validator, model_validator
+from pydantic import BaseModel, ConfigDict, ValidationError, field_validator, model_validator

# Inside Config class, remove:
-    from pydantic import field_validator as _field_validator  # noqa: PLC0415
-
-    `@_field_validator`("input_model", mode="before")
+    `@field_validator`("input_model", mode="before")
     `@classmethod`
     def coerce_input_model_to_list(cls, v: str | list[str] | None) -> list[str] | None:
         ...

-    `@_field_validator`("class_name_affix_scope", mode="before")
+    `@field_validator`("class_name_affix_scope", mode="before")
     `@classmethod`
     def validate_class_name_affix_scope(cls, v: str | ClassNameAffixScope | None) -> ClassNameAffixScope:
         ...
🤖 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 399 - 417, Move the
local import "from pydantic import field_validator as _field_validator" out of
the class body and into the module-level imports (alongside other pydantic
imports) and use the canonical name "field_validator" in the decorators; update
the decorators on the methods coerce_input_model_to_list and
validate_class_name_affix_scope to use `@field_validator`(...) instead of
`@_field_validator`, removing the in-class import and keeping the methods'
signatures and behavior unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@src/datamodel_code_generator/__main__.py`:
- Around line 146-152: Config.__getitem__ currently delegates to get() which
uses getattr() and lets AttributeError bubble up; change __getitem__ to catch
AttributeError (or check existence with hasattr) and raise KeyError for missing
keys so it follows mapping semantics: inside Config.__getitem__ (and/or adjust
Config.get signature to accept a default), attempt to retrieve the attribute via
getattr(self, item) in a try/except and convert any AttributeError into
KeyError(f"{item}") so callers receive a KeyError for missing keys instead of
AttributeError.

---

Nitpick comments:
In `@src/datamodel_code_generator/__main__.py`:
- Around line 399-417: Move the local import "from pydantic import
field_validator as _field_validator" out of the class body and into the
module-level imports (alongside other pydantic imports) and use the canonical
name "field_validator" in the decorators; update the decorators on the methods
coerce_input_model_to_list and validate_class_name_affix_scope to use
`@field_validator`(...) instead of `@_field_validator`, removing the in-class import
and keeping the methods' signatures and behavior unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 248b2227-1064-44f4-bcea-288522eb2caa

📥 Commits

Reviewing files that changed from the base of the PR and between d8811eb and 53b984c.

📒 Files selected for processing (6)
  • src/datamodel_code_generator/__main__.py
  • src/datamodel_code_generator/model/base.py
  • src/datamodel_code_generator/parser/jsonschema.py
  • src/datamodel_code_generator/parser/openapi.py
  • src/datamodel_code_generator/reference.py
  • src/datamodel_code_generator/types.py

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: 2

♻️ Duplicate comments (1)
src/datamodel_code_generator/__main__.py (1)

146-152: ⚠️ Potential issue | 🟡 Minor

Config.__getitem__ still leaks AttributeError for missing keys.

That breaks normal mapping semantics for callers expecting KeyError on absent entries.

Suggested fix
     def __getitem__(self, item: str) -> Any:  # pragma: no cover
         """Get item by key."""
-        return self.get(item)  # ty: ignore
+        try:
+            return getattr(self, item)
+        except AttributeError as exc:
+            raise KeyError(item) from exc
🤖 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 146 - 152, The
Config.__getitem__ currently forwards to get which uses getattr and therefore
propagates AttributeError for missing attributes; change this so missing keys
raise KeyError like a mapping: modify either Config.get or Config.__getitem__
(referencing method names get and __getitem__ on class Config) to detect a
missing attribute (use getattr with a sentinel/default or catch AttributeError)
and raise KeyError(item) instead of letting AttributeError bubble up.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/datamodel_code_generator/reference.py`:
- Around line 96-113: The dict() wrapper currently coerces exclude into a set
which destroys nested mappings; update dict() (the method calling
self.model_dump) to preserve mapping form: detect if the incoming exclude is a
Mapping and if so merge it with self._exclude_fields by copying the mapping and
adding any names from self._exclude_fields as keys with a True value (so
top-level excluded names remain excluded) then pass that merged mapping to
model_dump; if exclude is not a Mapping, keep the existing behavior of unioning
set(exclude or ()) with self._exclude_fields and pass that set to model_dump.

---

Duplicate comments:
In `@src/datamodel_code_generator/__main__.py`:
- Around line 146-152: The Config.__getitem__ currently forwards to get which
uses getattr and therefore propagates AttributeError for missing attributes;
change this so missing keys raise KeyError like a mapping: modify either
Config.get or Config.__getitem__ (referencing method names get and __getitem__
on class Config) to detect a missing attribute (use getattr with a
sentinel/default or catch AttributeError) and raise KeyError(item) instead of
letting AttributeError bubble up.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 285d801f-b49d-47ee-8745-61c02f41ea75

📥 Commits

Reviewing files that changed from the base of the PR and between 53b984c and cd79158.

📒 Files selected for processing (3)
  • src/datamodel_code_generator/__main__.py
  • src/datamodel_code_generator/reference.py
  • src/datamodel_code_generator/types.py

Comment thread src/datamodel_code_generator/__main__.py
Comment thread src/datamodel_code_generator/reference.py
@koxudaxi koxudaxi merged commit b868fa8 into main Mar 6, 2026
37 checks passed
@koxudaxi koxudaxi deleted the pr2a-remove-v1-compat branch March 6, 2026 01:12
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 6, 2026

Breaking Change Analysis

Result: Breaking changes detected

Reasoning: This PR removes the Pydantic v1 runtime compatibility layer entirely. Key changes include: (1) Removal of is_pydantic_v2() conditional branches throughout the codebase, (2) Removal of the py312-pydantic1 CI test matrix, (3) Removal of the deprecation warning for Pydantic v1 runtime support, (4) Direct use of Pydantic v2 APIs like model_dump(), model_validate(), ConfigDict, model_fields, and RootModel without fallbacks, (5) Removal of v1-specific tests and error messages for v1 runtime scenarios. The generated code output remains unchanged - this PR only affects the runtime dependency requirements. Users who had Pydantic v1 installed will encounter import/runtime errors and must upgrade to Pydantic v2.

Content for Release Notes

Dependency Changes

  • Pydantic v1 runtime support removed - Pydantic v2 is now required as a runtime dependency. Users running datamodel-code-generator with Pydantic v1 installed must upgrade to Pydantic v2. The previously deprecated v1 compatibility layer has been completely removed. (Remove pydantic v1 runtime compat layer #3025)

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