redundant-tuple-in-exception-handler (B013) | 异常处理程序中多余的元组 (B013)
源自 flake8-bugbear linter。
修复总是可用的。
作用
Checks for single-element tuples in exception handlers (e.g., except (ValueError,):
). | 检查异常处理程序中包含单个元素的元组(例如,except (ValueError,):
)。
Note: Single-element tuples consisting of a starred expression are allowed. | 注意:允许包含星号表达式的单元素元组。
为什么这不好?
A tuple with a single element can be more concisely and idiomatically expressed as a single value. | 包含单个元素的元组可以用更简洁和地道的方式表示为单个值。
示例
建议改为