Skip to content

Enable Ruff flake8-blind-except (BLE) #13728

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

Avasam
Copy link
Collaborator

@Avasam Avasam commented Mar 27, 2025

Ref #13295
flake8-blind-except (BLE)

Contains a single rule: blind-except (BLE001)
I think it's worth making sure we explain when blindly catching any exception in a script/test.

The one time we currently do it seems to be acceptable as per the rule's description.

Copy link
Collaborator

@srittau srittau left a comment

Choose a reason for hiding this comment

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

Another of these "meh" rules. As the example here shows, it's often necessary to catch all "normal" exceptions, and it's – in my experience – a mistake only fresh or particularly uninterested developers make, and easily caught in code reviews (and a teaching opportunity). But I don't particularly care.

@Avasam
Copy link
Collaborator Author

Avasam commented Mar 28, 2025

I'm neutral on this as well. In personal projects I'd enable it just to force myself to comment why I'm blindly catching all exceptions.
But there's a concern an external/newer contributor may not understand that their blind expect usage is ok and they should ignore the rule rather than try and solve it.

Similar reasons to try-except-in-loop (PERF203): it's good to be aware, but maybe shouldn't be enforced by tooling.

@AlexWaygood
Copy link
Member

Yeah... I'd lean towards not enabling this one, since in some situations it will suggest something that's outright incorrect. But no strong opinion either.

@Avasam Avasam closed this Mar 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants