Skip to content

Find the opening bracket from the line end in the builtin line split - #6699

Merged
Koudai Aono (koxudaxi) merged 1 commit into
bspeed-markfrom
bspeed-reverse
Nov 11, 2026
Merged

Koudai Aono (koxudaxi) merged 1 commit into
bspeed-markfrom
bspeed-reverse

Conversation

@koxudaxi

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

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • Performance
    • Improved processing speed for long lines in certain parsing scenarios.

@coderabbitai

coderabbitai Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

_is_one_sequence_between now searches backward through leaves to locate the opening bracket. Its bracket validation, depth calculation, comma counting, and return condition are unchanged.

Changes: Sequence check

Layer / File(s) Summary
Opening-bracket lookup
src/datamodel_code_generator/_builtin_line_split.py
_is_one_sequence_between now uses a reverse identity search to locate the opening bracket. The docstring records the lookup assumption and the prior search’s cost on long lines.

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

Change: Refactor

Suggested labels: breaking-change-analyzed

Merge Risk: Minimal · up to cfe31

The sequence check now searches backward for opening brackets. No actionable regression was established; normal checks remain appropriate before merging.

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 describes the main change: finding the opening bracket by searching backward from the line end.
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: 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 1 functions across 1 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.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 405f60c and cfe314f.

Files selected for processing: 1

  • src/datamodel_code_generator/_builtin_line_split.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.

@koxudaxi
Koudai Aono (koxudaxi) marked this pull request as ready for review November 10, 2026 20:25
@chatgpt-codex-connector

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

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-10T20:26:28.278706Z cfe314f 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

Copy link
Copy Markdown
Contributor

@codspeed

codspeed Bot commented Nov 10, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 97.02%

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

⚠️ 53 benchmarks with a significant change ran on different hardware

Their base and head results were measured on machines with a different CPU, core count or memory, so the changes might not come from the code. Run base and head on the same runner type.

Learn more about Macro Runners

See affected benchmarks

⚡ 53 improved benchmarks
⏩ 98 skipped benchmarks1

Performance Changes

Benchmark BASE HEAD Efficiency
⚡ test_perf_target_render[client-small] 62.5 ms 20.6 ms ×3
⚡ test_perf_target_render[fastapi-small] 34.4 ms 14.7 ms ×2.3
⚡ test_perf_client_calls[sync] 43.5 ms 19.1 ms ×2.3
⚡ test_perf_client_calls[async] 48.7 ms 21.7 ms ×2.2
⚡ test_perf_simple_msgspec_unset_field_rendering 596.1 ms 269.6 ms ×2.2
⚡ test_perf_pydantic_field_name_resolution 2.7 ms 1.3 ms ×2.2
⚡ test_perf_load_pyproject_config[config-multiple] 264.1 µs 121.3 µs ×2.2
⚡ test_perf_duplicate_names 1,194.5 ms 551 ms ×2.2
⚡ test_perf_load_pyproject_config[mapping-multiple] 265.4 µs 123.1 µs ×2.2
⚡ test_perf_load_pyproject_config[config-None] 240 µs 111.5 µs ×2.2
⚡ test_perf_load_pyproject_config[mapping-None] 247.2 µs 115.1 µs ×2.1
⚡ test_perf_large_models_typed_dict[total-false-requiredness] 1,385.7 ms 646.4 ms ×2.1
⚡ test_perf_large_models_dataclass_builtin 1,656 ms 773.2 ms ×2.1
⚡ test_perf_simple_pydantic_v2_field_construction 12.4 ms 5.9 ms ×2.1
⚡ test_perf_large_models_pydantic_v2 4.2 s 2 s ×2.1
⚡ test_perf_large_models_typed_dict[legacy-requiredness] 1,382.6 ms 674.1 ms ×2.1
⚡ test_perf_large_models_msgspec 2.4 s 1.2 s ×2
⚡ test_perf_large_models_single_module_stdout 2 s 1 s ×2
⚡ test_perf_complex_refs 2.5 s 1.3 s +99.87%
⚡ test_perf_extreme_large_schema 17.3 s 8.7 s +99.87%
... ... ... ... ...

ℹ️ 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 bspeed-reverse (cfe314f) with main (f478c79)2

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

  2. No successful run was found on bspeed-mark (405f60c) during the generation of this report, so main (f478c79) was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@codecov

codecov Bot commented Nov 10, 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 8920482 into main Nov 11, 2026
117 checks passed
@koxudaxi
Koudai Aono (koxudaxi) deleted the bspeed-reverse branch November 11, 2026 06:52
@github-actions

Copy link
Copy Markdown
Contributor

Breaking Change Analysis

Result: No breaking changes detected

Reasoning: The PR only changes the private helper _is_one_sequence_between in the internal module _builtin_line_split.py so that it finds the opening bracket leaf by searching from the end of the leaves list instead of from the start, and adds a docstring. The lookup uses identity comparison and each leaf object appears once in a line, so the index found is the same and only performance on long lines improves. No public API, CLI option, template, default value, Python version support or error handling changes. The behaviour diff gate lists only both-fail cells, with no accepted or violation cells, so the default generated output is unchanged.


This analysis was produced by the release draft workflow

@github-actions

Copy link
Copy Markdown
Contributor

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