summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSylvain Th?nault <thenault@gmail.com>2014-02-24 09:52:55 +0100
committerSylvain Th?nault <thenault@gmail.com>2014-02-24 09:52:55 +0100
commitcf29c0681f42955ee423e3c4d910d64e9f11e538 (patch)
treefa42a9338f790b3b5c00bc75c457113e0c7c0739
parentfa4de8855ebfba07bfcef09f3d96a120e1bbd680 (diff)
parent5bb880a1db5b66b744de3bce035b7f7a514fc7ac (diff)
downloadpylint-cf29c0681f42955ee423e3c4d910d64e9f11e538.tar.gz
Merged in PCManticore/pylint (pull request #91)
Do not warn about returning values in generator for Python 3.3+.
-rw-r--r--ChangeLog4
-rw-r--r--checkers/base.py15
-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
diff --git a/ChangeLog b/ChangeLog
index 1095347..2b7bba1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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 f0087c3..11198ac 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 1a3cd5d..1a3cd5d 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 d81ce5c..d81ce5c 100644
--- a/test/messages/func_return_yield_mix.txt
+++ b/test/messages/func_return_yield_mix_py_33.txt