Skip to content

[flake8-bugbear] Improve assert-raises-exception (B017) message#15389

Merged
MichaReiser merged 1 commit intoastral-sh:mainfrom
tjkuson:evil-begone
Jan 10, 2025
Merged

[flake8-bugbear] Improve assert-raises-exception (B017) message#15389
MichaReiser merged 1 commit intoastral-sh:mainfrom
tjkuson:evil-begone

Conversation

@tjkuson
Copy link
Copy Markdown
Contributor

@tjkuson tjkuson commented Jan 10, 2025

Summary

Changes the assert-raises-exception (B017) message to be more helpful. In doing so, the message is shorter and the implementation simpler as the diagnostic no longer needs to print the assertion.

- B017.py:45:10: B017 `pytest.raises(Exception)` should be considered evil
+ B017.py:45:10: B017 Do not assert blind exception: `Exception`

This assertion message is a corollary of blind-except (BLE001).

Do not catch blind exception: {name}

Test Plan

cargo nextest run

@github-actions
Copy link
Copy Markdown
Contributor

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@MichaReiser MichaReiser added the rule Implementing or modifying a lint rule label Jan 10, 2025
@MichaReiser
Copy link
Copy Markdown
Member

Thanks

@MichaReiser MichaReiser merged commit 23ad319 into astral-sh:main Jan 10, 2025
@tjkuson tjkuson deleted the evil-begone branch January 10, 2025 10:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rule Implementing or modifying a lint rule

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants