Skip to content

Suggestion: New lint to forbid except BaseException: #174

@untitaker

Description

@untitaker

This goes further than the existing lint against except:. The rationale is that in many codebases (celery task bodies and request handlers, in our case) it's extremely unlikely that except BaseException: is ever a valid way to handle errors. In our org we've seen people (usually ones who are not writing Python daily) introduce except BaseException: as per a suggestion from the lint against except: without diving deeper into the topic, and causing all kinds of problems. With such a new lint forbidding BaseException as well they'd be forced to think more about what exceptions they really want to handle, and hopefully they'll reconsider when writing except (Exception, SystemExit, KeyboardInterrupt, ...).

If y'all would accept such an opt-in lint I'll start working on it immediately.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions