Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TRY201 wrongly complains about raising from None #2814

Closed
adamtheturtle opened this issue Feb 12, 2023 · 0 comments · Fixed by #2816
Closed

TRY201 wrongly complains about raising from None #2814

adamtheturtle opened this issue Feb 12, 2023 · 0 comments · Fixed by #2816
Labels
bug Something isn't working

Comments

@adamtheturtle
Copy link

Take the following example:

try:
    raise Exception("We want to hide this error message")
except Exception:
    try:
        raise Exception("We want to show this")
    except Exception as exc:
        raise exc from None

ruff with TRY201 selected tells us:

TRY201 Use `raise` without specifying exception name

However, we cannot do raise from None.

See https://peps.python.org/pep-0409/#proposal for context of this syntax.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants