Skip to content

Spell the arguments of an option value in one place - #5590

Merged
Koudai Aono (koxudaxi) merged 1 commit into
mainfrom
impl-options
Oct 29, 2026
Merged

Koudai Aono (koxudaxi) merged 1 commit into
mainfrom
impl-options

Conversation

@koxudaxi

@koxudaxi Koudai Aono (koxudaxi) commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • Bug Fixes
    • Improved how CLI commands are generated from configuration values, including boolean options and lists of values. Options without a supported negative flag are now handled consistently.
    • Updated recommended commands to follow the same option-handling behavior as generated CLI commands.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 29, 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-10-29T20:12:32.354765Z eb5d5c9 PR opened
ℹ️ 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.

@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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 3f719a4 and eb5d5c9.

Files ignored due to path filters: 1
  • docs/llms-full.txt is excluded by none and included by none
Files selected for processing: 5
  • docs/architecture.md
  • scripts/decision_homes.toml
  • src/datamodel_code_generator/__main__.py
  • src/datamodel_code_generator/_option_names.py
  • src/datamodel_code_generator/_recommend/_rules.py

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

Walkthrough

The change adds option_arguments to centralize conversion of option values into command-line arguments. CLI generation and recommendation code now use it, and the architecture decision records describe the mapping and related sites.

Changes: Option Argument Mapping

Layer / File(s) Summary
Shared option argument mapping
src/datamodel_code_generator/_option_names.py
Adds option_arguments to map boolean values to positive or available negative flags, and other values to a positive flag followed by the value. Lists and tuples expand into separate arguments.
CLI and recommendation integration
src/datamodel_code_generator/__main__.py, src/datamodel_code_generator/_recommend/_rules.py, docs/architecture.md, scripts/decision_homes.toml
CLI generation and recommendation rules use option_arguments instead of local value-conversion logic. The architecture and decision-home entries record the mapping and related sites.

Priority: Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Refactor

Possibly related issues

Possibly related PRs

Merge Risk: Minimal · up to eb5d5

The change centralizes option argument generation without an established behavioral regression. It is 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 "Spell the arguments of an option value in one place" matches the main change. A new option_arguments function in _option_names.py now builds the CLI arguments for a field and value. The…
Docstring Coverage Passed Docstring coverage is 100.00% 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. Documentat…
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: Title check

Explanation

The title "Spell the arguments of an option value in one place" matches the main change. A new option_arguments function in _option_names.py now builds the CLI arguments for a field and value. The __main__.py and _recommend/_rules.py modules now delegate to it instead of building arguments inline. The title is specific, concise, and free of noise, so a teammate scanning history can tell what changed.

Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% 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 3 functions across 3 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

@codspeed

codspeed Bot commented Oct 29, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 26.37%

2 warnings

⚠️ 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

⚠️ Base and head ran on different runner types

Some benchmarks with significant performance changes were compared across different runner types, so the changes might not come from the code. Run base and head on the same runner type, or use CodSpeed Macro Runners for more stable results.

Learn more about Macro Runners

Open the report in CodSpeed to investigate

⚡ 51 improved benchmarks
✅ 1 untouched benchmark
⏩ 98 skipped benchmarks1

Performance Changes

Benchmark BASE HEAD Efficiency
⚡ test_perf_simple_msgspec_unset_field_rendering 464.9 ms 296.9 ms +56.57%
⚡ test_perf_client_calls[sync] 34.2 ms 23.9 ms +43.03%
⚡ test_perf_client_calls[async] 37.5 ms 26.6 ms +41.33%
⚡ test_perf_pydantic_field_name_resolution 2.1 ms 1.5 ms +36.64%
⚡ test_perf_large_models_dataclass_builtin 1,223.6 ms 895.6 ms +36.63%
⚡ test_perf_large_models_msgspec 1.8 s 1.3 s +35.56%
⚡ test_perf_large_models_pydantic_v2_builtin_double_quotes 1,193.8 ms 881.3 ms +35.46%
⚡ test_perf_scalar_root_collapsed_builtin 187.9 ms 138.9 ms +35.32%
⚡ test_perf_large_models_typed_dict[legacy-requiredness] 1,019.5 ms 754.2 ms +35.17%
⚡ test_perf_local_reference_file_resolution 117.8 ms 87.2 ms +35.14%
⚡ test_perf_large_models_pydantic_v2_builtin 1,136 ms 850.8 ms +33.52%
⚡ test_perf_large_models_typed_dict[total-false-requiredness] 1,027 ms 772 ms +33.02%
⚡ test_perf_large_models_single_module_stdout 1,318.6 ms 995.6 ms +32.45%
⚡ test_perf_load_yaml_openapi_large 36.7 ms 27.9 ms +31.94%
⚡ test_perf_openapi_large_pydantic_v2_builtin 1,158.2 ms 884 ms +31.02%
⚡ test_perf_large_models_pydantic_v2_noformat 1,139.9 ms 872.6 ms +30.63%
⚡ test_perf_load_pyproject_config[config-multiple] 299 µs 234.2 µs +27.66%
⚡ test_perf_false_reference_validation 244.6 ms 192.4 ms +27.12%
⚡ test_perf_ordinary_array_constraint_generation 1.7 s 1.4 s +26.61%
⚡ test_perf_unique_items_schema_validators 1.9 s 1.5 s +26.45%
... ... ... ... ...

ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.

Tip

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


Comparing impl-options (eb5d5c9) with main (3f719a4)

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 Oct 29, 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 ad62691 into main Oct 29, 2026
164 checks passed
@koxudaxi
Koudai Aono (koxudaxi) deleted the impl-options branch October 29, 2026 23:51
@github-actions

Copy link
Copy Markdown
Contributor

Breaking Change Analysis

Result: No breaking changes detected

Reasoning: The diff is an internal refactor that adds a private helper option_arguments in _option_names.py and routes generate_cli_command, _cli_arguments and the recommend rules option_arguments through it. The output stays the same for booleans (the negative option, or nothing when the parser defines none), lists, scalars and mappings. The only change is that tuples are now expanded like lists, and TOML config never yields tuples. Only docs and decision_homes.toml rows are otherwise added, and no public CLI option, API, template, default, Python version or error path is removed or changed. The accepted behaviour diff cells describe allOf schemas becoming root models, which comes from earlier parser changes since the last release that this diff does not touch, so they are not attributable to this PR.


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