Repository navigation
[flake8-bugbear] Make B014 example error out-of-the-box - #29941
Merged
Merged
Conversation
ntBre
reviewed
Nov 3, 2026
Comment on lines
+71
to
+75
| /// unreachable. | ||
| /// | ||
| /// ## Known problems | ||
| /// This rule does not yet detect a parent exception listed together with one of | ||
| /// its children, such as `except (Exception, ValueError)`. |
Contributor
There was a problem hiding this comment.
I don't think I would make this change. It's true but isn't really the kind of thing we put in the rule documentation. It's tracked as an enhancement to the rule in #29073.
And the existing text about exception hierarchies is accurate whether the rule actually flags it or not.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Related to #29073
The example in the B014 docs is not flagged when you run ruff on it. The rule only checks for the same exception listed twice. This PR changes the example to
except (ValueError, ValueError).Test Plan
I ran
ruff check --select B014on the old example and it passed, and on the new example B014 was flagged.