You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
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
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
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.
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.
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: 5
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title clearly and accurately summarizes both primary changes: universal newline handling and centralized configuration-field definitions.
Docstring Coverage
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
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
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.
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary by CodeRabbit