diff options
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | checkers/base.py | 15 | ||||
-rw-r--r-- | test/input/func_return_yield_mix_py_33.py (renamed from test/input/func_return_yield_mix.py) | 0 | ||||
-rw-r--r-- | test/messages/func_return_yield_mix_py_33.txt (renamed from test/messages/func_return_yield_mix.txt) | 0 |
4 files changed, 12 insertions, 7 deletions
@@ -25,7 +25,9 @@ ChangeLog for Pylint * Add a new warning 'abstract-class-instantiated' for checking that abstract classes created with `abc` module and - with abstract methods are instantied. + with abstract methods are instantied. + + * Do not warn about 'return-arg-in-generator' in Python 3.3+. 2013-12-22 -- 1.1.0 * Add new check for use of deprecated pragma directives "pylint:disable-msg" diff --git a/checkers/base.py b/checkers/base.py index f0087c3e9..11198acb0 100644 --- a/checkers/base.py +++ b/checkers/base.py @@ -52,6 +52,7 @@ NO_REQUIRED_DOC_RGX = re.compile('__.*__') REVERSED_METHODS = (('__getitem__', '__len__'), ('__reversed__', )) +PY33 = sys.version_info >= (3, 3) BAD_FUNCTIONS = ['map', 'filter', 'apply'] if sys.version_info < (3, 0): BAD_FUNCTIONS.append('input') @@ -241,7 +242,8 @@ class BasicErrorChecker(_BasicChecker): 'return-arg-in-generator', 'Used when a "return" statement with an argument is found ' 'outside in a generator function or method (e.g. with some ' - '"yield" statements).'), + '"yield" statements).', + {'maxversion': (3, 3)}), 'E0107': ("Use of the non-existent %s operator", 'nonexistent-operator', "Used when you attempt to use the C-style pre-increment or" @@ -292,11 +294,12 @@ class BasicErrorChecker(_BasicChecker): self.add_message('return-in-init', node=node) elif node.is_generator(): # make sure we don't mix non-None returns and yields - for retnode in returns: - if isinstance(retnode.value, astroid.Const) and \ - retnode.value.value is not None: - self.add_message('return-arg-in-generator', node=node, - line=retnode.fromlineno) + if not PY33: + for retnode in returns: + if isinstance(retnode.value, astroid.Const) and \ + retnode.value.value is not None: + self.add_message('return-arg-in-generator', node=node, + line=retnode.fromlineno) # Check for duplicate names args = set() for name in node.argnames(): diff --git a/test/input/func_return_yield_mix.py b/test/input/func_return_yield_mix_py_33.py index 1a3cd5d63..1a3cd5d63 100644 --- a/test/input/func_return_yield_mix.py +++ b/test/input/func_return_yield_mix_py_33.py diff --git a/test/messages/func_return_yield_mix.txt b/test/messages/func_return_yield_mix_py_33.txt index d81ce5cf4..d81ce5cf4 100644 --- a/test/messages/func_return_yield_mix.txt +++ b/test/messages/func_return_yield_mix_py_33.txt |