Repository navigation
Match CPython docstring indentation cleanup - #10161
Conversation
Expand tabs before stripping ASCII spaces, use only non-blank lines after the first to derive the common margin, and preserve other leading whitespace. Reuse the expanded string when it is already clean. Refs: RustPython#9852 Assisted-by: Codex:GPT-6.2
|
Caution Review failedThe pull request is closed.
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. |
Codex Review Summary: ✅ CompletedThis 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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 79b854f1bd
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let mut lines = doc.split('\n'); | ||
| let first_line = lines.next().unwrap_or_default(); | ||
|
|
||
| // Find the minimum indentation among non-blank lines after the first. |
There was a problem hiding this comment.
Preserve the still-valid indentation comments
The root AGENTS.md says “Do not delete or rewrite existing comments” unless they are factually wrong or contradict the new code. The removed explanation that a blank line contains only spaces (or is empty), along with the original first-pass and subsequent-line comments, remains accurate for this implementation. Preserve those comments instead of deleting or editorially rephrasing them as part of the indentation fix.
AGENTS.md reference: AGENTS.md:L99-L99
Useful? React with 👍 / 👎.
Match the indentation step in CPython 3.15.2's
_PyCompile_CleanDoc: after tab expansion, strip only ASCII spaces from the first line and remove a common ASCII-space margin from subsequent lines. Unlikeinspect.cleandoc, the compiler should leave non-ASCII whitespace and escaped carriage returns intact. Return the expanded string directly when there is no indentation to remove.The change covers module, function, and class docstrings from both source and Python AST input, at optimization levels 0–2. The comparison against CPython covers 360 observations; 120 mismatches before the patch, none after. UTF-8 errors for surrogate-bearing docstrings remain separate, and the Ruff pin and Lib are unchanged.
Linux: 800 codegen tests, codegen Clippy with warnings denied, git hooks, and the new compile snippet section passed. The selected standard suite passed on both runtimes (13 CPython; 10 RustPython plus 3 CPython-only skips). Six standard compiler docstring vectors were also exercised via compile. Full suites, other platforms and performance were not verified locally.
Refs #9852.