Skip to content

Detecting returning exception instead of raising #26456

Description

@ashrub-holvi

Summary

Hi,

cat tst.py 

def func ():
    return ValueError

running

ruff check --select=ALL tst.py

will warn only doctrings and type annotation, but the exception is returned, not raised, should be easy to detect standard exceptions, but for custom exceptions it's already more complicated, so, might ok to have it just for standard ones.
Of course, exception can be returned intentionally, but IMO it's much more rare case and it can be solved by noqa.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions