pylint #5977 yield != return [resolved]

skip wrote...

Pylint seems to treat yield statements as if they were returns. They definitely seem to be counted the same and the error message emitted with too many yields even calls them "returns": [R, yield_ex] Too many return statements (10/6)

Here's a trivial example cobbled together from an actual (slightly more complex) functio which generates a Python function from a higher level input:

def yield_ex(s):
    if s:
        yield "    line 1: %s\n" % s
        yield "    line 2\n"
        yield "    line 3\n"
        yield "    line 4\n"
        yield "    line 5\n"
        yield "    line 6\n"
        yield "    line 7\n"
        yield "    line 8\n"
        yield "    line 9\n"
        yield "    line 10\n"

I found it convenient to yield each line of the generated function. The code is hardly more complex than the above though there are some parameter substitutions on several lines. Having just two yield statements would have made it less obvious which values were being substituted where. (Though I will admit I could have used dict format expansion.)

At any rate, I don't think yield statements should be counted the same way returns are.

done in0.20.0
load left0.000
closed by<not specified>