Repository navigation
Share the operation planning the client and the server compute the same way, with one policy row per difference - #5474
Conversation
…erations.py, with their differences as TargetPolicy rows
…the client and the server
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
| Layer / File(s) | Summary |
|---|---|
Shared operation contracts and utilities src/datamodel_code_generator/_target_operations.py, src/datamodel_code_generator/_target_naming.py, docs/architecture.md, scripts/check_architecture_boundaries.py, scripts/decision_homes.toml |
Adds shared planning helpers and target-specific policies. Updates the architecture documentation, boundary checker, and T-operation registry to identify the shared core and its adapters. |
Client planner adoption src/datamodel_code_generator/_client/plan.py, src/datamodel_code_generator/_client/caching.py, src/datamodel_code_generator/_client/fields.py, src/datamodel_code_generator/_client/pagination.py, src/datamodel_code_generator/_client/protocol_plan.py, src/datamodel_code_generator/_client/security.py, src/datamodel_code_generator/_client/target.py |
Client planning and supporting modules use shared operation labels, settings, naming, fact access, type-use lookup, aliases, and placeholder validation. |
FastAPI planner adoption src/datamodel_code_generator/_fastapi/plan.py, src/datamodel_code_generator/_fastapi/routes.py, src/datamodel_code_generator/_fastapi/render.py, src/datamodel_code_generator/_fastapi/target.py |
FastAPI planning and route code use shared operation helpers, server policies, naming, aliases, type-use lookup, and path-placeholder matching. |
Priority:
Estimated code review effort: 3 (Moderate) | ~25 minutes
Change: Refactor
Possibly related issues
- Issue 5421: The PR updates the architecture model to describe shared operation planning and policy rows, which relates to the issue’s concern about policy rows in the architecture documentation.
Possibly related PRs
- datamodel-code-generator/datamodel-code-generator#5429: This PR establishes the planned
T-operationhome that this PR assigns to_target_operations.py. - datamodel-code-generator/datamodel-code-generator#5430: Both PRs change the operation-settings flow; this PR centralizes selector resolution and operation metadata used by target planners.
- datamodel-code-generator/datamodel-code-generator#5422: Both PRs modify the
T-operationregistry and its architecture tracking.
Merge Risk: 
Minimal · previous review dc29e
-
The shared operation-planning changes have no identified merge-blocking issue. Merge after normal checks pass.
Pre-merge checks: 
5
-
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 93.33% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 60 functions across 14 files. (2 skipped: 2 unsupported.)
-
Finishing Touches
-
📝 Generate docstrings
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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 @coderabbitai help to get the list of available commands.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Merging this PR will degrade performance by 20.86%2 warnings
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing Footnotes
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Breaking Change AnalysisResult: No breaking changes detected Reasoning: This PR is an internal refactor that moves logic shared by the client and FastAPI targets into a new private module, _target_operations.py. The moved pieces are PlanError, fact, label, type_uses, first_use, local, declared_by, tags, group_tag, derived_name, type_names, argument_names, alias, resolve_settings, placeholder_problems, BODYLESS_STATUSES and LOCATIONS. Where the two targets behaved differently, each difference is kept as a row in a TargetPolicy for CLIENT and SERVER. Comparing the removed code with the new code line by line shows the same behaviour. The diagnostic codes, stages and messages are unchanged: the client still reports E_METADATA_REQUIRED for path placeholders and includes the operation label, while the server still reports F_ROUTE_INVALID without the label on the first message. The duplicate-setting errors keep their codes and wording (E_CONFIG_CONFLICT with Two settings name for the client, E_CONFIG_VALUE with The option setting names key twice for the server). The stage rules are the same, and the aliases-entry checks use the same source locations. Argument, operation and type naming calls the same claim logic with the same scopes. Only modules with an underscore prefix are touched, so no public Python API or CLI option changes. No templates, Python version support or defaults change either. The behaviour diff gate does list accepted output changes, but all of them are about allOf and JSON Schema intersection handling, which the notes credit to other work, and this PR does not touch the parser or model code. The rest of the diff only updates architecture docs, the decision-homes toml allowlist and the boundary-check script. This analysis was produced by the release draft workflow |
|
🎉 Released in 0.88.0 This PR is now available in the latest release. See the release notes for details. |
Summary by CodeRabbit