Skip to content

Read the line endings of a text as universal newlines, list the config fields that hold paths and the JSON fields of a target in one place each - #5904

Merged
Koudai Aono (koxudaxi) merged 2 commits into
next9-3from
next9-4
Nov 1, 2026
Merged

Koudai Aono (koxudaxi) merged 2 commits into
next9-3from
next9-4

Conversation

@koxudaxi

@koxudaxi Koudai Aono (koxudaxi) commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • Bug Fixes
    • Improved consistency when processing Python text with different line endings, including when checking generated files and comparing output.
  • Refactor
    • Standardized how configuration paths and JSON options are handled across command-line, project configuration, generation, and watch workflows.
  • Documentation
    • Clarified how line-ending normalization and configuration fields are handled across the generation process.

@koxudaxi
Koudai Aono (koxudaxi) marked this pull request as ready for review November 1, 2026 06:23
@koxudaxi Koudai Aono (koxudaxi) changed the title next9 4 Read the line endings of a text as universal newlines, list the config fields that hold paths and the JSON fields of a target in one place each Nov 1, 2026
@coderabbitai

coderabbitai Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 24ac4a9 and 2eb14b3.

Files ignored due to path filters: 1
  • docs/llms-full.txt is excluded by none and included by none
Files selected for processing: 13
  • docs/architecture.md
  • src/datamodel_code_generator/__init__.py
  • src/datamodel_code_generator/__main__.py
  • src/datamodel_code_generator/_api_generation.py
  • src/datamodel_code_generator/_builtin_formatter.py
  • src/datamodel_code_generator/_cli_config.py
  • src/datamodel_code_generator/_config_fields.py
  • src/datamodel_code_generator/_project_config.py
  • src/datamodel_code_generator/_python_syntax.py
  • src/datamodel_code_generator/_source.py
  • src/datamodel_code_generator/base_config.py
  • src/datamodel_code_generator/parser/base.py
  • src/datamodel_code_generator/watch_dependencies.py

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review.

Walkthrough

The change adds shared newline normalization for Python text and output comparisons. It also centralizes configuration path, JSON, and target-selector field definitions, then uses those definitions across configuration loading, generation, and watch handling.

Changes: Python Text Newline Normalization

Layer / File(s) Summary
Define shared newline normalization
src/datamodel_code_generator/_python_syntax.py, docs/architecture.md
A shared helper converts CRLF and lone CR to LF. The architecture documentation describes the normalization and names its consumers.
Use newline normalization across text paths
src/datamodel_code_generator/parser/base.py, src/datamodel_code_generator/_source.py, src/datamodel_code_generator/__init__.py, src/datamodel_code_generator/_builtin_formatter.py, src/datamodel_code_generator/_api_generation.py, src/datamodel_code_generator/__main__.py
Source parsing, directory input checks, formatting, API generation, and output comparisons use the shared helper instead of local newline replacements.

Configuration Field Registry

Layer / File(s) Summary
Define shared configuration field groups
src/datamodel_code_generator/_config_fields.py, docs/architecture.md
The new registry defines path resolution and watch classifications, and derives path, JSON, and target-selector field groups. The architecture documentation describes these classifications.
Apply shared fields in configuration and target selection
src/datamodel_code_generator/_cli_config.py, src/datamodel_code_generator/_project_config.py, src/datamodel_code_generator/__main__.py, src/datamodel_code_generator/base_config.py
CLI path validation, pyproject path and JSON handling, JSON source tracking, and target selection now use field groups from the shared registry.
Use shared fields for generation and watch handling
src/datamodel_code_generator/__init__.py, src/datamodel_code_generator/__main__.py, src/datamodel_code_generator/watch_dependencies.py
Generation resolves caller-relative paths from the shared group. Watch dependency collection uses shared path and JSON groups to categorize configured dependencies.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Refactor

Merge Risk: Minimal · up to 2eb14

No actionable merge-blocking issue is established for the shared normalization and configuration-field changes. The change appears mergeable subject to normal checks.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and accurately summarizes both primary changes: universal newline handling and centralized configuration-field definitions.
Docstring Coverage Passed Docstring coverage is 94.74% 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. Documentati…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 94.74% 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 19 functions across 12 files. (1 skipped: 1 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

Warning

Some tools did not complete. Review the errors below.

LanguageTool
docs/architecture.md

LanguageTool checks are incomplete because the per-file request limit of 5 was reached. Remaining text was skipped; findings from completed checks are retained.

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-01T06:24:18.133316Z 2eb14b3 Draft marked ready
ℹ️ About Codex in GitHub

Your 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.

@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

@codspeed

codspeed Bot commented Nov 1, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 13.19%

1 warning

⚠️ Walltime results may be unreliable

Some benchmarks used the Walltime instrument outside CodSpeed Macro Runners, which can make the results inconsistent.

Learn more about Macro Runners

See affected benchmarks

⚡ 3 improved benchmarks
✅ 49 untouched benchmarks
⏩ 98 skipped benchmarks1

Performance Changes

Benchmark BASE HEAD Efficiency
⚡ test_perf_inherited_required_fields[required-base-first] 418.8 ms 364 ms +15.06%
⚡ test_perf_inherited_required_fields[required-derived-first] 461.8 ms 403.5 ms +14.44%
⚡ test_perf_inherited_required_fields[partial-base-first] 633.8 ms 575.4 ms +10.15%

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing next9-4 (2eb14b3) with next9-3 (24ac4a9)

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. ↩

@codecov

codecov Bot commented Nov 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@koxudaxi
Koudai Aono (koxudaxi) merged commit ce7a24f into main Nov 1, 2026
164 checks passed
@koxudaxi
Koudai Aono (koxudaxi) deleted the next9-4 branch November 1, 2026 11:47
@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Breaking Change Analysis

Result: No breaking changes detected

Reasoning: This PR is an internal refactor. It adds a private _config_fields module that lists every path and JSON config field with the stages that read it. The CLI validator, generate() path resolution, the pyproject.toml relative-path join and the watch dependency collector now derive their field lists from that table, and each derived list matches the hard-coded list it replaces. It also adds a normalize_newlines helper in _python_syntax that turns CRLF and lone CR into LF, and the sites that used to do this inline now call it with the same result. The only semantic difference is that the check option now also turns a lone CR into LF, where the removed private _normalize_line_endings only handled CRLF; this only makes the comparison more forgiving and does not change generated code. Every removed name is underscore-private: _normalize_line_endings, _TARGET_SELECTORS, the _PYPROJECT field sets and the watch_dependencies field tuples. No public API, CLI option, template, default value, error message or Python version support changes. The behaviour diff gate shows accepted cells for allOf schemas that now generate root models or aliases instead of empty object models, but these compare against the last release and their notes credit a different change; nothing in this diff touches allOf parsing or model generation. The remaining cells are both-fail or crash-fix.


This analysis was produced by the release draft workflow

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

🎉 Released in 0.88.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