Repository navigation
Share the option spelling, the argparse index and the preset application of the CLI, the recommender, the prompt and generate() - #5566
Conversation
…the external-ref-mapping split between the CLI, the recommender and generate()
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Shared option and value helpers src/datamodel_code_generator/_option_names.py, src/datamodel_code_generator/cli_options.py, src/datamodel_code_generator/_recommend/_rules.py, src/datamodel_code_generator/prompt.py, scripts/recommender_calibrate.py |
Added helpers for option names, hyphenated configuration keys, TOML-style values, and external-reference mappings. Added parser-action lookup for negative boolean options. Recommendation rules and prompt formatting now use shared helpers. |
Centralized preset resolution src/datamodel_code_generator/preset.py, src/datamodel_code_generator/__init__.py, src/datamodel_code_generator/__main__.py, src/datamodel_code_generator/_api_generation.py, src/datamodel_code_generator/_recommend/* |
Added a resolver that builds preset context from configuration and returns ordered updates. Configuration, API, CLI, and recommendation paths now apply those updates. |
CLI and configuration integration src/datamodel_code_generator/__main__.py, src/datamodel_code_generator/_recommend/_report.py, src/datamodel_code_generator/base_config.py, src/datamodel_code_generator/_cli_config.py, src/datamodel_code_generator/arguments.py, src/datamodel_code_generator/preset.py, src/datamodel_code_generator/_recommend/__init__.py |
CLI and reporting paths now use shared option names and configuration-key conversion. External-reference mapping validators use the shared parser and preserve their existing error types. |
Priority:
Estimated code review effort: 3 (Moderate) | ~20 minutes
Merge Risk: 
Minimal · up to b953c
-
The change centralizes option formatting, validation, and preset handling. No actionable merge-blocking issue was identified; merge after normal checks pass.
Pre-merge checks: 
5
-
Full details: Title check
-
Explanation
The title names the shared pieces this PR centralizes: option spelling, the argparse action index, and preset application across the CLI, recommender, prompt, and generate(). The raw summary confirms these changes. New _option_names.py helpers (option_flag, hyphenated, toml_value, split_external_ref_mapping) cover option spelling. _actions_by_dest and _negative_option cover the argparse index. _resolve_config_preset covers preset application. The title is long and uses internal jargon, but it describes the main change. It does not mention the external-reference-mapping split from the commit messages, which is a secondary point.
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 93.55% 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 31 functions across 14 files.
-
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 47.27%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 with no breaking changes. It adds a private helper module, _option_names, with option_flag, hyphenated, toml_value and split_external_ref_mapping. It also adds a private preset helper, _resolve_config_preset, and a ResolvedPresetConfig.updates method, then switches the duplicated call sites over to them. The only removed symbols are private or internal: _flag in base_config and in the recommend report module, toml_value and _option_strings in the private _recommend._rules module, and _negative_boolean_options in main. The prompt module's _actions_by_dest moved to cli_options and is still imported into prompt. The public resolve_preset_config_updates function, PresetContext and PresetError are unchanged. Preset application still applies the same values: the target Python version first, then preset items, then forced field constraints. The CLI and pyproject handling of --external-ref-mapping keeps the same messages and exception types (Error and ArgumentTypeError). Option spelling, including the --no- forms of boolean flags, is computed the same way. The PresetConfigItem pyproject_value result is the same for enum tuples. No CLI options, defaults, templates or supported Python versions change. The behaviour diff gate does list accepted cells, but their notes describe allOf schemas whose parts admit no object now generating root models or aliases instead of empty object models, and they point to a different PR. This diff does not touch any parser or model-generation code, so those output changes cannot come from it; the remaining cells are both-fail or crash-fix, which do not change default output. 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