raise-within-try (TRY301)
Added in v0.0.233 · Related issues · View source
Derived from the tryceratops linter.
What it does
Checks for raise statements within try blocks. The only raises
caught are those that throw exceptions caught by the try statement itself.
Why is this bad?
Raising and catching exceptions within the same try block is redundant,
as the code can be refactored to avoid the try block entirely.
Alternatively, the raise can be moved within an inner function, making
the exception reusable across multiple call sites.
Example
Use instead: