Warn or autofix "return <Exception>"
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 49.7k
- Forks
- 2.4k
- Avg merge
- 2d 1h
- Merged PRs (30d)
- 458
Description
Summary
I spent an hour today debugging a test with pytest because I didn't realize that I had used return TypeError('blah') when I should have used raise TypeError('blah').
I'm not sure (but willing to be corrected) if there is a case where one would want to return the Exception instead of raise -ing the exception. If there is, then would be good to throw a warning.
If not, then would be better to autofix so that return becomes raise instead.
Closest existing issue I found was https://github.com/astral-sh/ruff/pull/21571 .
Looks like I'm using ruff 0.14.10. Happy to provide more info if helpful.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the linked Ruff pull request 21571 and the issue discussion to determine whether returning an Exception has valid use cases. Define whether the result should be a warning or autofix, and document the expected behavior and completion criteria before locating the relevant Ruff rule and tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, rust
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100