Skip to content

Add linting for exception chaining with raise-from #1765

Closed
@pseudo-rnd-thoughts

Description

@pseudo-rnd-thoughts

describe the request

It would be interesting to add a linting check for exception chaining, i.e., raising new exception with catch case using the raise from style

try:
   * code causes an exception * 
except Exception as e:
    raise TypeError("...") from e

Based on this blog post - https://blog.ram.rachum.com/post/621791438475296768/improving-python-exception-chaining-with

This rule has already been added to pylint, pylint-dev/pylint#3695
But the rule seems to be relevant to flake8 as well

I have looked through the issues and couldn't find a similar request, apologies if already requested.

@cool-RR is the blog posts original author

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions