Skip to content
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

Is there a way to raise PT011 for any exception types? #6473

Closed
harupy opened this issue Aug 10, 2023 Discussed in #6382 · 5 comments · Fixed by #6635
Closed

Is there a way to raise PT011 for any exception types? #6473

harupy opened this issue Aug 10, 2023 Discussed in #6382 · 5 comments · Fixed by #6635
Assignees
Labels
accepted Ready for implementation configuration Related to settings and configuration

Comments

@harupy
Copy link
Contributor

harupy commented Aug 10, 2023

Discussed in #6382

Originally posted by harupy August 7, 2023
I want to disallow calling pytest.raises without match regardless of the error type. Is there a way to achieve that? We could use raises-require-match-for and specify all error types in a codebase there:

[tool.ruff.flake8-pytest-style]
raises-require-match-for = ["ALL", "ERROR", "TYPES", "IN", "THIS", "REPO", "..."]

Is there an easier way?

@charliermarsh charliermarsh added the needs-decision Awaiting a decision from a maintainer label Aug 10, 2023
@harupy
Copy link
Contributor Author

harupy commented Aug 15, 2023

Ideas

  • Regular expression (e.g. [".*"])
  • Wildcard (e.g. ["requests.*"]).
  • Inroduce a special name (e.g., "ALL").
  • Treat an empty array as any error types.

@charliermarsh
Copy link
Member

We could probably support globbing... We already use globbing for some settings, like https://beta.ruff.rs/docs/settings/#isort-extra-standard-library.

@harupy
Copy link
Contributor Author

harupy commented Aug 15, 2023

Globbing sounds good :)

@zanieb zanieb added accepted Ready for implementation and removed needs-decision Awaiting a decision from a maintainer labels Aug 15, 2023
@charliermarsh charliermarsh added the configuration Related to settings and configuration label Aug 16, 2023
@harupy
Copy link
Contributor Author

harupy commented Aug 16, 2023

Can I implement this?

@charliermarsh
Copy link
Member

That'd be great, thanks.

charliermarsh pushed a commit that referenced this issue Aug 17, 2023
…ire_match_for` (#6635)

## Summary

<!-- What's the purpose of the change? What does it do, and why? -->

Support glob patterns for `raises_require_match_for` and
`raises_require_match_for`. Resolve #6473

## Test Plan

New tests + existing tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted Ready for implementation configuration Related to settings and configuration
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants