Skip to content

[flake8-bugbear] Make B014 example error out-of-the-box - #29941

Merged
ntBre merged 2 commits into
astral-sh:mainfrom
adarrevah:b014-known-problems
Nov 3, 2026
Merged

ntBre merged 2 commits into
astral-sh:mainfrom
adarrevah:b014-known-problems

Conversation

@adarrevah

@adarrevah adarrevah commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

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 B014 on the old example and it passed, and on the new example B014 was flagged.

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)`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@ntBre ntBre added the documentation Improvements or additions to public-facing documentation label Nov 3, 2026

@ntBre ntBre left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@ntBre
ntBre enabled auto-merge (squash) November 3, 2026 15:33
@ntBre
ntBre merged commit d716850 into astral-sh:main Nov 3, 2026
53 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to public-facing documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants