-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
ANN201 doesn't handle pytest.raises context manager #15975
Comments
Thanks for the report. The issue is really only about def test_exception():
with pytest.raises(ValueError):
raise ValueError("This is a test exception")
a = 1
assert a == 1 specifically that Ruff adds the return type Since it is hard for ruff to know if a context manager handles an exception (because it can't resolve the context manager nor its methods if defined in another file). We have to explore whether we can provide any type suggestion in that case (by handling a context manager similar to Relevant code: ruff/crates/ruff_python_semantic/src/analyze/terminal.rs Lines 42 to 150 in 13ffb5b
|
Description
ruff version: 0.9.4
code:
ruff check --select=ANN201 --diff --unsafe-fixes example.py
After applying the fix mypy reports the error:
The text was updated successfully, but these errors were encountered: