RE: https://hachyderm.io/@nedbat/116150179474021938

The answer to the mystery: because my function had a `yield` in it, it was compiled as a generator. But executing the function never ran `yield`, so iterating it produced an empty sequence. The value from the return statement is ignored.

TBH, I know there is a way to get the returned value, but I have never needed to, and I don't know how.

The solution was to delete the code after the return.

@nedbat you could also "yield from" instead of the "return" I think
@liskin I didn't want it to stay a generator at all, I was just quick-hacking some code to see if the new idea would work!
@nedbat fair enough

(I come from a strong typing background so naturally I started with the idea to keep the type - a generator - to avoid having to think about and potentially change every use site)
@liskin I never use `Generator[T]` for generators anyway, I use `Iterable[T]`, since that all that callers expect of it.
@nedbat so do I to be fair 😁
@nedbat What did you eventually change it to?
@3psboyd I just kept the return.
@nedbat I can’t reproduce it right now so maybe it doesn’t work this way any more, but I vaguely recall that the peephole optimizer (at least in some old version of python) could sometimes optimize out the generator-ness of a function, under a constant conditional, like an “if 0”, but not under some non-constant like “x = 0; if x:”. this confusion can get very intense:-)
@glyph AFAIK it always is and always has been that a yield in a function makes it a generator. In fact, I think the Python code Jinja(?) generates uses this fact by generating `if 0: yield None` sometimes for some reason?

@nedbat @glyph Yes, always is, always has been -- modulo bugs 😅

What Glyph is describing was a long standing and very confusing bug, where `if 0: yield` and similar constructs would get optimized away _before_ deciding the function was a generator.

@Yhg1s @nedbat yeah I should have probably said “the bug was fixed”, not “doesn’t work this way any more”; I didn’t intend to imply this behavior was intentional:)
@nedbat I’m actually surprised it’s not a syntax error to have code after a return!