Skip to content

Docs: describe --keep-model-order as deterministic dependency-aware ordering#3090

Merged
koxudaxi merged 2 commits intomainfrom
docs/keep-model-order-accurate-description
Apr 16, 2026
Merged

Docs: describe --keep-model-order as deterministic dependency-aware ordering#3090
koxudaxi merged 2 commits intomainfrom
docs/keep-model-order-accurate-description

Conversation

@koxudaxi
Copy link
Copy Markdown
Owner

@koxudaxi koxudaxi commented Apr 16, 2026

Related issues: #3087

Summary by CodeRabbit

Release Notes

  • Documentation
    • Updated --keep-model-order CLI option documentation to provide clearer details on how the generator orders models—starting from class name order and repositioning only to satisfy dependency and runtime constraints. Clarified that this approach differs from raw schema preservation or unconditional alphabetical ordering, and ensures consistent ordering across repeated runs.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 16, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 62af25e1-9b9c-4f7d-ab96-bb9485137a88

📥 Commits

Reviewing files that changed from the base of the PR and between 3e87a9a and c8dceb7.

⛔ Files ignored due to path filters (1)
  • docs/llms-full.txt is excluded by none and included by none
📒 Files selected for processing (4)
  • docs/cli-reference/model-customization.md
  • docs/cli-reference/quick-reference.md
  • src/datamodel_code_generator/prompt_data.py
  • tests/main/jsonschema/test_main_jsonschema.py

📝 Walkthrough

Walkthrough

Documentation and CLI option descriptions for --keep-model-order were updated to clarify that the feature provides stable deterministic generation ordering respecting dependency constraints (base-before-subclass, cyclic groups together), rather than strictly preserving input schema order or enforcing unconditional alphabetical ordering.

Changes

Cohort / File(s) Summary
Documentation Pages
docs/cli-reference/model-customization.md, docs/cli-reference/quick-reference.md
Clarified --keep-model-order behavior to describe deterministic ordering that respects dependency constraints rather than raw schema order preservation.
CLI Option Descriptions
src/datamodel_code_generator/prompt_data.py
Updated the OPTION_DESCRIPTIONS string for --keep-model-order to reflect deterministic ordering with dependency awareness.
Test Documentation
tests/main/jsonschema/test_main_jsonschema.py
Updated docstring and CLI documentation text in tests for --keep-model-order, clarifying that it provides dependency-aware deterministic ordering, not schema-definition-order preservation or unconditional alphabetical ordering.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A flag's true colors now shine bright,
No more confusion—order's right!
Deterministic paths, constraints we meet,
Dependencies first, alphabets retreat! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: updating documentation to clarify that --keep-model-order provides deterministic, dependency-aware ordering rather than simple schema-order preservation.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch docs/keep-model-order-accurate-description

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 and usage tips.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 16, 2026

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 16, 2026

Merging this PR will improve performance by 12.44%

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

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

Performance Changes

Mode Benchmark BASE HEAD Efficiency
WallTime test_perf_graphql_style_pydantic_v2 825.8 ms 748.2 ms +10.37%
WallTime test_perf_large_models_pydantic_v2 3.7 s 3.3 s +10.72%
WallTime test_perf_openapi_large 2.9 s 2.6 s +12.44%
WallTime test_perf_aws_style_openapi_pydantic_v2 1.9 s 1.7 s +10.92%
WallTime test_perf_kubernetes_style_pydantic_v2 2.6 s 2.4 s +10.84%
WallTime test_perf_complex_refs 2.2 s 1.9 s +11.29%
WallTime test_perf_multiple_files_input 3.7 s 3.3 s +12.35%
WallTime test_perf_duplicate_names 1,061.4 ms 957.9 ms +10.81%

Comparing docs/keep-model-order-accurate-description (c8dceb7) with main (3e87a9a)

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
Copy link
Copy Markdown

codecov Bot commented Apr 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (3e87a9a) to head (c8dceb7).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #3090   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           87        87           
  Lines        18306     18306           
  Branches      2091      2091           
=========================================
  Hits         18306     18306           
Flag Coverage Δ
unittests 100.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@koxudaxi koxudaxi marked this pull request as draft April 16, 2026 16:37
@koxudaxi koxudaxi marked this pull request as ready for review April 16, 2026 16:59
@koxudaxi koxudaxi merged commit 6274b70 into main Apr 16, 2026
39 checks passed
@koxudaxi koxudaxi deleted the docs/keep-model-order-accurate-description branch April 16, 2026 16:59
@github-actions
Copy link
Copy Markdown
Contributor

Breaking Change Analysis

Result: No breaking changes detected

Reasoning: PR #3090 is documentation-only. It revises the description of the existing --keep-model-order CLI option to clarify that ordering starts from class name order and repositions only as needed for dependencies/runtime constraints. No code, CLI flags, defaults, generated output, templates, or APIs are modified, so there are no breaking changes.


This analysis was performed by Claude Code Action

@github-actions
Copy link
Copy Markdown
Contributor

🎉 Released in 0.56.1

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