Pull requests

#91 Merged
Repository
PCManticore
Branch
default
Repository
logilab
Branch
default

Do not warn about returning values in generator for Python 3.3+.

Author
  1. Claudiu Popa
Reviewers
Description

Here's a patch which disables the 'returning-arg-in-generator' warning for Python 3.3+, because it is valid syntax. The return value will be the argument to StopIteration and StopIteration will be raised when the return is encountered.

def gen(x):
   if x:
       return [1]
   for i in iter([10]):
       yield i

next(gen(1))   

Traceback (most recent call last):
  File "a.py", line 7, in <module>
    next(gen(1))
StopIteration: [1]
  • Learn about pull requests

Comments (0)