Add new checks for except (...): clauses#105
Add new checks for except (...): clauses#105cooperlees merged 1 commit intoPyCQA:masterfrom Zac-HD:except-checks
except (...): clauses#105Conversation
| "statements can be moved outside the finally block." | ||
| ) | ||
| B013 = Error( | ||
| message="B013 A length-one tuple literal is redundant. " |
There was a problem hiding this comment.
Makes sense to me, but I've left it as "length-one tuple" to minimize the terminology that new programmers need to learn (right now to use the linter).
For example I have a tox config for formatters+linters that I encourage all my students to use when they're learning Python - in my experience automated feedback on what "good code" looks like can be really helpful, and the other bugbear messages are great at explaining why as well as what.
|
Turns out that this is useful for well-linted projects too:
|
|
Will merge and release tonight (US Pacific time) |
When using a tuple of exception types in an
exceptclause, it's easy for inexperienced Pythonistas to include elements that don't have any function at all. For example:This PR adds checks for all these cases, recommends the improved version (with
as-clause if applicable), and thus closes #98.CC @cooperlees