Repository navigation
Share the builtin formatter's block layouts, predicates and pyproject lookup, and define its constants once - #5519
Conversation
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Shared formatting defaults and configuration src/datamodel_code_generator/_format_types.py, src/datamodel_code_generator/_builtin_formatter.py, src/datamodel_code_generator/format.py, src/datamodel_code_generator/util.py, src/datamodel_code_generator/watch_dependencies.py, tests/test_format.py |
Formatting defaults and project-file lookup are shared across formatter and dependency-watcher code. Formatter configuration delegates line-length validation and tool-config loading to shared helpers. Tests check constant identity, validation, and missing configuration. |
Literal, call, and annotation layouts src/datamodel_code_generator/_builtin_formatter.py |
Shared helpers format literals, calls, unions, subscripts, and annotated expressions. Multiline expressions and line-length checks are handled in these formatting paths. |
Generated assignments, aliases, and class bases src/datamodel_code_generator/_builtin_formatter.py |
Annotation assignments, function signatures, type aliases, TypedDict calls, and supported RootModel bases use shared formatting helpers. |
Replacement collection and formatted output src/datamodel_code_generator/_builtin_formatter.py |
Import grouping, source-line replacements, top-level spacing, import/body joining, and identifier restoration use consolidated helpers. |
Priority:
Estimated code review effort: 4 (Complex) | ~45 minutes
Change: Refactor
Merge Risk: 
Minimal · up to 0b8ab
-
The formatter consolidation has no established merge-blocking regression. The lambda issue predates this change and is not worsened by it; merge after normal checks.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passedFull details: Docstring Coverage
-
Explanation
Docstring coverage is 26.32% which is insufficient. 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 57 functions across 6 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches: 💡 1
-
📝 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. |
… lookup, and define its constants once
13f578b to
0b8abf1
Compare
Merging this PR will degrade performance by 32.04%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 of the built-in formatter. It moves the shared formatting constants such as DEFAULT_LINE_LENGTH, DEFAULT_KNOWN_FIRST_PARTY and STRING_PREFIX_PATTERN into the private _format_types module. The public format module still exposes them under the same names and values. The pyproject.toml lookup moves into util._find_pyproject_toml, and the private builtin formatter and watch_dependencies modules import it under their old names. Repeated layout code is pulled into small helpers like _nested_lines, _item_lines, _block, _joined_block, _parenthesized, _is_bit_or, _is_multiline and _replacement. Line-length validation and tool-config loading are shared through _check_builtin_line_length and _load_builtin_tool_config, which keep the same error message and the same fallback to an empty tool config. The rewritten formatting functions produce the same line layouts, trailing commas and indentation as the code they replace, so the generated output should not change. No CLI options, public API, templates, supported Python versions or error behaviour are removed or changed. The only removal is LONG_TARGET_PREFIX_LENGTH from the private _builtin_formatter module, and it is still available from format and _format_types. The behaviour diff gate shows accepted cells, but these compare against the last release and describe allOf schemas turning from BaseModel into RootModel or alias output. That kind of change cannot come from a formatter refactor and does not appear anywhere in this diff, so it belongs to other changes since the release. The remaining cells are both-fail or crash-fix, which do not change default behaviour. 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