Spurious error on bare yield
in a context manager under strict-optional
#1958
Labels
yield
in a context manager under strict-optional
#1958
Running
mypy --strict-optional
on the mypy codebase itself, we get this error:The function in question looks like this:
This is pretty sensible idiomatic code. Arguably there might be some other appropriate annotation to write for the return type; bracketing that question, it looks to be perfectly well-typed code that shouldn't produce an error. It's also not immediately clear to me how to work around it, except I guess with a
# type: ignore
.I suspect this is related to the complicated treatment we give in some places to None as a return type -- cf #1509, #299, #359 -- and that treating None in a more regular way as discussed in #1278 and #1847 would fix it.
It may also be related to #1933, but I haven't yet read through that discussion to understand what's going on there.
The text was updated successfully, but these errors were encountered: