Skip to content

E722 BaseException should also be considered as bare except #21518

@typenoob

Description

@typenoob

Summary

According to the document,

A bare except catches BaseException which includes KeyboardInterrupt, SystemExit, Exception, and others. Catching > BaseException can make it hard to interrupt the program (e.g., with Ctrl-C) and can disguise other problems.

A bare except is equal with catching BaseException explicitly.
Therefore we should report the following snippets as well.

try:
    pass
except BaseException:
    pass

Does it make sense?

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-decisionAwaiting a decision from a maintainerruleImplementing or modifying a lint rule

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions