You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Spurious error on bare yield in a context manager under strict-optional #1958
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.
Activity
ddfisher commentedon Aug 4, 2016
This no longer appears to be a problem. I think this was fixed by #1980.
ambv commentedon Jun 14, 2017
This is fixed for the function syntax, e.g. this doesn't return an error:
However, this still does:
Error:
gvanrossum commentedon Jun 14, 2017
Can you open a new issue?
ambv commentedon Jun 14, 2017
Will do.