Remove pydantic v1 runtime compat shims and update dependencies#3027
Remove pydantic v1 runtime compat shims and update dependencies#3027
Conversation
📝 WalkthroughWalkthroughThe PR removes Pydantic v1 compatibility and related runtime patches, updates dependencies to require Pydantic v2 with Python-version conditionals, and deletes a pydantic_patch module while simplifying util.py to always return a v2-style BaseModel (model_config strict=False). Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested labels
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 improve performance by 14.54%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ⚡ | WallTime | test_perf_large_models_pydantic_v2 |
3.7 s | 3.2 s | +14.41% |
| ⚡ | WallTime | test_perf_multiple_files_input |
3.7 s | 3.2 s | +14.54% |
| ⚡ | WallTime | test_perf_stripe_style_pydantic_v2 |
2 s | 1.8 s | +11.25% |
| ⚡ | WallTime | test_perf_complex_refs |
2.2 s | 1.9 s | +14.05% |
| ⚡ | WallTime | test_perf_openapi_large |
3.1 s | 2.7 s | +13.45% |
| ⚡ | WallTime | test_perf_graphql_style_pydantic_v2 |
822.2 ms | 731.1 ms | +12.46% |
| ⚡ | WallTime | test_perf_aws_style_openapi_pydantic_v2 |
2 s | 1.7 s | +14.14% |
| ⚡ | WallTime | test_perf_kubernetes_style_pydantic_v2 |
2.6 s | 2.3 s | +13.48% |
| ⚡ | WallTime | test_perf_duplicate_names |
1,069.5 ms | 934.4 ms | +14.45% |
| ⚡ | WallTime | test_perf_all_options_enabled |
6.7 s | 6.1 s | +10.2% |
| ⚡ | WallTime | test_perf_deep_nested |
6.1 s | 5.4 s | +12.59% |
Comparing pr3-remove-compat-shims (983b94c) with main (bef3fe5)
Footnotes
-
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. ↩
ca48ae2 to
9859ea5
Compare
a8caef4 to
1209712
Compare
9859ea5 to
ad5f527
Compare
1209712 to
da7debb
Compare
ad5f527 to
806a780
Compare
da7debb to
1198ce6
Compare
806a780 to
6862599
Compare
1198ce6 to
da29b4f
Compare
6862599 to
4f3713e
Compare
5ec568d to
8560324
Compare
8560324 to
3953c40
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3027 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 86 85 -1
Lines 17710 17684 -26
Branches 2069 2068 -1
=========================================
- Hits 17710 17684 -26
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: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@pyproject.toml`:
- Line 38: Update the pydantic dependency constraint in pyproject.toml from
"pydantic>=2" to "pydantic>=2.12,<3" so the project requires the first release
with Python 3.14 support and prevents accidental major-version upgrades; locate
the dependency entry for "pydantic" and replace its version specifier
accordingly.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 8d058047-e493-4ccf-9753-6610da280699
⛔ Files ignored due to path filters (1)
uv.lockis excluded by!**/*.lock,!**/*.lockand included by none
📒 Files selected for processing (3)
pyproject.tomlsrc/datamodel_code_generator/pydantic_patch.pysrc/datamodel_code_generator/util.py
💤 Files with no reviewable changes (1)
- src/datamodel_code_generator/pydantic_patch.py
There was a problem hiding this comment.
🧹 Nitpick comments (1)
pyproject.toml (1)
31-42: Addpackagingto test dependencies explicitly.Six test files import
packaging.versiondirectly, butpyproject.tomldoes not declarepackagingas an explicit dependency. This makes tests reliant on transitive dependencies fromblack,isort, and other packages, which is fragile. Addpackagingto[dependency-groups] test.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@pyproject.toml` around lines 31 - 42, The test suite relies on the packaging library transitively; update the pyproject.toml test dependency group by adding an explicit entry for packaging (for example "packaging>=23.0,<26" or your chosen semver) under [dependency-groups] test so tests import packaging.version directly without relying on transitive deps from black/isort; locate the test group in pyproject.toml and append the packaging string to the list of test dependencies.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@pyproject.toml`:
- Around line 31-42: The test suite relies on the packaging library
transitively; update the pyproject.toml test dependency group by adding an
explicit entry for packaging (for example "packaging>=23.0,<26" or your chosen
semver) under [dependency-groups] test so tests import packaging.version
directly without relying on transitive deps from black/isort; locate the test
group in pyproject.toml and append the packaging string to the list of test
dependencies.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: ab7c5d56-293c-4f02-be54-e28dd773e7a9
⛔ Files ignored due to path filters (1)
uv.lockis excluded by!**/*.lock,!**/*.lockand included by none
📒 Files selected for processing (1)
pyproject.toml
Breaking Change AnalysisResult: Breaking changes detected Reasoning: This PR removes pydantic v1 runtime compatibility shims and updates the dependency to require pydantic>=2. The main breaking changes are: (1) Users must have pydantic v2 installed - pydantic v1 is no longer supported at runtime; (2) Internal compatibility utilities like is_pydantic_v2(), model_validator(), field_validator(), and ConfigDict were removed from util.py; (3) The pydantic_patch.py module was deleted; (4) The packaging dependency was removed. These are API changes affecting users who either have pydantic v1 installed or import internal utilities directly. Content for Release NotesAPI/CLI Changes
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 by CodeRabbit
packagingdependency.