Clarify R503 terminal-return scope (#197) - #215
Conversation
Scope R503 to functions that return a value along another path. Align R502 with R501 by using a bare `return` for the explicit `None` result while leaving all-`None` procedures free to return implicitly.
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🔗 Linked repositories identifiedCodeRabbit considers these linked repositories for cross-repo context during reviews:
Summary
Validation
WalkthroughUpdate ChangesR503 guidance
Possibly related issues
Possibly related PRs
Suggested labels: Poem
🚥 Pre-merge checks | ✅ 20✅ Passed checks (20 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideClarifies Python return rules R502 and R503 to distinguish when explicit terminal returns are required, aligning them with R501 and exempting functions that can only return None. File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f14723f800
ℹ️ 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".
| Ensure all branches return explicitly if any branch returns a value. Use a bare | ||
| `return` when the other result is `None`, as required by R501. |
There was a problem hiding this comment.
Replace bare returns in mixed-value examples
When one branch returns x, a bare return is precisely what RET502 rejects: running ruff check --isolated --select RET501,RET502,RET503 on this example reports “RET502 Do not implicitly return None in function able to return non-None value.” R501 only removes explicit None when None is the function's only possible result, so both new “GOOD” examples fail the configured RET lint; use return None or another explicit value instead.
AGENTS.md reference: AGENTS.md:L199-L200
Useful? React with 👍 / 👎.
Summary
This branch clarifies the Python return guidance so R503 requires an explicit terminal return only when another control-flow path returns a value. It aligns R502 and R503 with R501 by using a bare
returnfor an explicitNoneresult, while allowing procedures whose only possible result isNoneto return implicitly.Closes #197.
Review walkthrough
.rules/python-return.mdfor the aligned R502 example, the narrowed R503 heading and explanation, and the explicit exemption for all-Noneprocedures.Validation
make fmt: passed; unrelated formatter churn was removed.make markdownlint: passed, including.rules/python-return.md.make nixie: passed.git diff --check: passed.coderabbit review --agent: completed with zero findings.References
Summary by Sourcery
Documentation: