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
and while this does run, it doesn't do what the programmer expects. Only the first iteration prints anything. The second iteration stops immediately because the generator is already exhausted.
This might be very difficult, but it would be nice if mypy could detect this.
The text was updated successfully, but these errors were encountered:
This just happened to me yesterday. Would be great to catch it.
However, I think this falls in the realm of unique types, which is about as advanced as type systems go. So I'm not sure mypy will ever land this...[1]
Mypy won't be able to catch all issues like these, but at least simple cases like the same generator being iterated twice in succession in a single scope would be possible to catch.
We might want to do this for all iterables, not just generators.
Somewhat related to #4707
This code currently does not give any warnings:
and while this does run, it doesn't do what the programmer expects. Only the first iteration prints anything. The second iteration stops immediately because the generator is already exhausted.
This might be very difficult, but it would be nice if mypy could detect this.
The text was updated successfully, but these errors were encountered: