Skip to content

[pylint] Extend PLW0133 to also detect user-defined exceptions #17347

@LoicRiegel

Description

@LoicRiegel

Summary

From the rule's documentation (PLW0133):

Known problems

This rule only detects built-in exceptions, like ValueError, and does not catch user-defined exceptions.

So currently this is caught:

def foo():
    ValueError("...")

But not this. But I would love if it would, it would have spared me 1hr of debugging this morning :)

class MyCustomError(Exception):
    ...

def foo():
    MyCustomError("...")

Metadata

Metadata

Assignees

No one assigned

    Labels

    ruleImplementing or modifying a lint ruletype-inferenceRequires more advanced type inference.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions