Open
Description
Background
There is a consistent pattern of using _cause
as the variable name when catching exceptions for chaining in the codebase, but this convention is not documented in the Exception Guide.
Proposed Change
Add the following section to the "Error Handling Practices" section of the Exception_Guide.md:
- **Exception Variable Naming**: When catching exceptions for re-raising or chaining, use `_cause` as the standard variable name. This follows PEP 8's convention for variables that might appear unused while clearly indicating the variable's purpose in exception chaining.
# Good practice
try:
some_operation()
except SomeError as _cause:
raise CustomError("Meaningful message") from _cause
Where
Motivation
Documenting this convention will:
- Promote consistency across the codebase
- Provide clear guidance for new contributors
- Make the reason for the naming convention explicit
Related to PR #385 discussion: #385 (comment)
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
To do