summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--pylint/checkers/classes.py2
-rw-r--r--pylint/checkers/exceptions.py11
-rw-r--r--pylint/checkers/python3.py2
-rw-r--r--pylint/checkers/strings.py3
-rw-r--r--pylint/checkers/typecheck.py15
-rw-r--r--pylint/checkers/utils.py4
-rw-r--r--pylint/checkers/variables.py2
-rw-r--r--pylint/lint.py48
-rw-r--r--pylint/reporters/__init__.py3
-rw-r--r--pylint/test/functional/bad_builtin.py3
-rw-r--r--pylint/test/functional/bad_builtin.txt1
-rw-r--r--pylint/test/functional/bad_exception_context.py (renamed from pylint/test/input/func_bad_exception_context_py30.py)6
-rw-r--r--pylint/test/functional/bad_exception_context.rc2
-rw-r--r--pylint/test/functional/bad_exception_context.txt3
-rw-r--r--pylint/test/functional/bad_staticmethod_argument.py16
-rw-r--r--pylint/test/functional/bad_staticmethod_argument.txt2
-rw-r--r--pylint/test/functional/blacklisted_name.py4
-rw-r--r--pylint/test/functional/blacklisted_name.txt1
-rw-r--r--pylint/test/functional/dangerous_default_value.py (renamed from pylint/test/input/func_dangerous_default.py)33
-rw-r--r--pylint/test/functional/dangerous_default_value.rc2
-rw-r--r--pylint/test/functional/dangerous_default_value.txt14
-rw-r--r--pylint/test/functional/dangerous_default_value_py30.py79
-rw-r--r--pylint/test/functional/dangerous_default_value_py30.rc2
-rw-r--r--pylint/test/functional/dangerous_default_value_py30.txt14
-rw-r--r--pylint/test/functional/eval_used.py11
-rw-r--r--pylint/test/functional/eval_used.txt4
-rw-r--r--pylint/test/functional/fixme.py (renamed from pylint/test/input/func_fixme.py)11
-rw-r--r--pylint/test/functional/fixme.txt5
-rw-r--r--pylint/test/functional/function_redefined.py (renamed from pylint/test/input/func_w0102.py)10
-rw-r--r--pylint/test/functional/function_redefined.txt5
-rw-r--r--pylint/test/functional/interface_not_implemented.py (renamed from pylint/test/input/func_r0923.py)6
-rw-r--r--pylint/test/functional/interface_not_implemented.txt1
-rw-r--r--pylint/test/functional/invalid_name.py3
-rw-r--r--pylint/test/functional/invalid_name.txt1
-rw-r--r--pylint/test/functional/invalid_sequence_index.py (renamed from pylint/test/input/func_invalid_sequence_index.py)44
-rw-r--r--pylint/test/functional/invalid_sequence_index.txt20
-rw-r--r--pylint/test/functional/logging_format_interpolation.py (renamed from pylint/test/input/func_w1202.py)12
-rw-r--r--pylint/test/functional/logging_format_interpolation.txt4
-rw-r--r--pylint/test/functional/logging_not_lazy.py (renamed from pylint/test/input/func_w1201.py)12
-rw-r--r--pylint/test/functional/logging_not_lazy.txt3
-rw-r--r--pylint/test/functional/no_self_use.py (renamed from pylint/test/input/func_method_could_be_function.py)2
-rw-r--r--pylint/test/functional/no_self_use.txt1
-rw-r--r--pylint/test/functional/nonexistent_operator.py15
-rw-r--r--pylint/test/functional/nonexistent_operator.txt6
-rw-r--r--pylint/test/functional/not_context_manager.py14
-rw-r--r--pylint/test/functional/not_context_manager.txt1
-rw-r--r--pylint/test/functional/too_few_public_methods.py (renamed from pylint/test/input/func_r0903.py)11
-rw-r--r--pylint/test/functional/too_few_public_methods.txt1
-rw-r--r--pylint/test/functional/too_many_ancestors.py25
-rw-r--r--pylint/test/functional/too_many_ancestors.txt2
-rw-r--r--pylint/test/functional/too_many_arguments.py4
-rw-r--r--pylint/test/functional/too_many_arguments.txt1
-rw-r--r--pylint/test/functional/too_many_instance_attributes.py (renamed from pylint/test/input/func_r0902.py)8
-rw-r--r--pylint/test/functional/too_many_instance_attributes.txt1
-rw-r--r--pylint/test/functional/too_many_public_methods.py (renamed from pylint/test/input/func_r0904.py)9
-rw-r--r--pylint/test/functional/too_many_public_methods.txt1
-rw-r--r--pylint/test/functional/too_many_return_statements.py (renamed from pylint/test/input/func_w0101.py)8
-rw-r--r--pylint/test/functional/too_many_return_statements.txt1
-rw-r--r--pylint/test/functional/too_many_statements.py (renamed from pylint/test/input/func_w0105.py)6
-rw-r--r--pylint/test/functional/too_many_statements.txt1
-rw-r--r--pylint/test/functional/trailing_whitespaces.py (renamed from pylint/test/input/func_trailing_whitespace.py)3
-rw-r--r--pylint/test/functional/trailing_whitespaces.txt3
-rw-r--r--pylint/test/functional/unreachable.py22
-rw-r--r--pylint/test/functional/unreachable.txt4
-rw-r--r--pylint/test/input/func_eval_used.py13
-rw-r--r--pylint/test/input/func_f0401.py9
-rw-r--r--pylint/test/input/func_operators.py19
-rw-r--r--pylint/test/input/func_r0901.py27
-rw-r--r--pylint/test/input/func_set_literal_as_default_py27.py7
-rw-r--r--pylint/test/input/func_unreachable.py21
-rw-r--r--pylint/test/input/func_w0103.py8
-rw-r--r--pylint/test/input/func_w0110.py10
-rw-r--r--pylint/test/input/func_w0111.py10
-rw-r--r--pylint/test/input/func_w0112.py37
-rw-r--r--pylint/test/input/func_w0151.py5
-rw-r--r--pylint/test/input/func_w0202.py17
-rw-r--r--pylint/test/input/func_w0402.py4
-rw-r--r--pylint/test/input/func_w0623_py_30.py2
-rw-r--r--pylint/test/input/func_w0704.py16
-rw-r--r--pylint/test/messages/func_bad_exception_context_py30.txt3
-rw-r--r--pylint/test/messages/func_dangerous_default.txt13
-rw-r--r--pylint/test/messages/func_dangerous_default_py30.txt13
-rw-r--r--pylint/test/messages/func_eval_used.txt4
-rw-r--r--pylint/test/messages/func_f0401.txt2
-rw-r--r--pylint/test/messages/func_fixme.txt5
-rw-r--r--pylint/test/messages/func_invalid_sequence_index.txt19
-rw-r--r--pylint/test/messages/func_method_could_be_function.txt1
-rw-r--r--pylint/test/messages/func_operators.txt6
-rw-r--r--pylint/test/messages/func_r0901.txt2
-rw-r--r--pylint/test/messages/func_r0902.txt1
-rw-r--r--pylint/test/messages/func_r0903.txt1
-rw-r--r--pylint/test/messages/func_r0904.txt1
-rw-r--r--pylint/test/messages/func_r0923.txt1
-rw-r--r--pylint/test/messages/func_set_literal_as_default_py27.txt1
-rw-r--r--pylint/test/messages/func_trailing_whitespace.txt3
-rw-r--r--pylint/test/messages/func_unreachable.txt3
-rw-r--r--pylint/test/messages/func_w0101.txt1
-rw-r--r--pylint/test/messages/func_w0102.txt5
-rw-r--r--pylint/test/messages/func_w0103.txt1
-rw-r--r--pylint/test/messages/func_w0105.txt1
-rw-r--r--pylint/test/messages/func_w0110.txt1
-rw-r--r--pylint/test/messages/func_w0111.txt1
-rw-r--r--pylint/test/messages/func_w0112.txt1
-rw-r--r--pylint/test/messages/func_w0151.txt1
-rw-r--r--pylint/test/messages/func_w0202.txt3
-rw-r--r--pylint/test/messages/func_w0402.txt2
-rw-r--r--pylint/test/messages/func_w0623_py30.txt1
-rw-r--r--pylint/test/messages/func_w0704.txt1
-rw-r--r--pylint/test/messages/func_w0705.txt4
-rw-r--r--pylint/test/messages/func_w1201.txt3
-rw-r--r--pylint/test/messages/func_w1202.txt4
-rw-r--r--pylint/test/unittest_checker_strings.py41
-rw-r--r--pylint/utils.py4
-rw-r--r--pylintrc2
115 files changed, 494 insertions, 448 deletions
diff --git a/ChangeLog b/ChangeLog
index 422f2e6..357b90a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -38,6 +38,13 @@ ChangeLog for Pylint
* The colorized reporter now works on Windows. Closes issue #96.
+ * Remove pointless-except warning. It was previously disabled by
+ default and it wasn't very useful. Closes issue #506.
+
+ * Fix a crash on Python 3 related to the string checker, which
+ crashed when it encountered a bytes string with a .format
+ method called.
+
2015-03-14 -- 1.4.3
diff --git a/pylint/checkers/classes.py b/pylint/checkers/classes.py
index fe6d26d..2bd7cc1 100644
--- a/pylint/checkers/classes.py
+++ b/pylint/checkers/classes.py
@@ -684,8 +684,6 @@ a metaclass class method.'}
"""check that accessed members are defined"""
# XXX refactor, probably much simpler now that E0201 is in type checker
for attr, nodes in six.iteritems(accessed):
- # deactivate "except doesn't do anything", that's expected
- # pylint: disable=W0704
try:
# is it a class attribute ?
node.local_attr(attr)
diff --git a/pylint/checkers/exceptions.py b/pylint/checkers/exceptions.py
index d4c1746..b11a120 100644
--- a/pylint/checkers/exceptions.py
+++ b/pylint/checkers/exceptions.py
@@ -22,7 +22,6 @@ from logilab.common.compat import builtins
from pylint.checkers import BaseChecker
from pylint.checkers.utils import (
- is_empty,
is_raising,
check_messages,
inherit_from_std_ex,
@@ -91,10 +90,6 @@ MSGS = {
'broad-except',
'Used when an except catches a too general exception, \
possibly burying unrelated errors.'),
- 'W0704': ('Except doesn\'t do anything',
- 'pointless-except',
- 'Used when an except clause does nothing but "pass" and there is\
- no "else" clause.'),
'W0705': ('Catching previously caught exception type %s',
'duplicate-except',
'Used when an except catches a type that was already caught by '
@@ -272,7 +267,7 @@ class ExceptionsChecker(BaseChecker):
node=handler.type,
args=(exc.name, ))
- @check_messages('bare-except', 'broad-except', 'pointless-except',
+ @check_messages('bare-except', 'broad-except',
'binary-op-exception', 'bad-except-order',
'catching-non-exception')
def visit_tryexcept(self, node):
@@ -280,10 +275,6 @@ class ExceptionsChecker(BaseChecker):
exceptions_classes = []
nb_handlers = len(node.handlers)
for index, handler in enumerate(node.handlers):
- # single except doing nothing but "pass" without else clause
- if is_empty(handler.body) and not node.orelse:
- self.add_message('pointless-except',
- node=handler.type or handler.body[0])
if handler.type is None:
if not is_raising(handler.body):
self.add_message('bare-except', node=handler)
diff --git a/pylint/checkers/python3.py b/pylint/checkers/python3.py
index 837cbef..ccffce7 100644
--- a/pylint/checkers/python3.py
+++ b/pylint/checkers/python3.py
@@ -448,7 +448,7 @@ class Python3Checker(checkers.BaseChecker):
args = node.args
elif (isinstance(node.func, astroid.Name)
- and node.func.name == 'sorted'):
+ and node.func.name == 'sorted'):
inferred = utils.safe_infer(node.func)
if not inferred:
return
diff --git a/pylint/checkers/strings.py b/pylint/checkers/strings.py
index 8892c2c..b97738d 100644
--- a/pylint/checkers/strings.py
+++ b/pylint/checkers/strings.py
@@ -361,6 +361,9 @@ class StringMethodsChecker(BaseChecker):
return
if not isinstance(strnode, astroid.Const):
return
+ if not isinstance(strnode.value, six.string_types):
+ return
+
if node.starargs or node.kwargs:
# TODO: Don't complicate the logic, skip these for now.
return
diff --git a/pylint/checkers/typecheck.py b/pylint/checkers/typecheck.py
index a8fc846..c86f8b9 100644
--- a/pylint/checkers/typecheck.py
+++ b/pylint/checkers/typecheck.py
@@ -633,18 +633,27 @@ accessed. Python regular expressions are accepted.'}
infered = safe_infer(ctx_mgr)
if infered is None or infered is astroid.YES:
continue
+
if isinstance(infered, astroid.bases.Generator):
- func = safe_infer(ctx_mgr.func)
+ if (isinstance(ctx_mgr, astroid.Name) and
+ infered.parent and
+ isinstance(infered.parent, astroid.Function)):
+ func = infered.parent
+ else:
+ func = safe_infer(ctx_mgr.func)
+
if func is None and func is astroid.YES:
continue
if not decorated_with(func, ['contextlib.contextmanager']):
- self.add_message('not-context-manager', node=node, args=(infered.name, ))
+ self.add_message('not-context-manager',
+ node=node, args=(infered.name, ))
else:
try:
infered.getattr('__enter__')
infered.getattr('__exit__')
except astroid.NotFoundError:
- self.add_message('not-context-manager', node=node, args=(infered.name, ))
+ self.add_message('not-context-manager',
+ node=node, args=(infered.name, ))
def register(linter):
diff --git a/pylint/checkers/utils.py b/pylint/checkers/utils.py
index 231fe1c..4db0862 100644
--- a/pylint/checkers/utils.py
+++ b/pylint/checkers/utils.py
@@ -122,10 +122,6 @@ def is_raising(body):
return True
return False
-def is_empty(body):
- """return true if the given node does nothing but 'pass'"""
- return len(body) == 1 and isinstance(body[0], astroid.Pass)
-
builtins = builtins.__dict__.copy()
SPECIAL_BUILTINS = ('__builtins__',) # '__path__', '__file__')
diff --git a/pylint/checkers/variables.py b/pylint/checkers/variables.py
index 8653d54..c813727 100644
--- a/pylint/checkers/variables.py
+++ b/pylint/checkers/variables.py
@@ -425,7 +425,7 @@ builtins. Remember that you should avoid to define new builtins when possible.'
msg = "%s imported as %s" % (imported_name, as_name)
self.add_message('unused-import', args=msg, node=stmt)
elif (isinstance(stmt, astroid.From)
- and stmt.modname != '__future__'):
+ and stmt.modname != '__future__'):
if SPECIAL_OBJ.search(imported_name):
# Filter special objects (__doc__, __all__) etc.,
diff --git a/pylint/lint.py b/pylint/lint.py
index 0df8475..ec03420 100644
--- a/pylint/lint.py
+++ b/pylint/lint.py
@@ -29,7 +29,6 @@ from __future__ import print_function
import collections
import contextlib
-import itertools
import operator
import os
try:
@@ -97,7 +96,11 @@ def _get_python_path(filepath):
def _merge_stats(stats):
merged = {}
+ by_msg = collections.Counter()
for stat in stats:
+ message_stats = stat.pop('by_msg', {})
+ by_msg.update(message_stats)
+
for key, item in six.iteritems(stat):
if key not in merged:
merged[key] = item
@@ -106,6 +109,8 @@ def _merge_stats(stats):
merged[key].update(item)
else:
merged[key] = merged[key] + item
+
+ merged['by_msg'] = by_msg
return merged
@@ -402,24 +407,24 @@ class PyLinter(configuration.OptionsManagerMixIn,
' may run arbitrary code.')}),
('extension-pkg-whitelist',
- {'type': 'csv', 'metavar': '<pkg[,pkg]>', 'default': [],
- 'help': ('A comma-separated list of package or module names'
- ' from where C extensions may be loaded. Extensions are'
- ' loading into the active Python interpreter and may run'
- ' arbitrary code')}
- ),
+ {'type': 'csv', 'metavar': '<pkg[,pkg]>', 'default': [],
+ 'help': ('A comma-separated list of package or module names'
+ ' from where C extensions may be loaded. Extensions are'
+ ' loading into the active Python interpreter and may run'
+ ' arbitrary code')}
+ ),
('optimize-ast',
- {'type': 'yn', 'metavar': '<yn>', 'default': False,
- 'help': ('Allow optimization of some AST trees. This will '
- 'activate a peephole AST optimizer, which will '
- 'apply various small optimizations. For instance, '
- 'it can be used to obtain the result of joining '
- 'multiple strings with the addition operator. '
- 'Joining a lot of strings can lead to a maximum '
- 'recursion error in Pylint and this flag can prevent '
- 'that. It has one side effect, the resulting AST '
- 'will be different than the one from reality.')}
+ {'type': 'yn', 'metavar': '<yn>', 'default': False,
+ 'help': ('Allow optimization of some AST trees. This will '
+ 'activate a peephole AST optimizer, which will '
+ 'apply various small optimizations. For instance, '
+ 'it can be used to obtain the result of joining '
+ 'multiple strings with the addition operator. '
+ 'Joining a lot of strings can lead to a maximum '
+ 'recursion error in Pylint and this flag can prevent '
+ 'that. It has one side effect, the resulting AST '
+ 'will be different than the one from reality.')}
),
)
@@ -528,8 +533,8 @@ class PyLinter(configuration.OptionsManagerMixIn,
meth = self._options_methods[optname]
except KeyError:
meth = self._bw_options_methods[optname]
- warnings.warn('%s is deprecated, replace it by %s' % (
- optname, optname.split('-')[0]),
+ warnings.warn('%s is deprecated, replace it by %s' % (optname,
+ optname.split('-')[0]),
DeprecationWarning)
value = optik_ext.check_csv(None, optname, value)
if isinstance(value, (list, tuple)):
@@ -827,7 +832,7 @@ class PyLinter(configuration.OptionsManagerMixIn,
all_stats.append(stats)
self.msg_status |= msg_status
- self.stats = _merge_stats(itertools.chain(all_stats, [self.stats]))
+ self.stats = _merge_stats(all_stats)
self.current_name = module
# Insert stats data to local checkers.
@@ -915,7 +920,7 @@ class PyLinter(configuration.OptionsManagerMixIn,
if isinstance(ex.args[0], SyntaxError):
ex = ex.args[0]
self.add_message('syntax-error',
- line=ex.lineno,
+ line=ex.lineno or 0,
args=ex.msg)
else:
self.add_message('parse-error', args=ex)
@@ -1277,7 +1282,6 @@ group are mutually exclusive.'),
'been issued by analysing pylint output status code\n',
level=1)
# read configuration
- linter.disable('pointless-except')
linter.disable('suppressed-message')
linter.disable('useless-suppression')
linter.read_config_file()
diff --git a/pylint/reporters/__init__.py b/pylint/reporters/__init__.py
index ea3281f..db96cf6 100644
--- a/pylint/reporters/__init__.py
+++ b/pylint/reporters/__init__.py
@@ -17,6 +17,7 @@ from __future__ import print_function
import sys
import locale
import os
+import six
from pylint import utils
@@ -78,7 +79,7 @@ class BaseReporter(object):
return
def encode(string):
- if not isinstance(string, unicode):
+ if not isinstance(string, six.text_type):
return string
encoding = (getattr(self.out, 'encoding', None) or
locale.getdefaultlocale()[1] or
diff --git a/pylint/test/functional/bad_builtin.py b/pylint/test/functional/bad_builtin.py
new file mode 100644
index 0000000..fd4eaf6
--- /dev/null
+++ b/pylint/test/functional/bad_builtin.py
@@ -0,0 +1,3 @@
+# pylint: disable=missing-docstring
+
+TEST = map(str, (1, 2, 3)) # [bad-builtin]
diff --git a/pylint/test/functional/bad_builtin.txt b/pylint/test/functional/bad_builtin.txt
new file mode 100644
index 0000000..8a3d610
--- /dev/null
+++ b/pylint/test/functional/bad_builtin.txt
@@ -0,0 +1 @@
+bad-builtin:3::Used builtin function 'map'
diff --git a/pylint/test/input/func_bad_exception_context_py30.py b/pylint/test/functional/bad_exception_context.py
index 98b44ee..f386343 100644
--- a/pylint/test/input/func_bad_exception_context_py30.py
+++ b/pylint/test/functional/bad_exception_context.py
@@ -11,14 +11,14 @@ class ExceptionSubclass(Exception):
def test():
""" docstring """
- raise IndexError from 1
+ raise IndexError from 1 # [bad-exception-context]
raise IndexError from None
raise IndexError from ZeroDivisionError
- raise IndexError from object()
+ raise IndexError from object() # [bad-exception-context]
raise IndexError from ExceptionSubclass
raise IndexError from socket.error
raise IndexError() from None
raise IndexError() from ZeroDivisionError
raise IndexError() from ZeroDivisionError()
- raise IndexError() from object()
+ raise IndexError() from object() # [bad-exception-context]
raise IndexError() from unknown
diff --git a/pylint/test/functional/bad_exception_context.rc b/pylint/test/functional/bad_exception_context.rc
new file mode 100644
index 0000000..8c6eb56
--- /dev/null
+++ b/pylint/test/functional/bad_exception_context.rc
@@ -0,0 +1,2 @@
+[testoptions]
+min_pyver=3.0 \ No newline at end of file
diff --git a/pylint/test/functional/bad_exception_context.txt b/pylint/test/functional/bad_exception_context.txt
new file mode 100644
index 0000000..f403a39
--- /dev/null
+++ b/pylint/test/functional/bad_exception_context.txt
@@ -0,0 +1,3 @@
+bad-exception-context:14:test:Exception context set to something which is not an exception, nor None
+bad-exception-context:17:test:Exception context set to something which is not an exception, nor None
+bad-exception-context:23:test:Exception context set to something which is not an exception, nor None \ No newline at end of file
diff --git a/pylint/test/functional/bad_staticmethod_argument.py b/pylint/test/functional/bad_staticmethod_argument.py
new file mode 100644
index 0000000..0ff5d9b
--- /dev/null
+++ b/pylint/test/functional/bad_staticmethod_argument.py
@@ -0,0 +1,16 @@
+# pylint: disable=missing-docstring
+
+class Abcd(object):
+
+ def method1(self): # [bad-staticmethod-argument]
+ pass
+
+ method1 = staticmethod(method1)
+
+ def method2(cls): # [bad-staticmethod-argument]
+ pass
+
+ method2 = staticmethod(method2)
+
+ def __init__(self):
+ pass
diff --git a/pylint/test/functional/bad_staticmethod_argument.txt b/pylint/test/functional/bad_staticmethod_argument.txt
new file mode 100644
index 0000000..a9d5b46
--- /dev/null
+++ b/pylint/test/functional/bad_staticmethod_argument.txt
@@ -0,0 +1,2 @@
+bad-staticmethod-argument:5:Abcd.method1:Static method with 'self' as first argument
+bad-staticmethod-argument:10:Abcd.method2:Static method with 'cls' as first argument \ No newline at end of file
diff --git a/pylint/test/functional/blacklisted_name.py b/pylint/test/functional/blacklisted_name.py
new file mode 100644
index 0000000..b62c6d2
--- /dev/null
+++ b/pylint/test/functional/blacklisted_name.py
@@ -0,0 +1,4 @@
+# pylint: disable=missing-docstring
+
+def baz(): # [blacklisted-name]
+ pass
diff --git a/pylint/test/functional/blacklisted_name.txt b/pylint/test/functional/blacklisted_name.txt
new file mode 100644
index 0000000..f0fc9c2
--- /dev/null
+++ b/pylint/test/functional/blacklisted_name.txt
@@ -0,0 +1 @@
+blacklisted-name:3:baz:Black listed name "baz"
diff --git a/pylint/test/input/func_dangerous_default.py b/pylint/test/functional/dangerous_default_value.py
index 7351c12..58a22f4 100644
--- a/pylint/test/input/func_dangerous_default.py
+++ b/pylint/test/functional/dangerous_default_value.py
@@ -1,14 +1,13 @@
-"""docstring"""
-
+# pylint: disable=missing-docstring
HEHE = {}
-def function1(value=[]):
+def function1(value=[]): # [dangerous-default-value]
"""docstring"""
return value
-def function2(value=HEHE):
+def function2(value=HEHE): # [dangerous-default-value]
"""docstring"""
return value
@@ -16,7 +15,7 @@ def function3(value):
"""docstring"""
return value
-def function4(value=set()):
+def function4(value=set()): # [dangerous-default-value]
"""set is mutable and dangerous."""
return value
@@ -26,31 +25,31 @@ def function5(value=frozenset()):
GLOBAL_SET = set()
-def function6(value=GLOBAL_SET):
+def function6(value=GLOBAL_SET): # [dangerous-default-value]
"""set is mutable and dangerous."""
return value
-def function7(value=dict()):
+def function7(value=dict()): # [dangerous-default-value]
"""dict is mutable and dangerous."""
return value
-def function8(value=list()):
+def function8(value=list()): # [dangerous-default-value]
"""list is mutable and dangerous."""
return value
-def function9(value=[1, 2, 3, 4]):
+def function9(value=[1, 2, 3, 4]): # [dangerous-default-value]
"""list with items should not output item values in error message"""
return value
-def function10(value={'a': 1, 'b': 2}):
+def function10(value={'a': 1, 'b': 2}): # [dangerous-default-value]
"""dictionaries with items should not output item values in error message"""
return value
-def function11(value=list([1, 2, 3])):
+def function11(value=list([1, 2, 3])): # [dangerous-default-value]
"""list with items should not output item values in error message"""
return value
-def function12(value=dict([('a', 1), ('b', 2)])):
+def function12(value=dict([('a', 1), ('b', 2)])): # [dangerous-default-value]
"""dictionaries with items should not output item values in error message"""
return value
@@ -59,11 +58,11 @@ OINK = {
'b': 2
}
-def function13(value=OINK):
+def function13(value=OINK): # [dangerous-default-value]
"""dictionaries with items should not output item values in error message"""
return value
-def function14(value=dict([(1, 2), (1, 2, 3)])):
+def function14(value=dict([(1, 2), (1, 2, 3)])): # [dangerous-default-value]
"""a dictionary which will not be inferred to a syntax AST, but to an
astroid.Instance.
"""
@@ -71,6 +70,10 @@ def function14(value=dict([(1, 2), (1, 2, 3)])):
INVALID_DICT = dict([(1, 2), (1, 2, 3)])
-def function15(value=INVALID_DICT):
+def function15(value=INVALID_DICT): # [dangerous-default-value]
"""The same situation as function14."""
return value
+
+def function16(value={1}): # [dangerous-default-value]
+ """set literal as default value"""
+ return value
diff --git a/pylint/test/functional/dangerous_default_value.rc b/pylint/test/functional/dangerous_default_value.rc
new file mode 100644
index 0000000..a2328ed
--- /dev/null
+++ b/pylint/test/functional/dangerous_default_value.rc
@@ -0,0 +1,2 @@
+[testoptions]
+max_pyver=3.0 \ No newline at end of file
diff --git a/pylint/test/functional/dangerous_default_value.txt b/pylint/test/functional/dangerous_default_value.txt
new file mode 100644
index 0000000..92180e9
--- /dev/null
+++ b/pylint/test/functional/dangerous_default_value.txt
@@ -0,0 +1,14 @@
+dangerous-default-value:6:function1:Dangerous default value [] as argument
+dangerous-default-value:10:function2:Dangerous default value HEHE (__builtin__.dict) as argument
+dangerous-default-value:18:function4:Dangerous default value set() (__builtin__.set) as argument
+dangerous-default-value:28:function6:Dangerous default value GLOBAL_SET (__builtin__.set) as argument
+dangerous-default-value:32:function7:Dangerous default value dict() (__builtin__.dict) as argument
+dangerous-default-value:36:function8:Dangerous default value list() (__builtin__.list) as argument
+dangerous-default-value:40:function9:Dangerous default value [] as argument
+dangerous-default-value:44:function10:Dangerous default value {} as argument
+dangerous-default-value:48:function11:Dangerous default value list() (__builtin__.list) as argument
+dangerous-default-value:52:function12:Dangerous default value dict() (__builtin__.dict) as argument
+dangerous-default-value:61:function13:Dangerous default value OINK (__builtin__.dict) as argument
+dangerous-default-value:65:function14:Dangerous default value dict() (__builtin__.dict) as argument
+dangerous-default-value:73:function15:Dangerous default value INVALID_DICT (__builtin__.dict) as argument
+dangerous-default-value:77:function16:Dangerous default value set() as argument
diff --git a/pylint/test/functional/dangerous_default_value_py30.py b/pylint/test/functional/dangerous_default_value_py30.py
new file mode 100644
index 0000000..58a22f4
--- /dev/null
+++ b/pylint/test/functional/dangerous_default_value_py30.py
@@ -0,0 +1,79 @@
+# pylint: disable=missing-docstring
+
+
+HEHE = {}
+
+def function1(value=[]): # [dangerous-default-value]
+ """docstring"""
+ return value
+
+def function2(value=HEHE): # [dangerous-default-value]
+ """docstring"""
+ return value
+
+def function3(value):
+ """docstring"""
+ return value
+
+def function4(value=set()): # [dangerous-default-value]
+ """set is mutable and dangerous."""
+ return value
+
+def function5(value=frozenset()):
+ """frozenset is immutable and safe."""
+ return value
+
+GLOBAL_SET = set()
+
+def function6(value=GLOBAL_SET): # [dangerous-default-value]
+ """set is mutable and dangerous."""
+ return value
+
+def function7(value=dict()): # [dangerous-default-value]
+ """dict is mutable and dangerous."""
+ return value
+
+def function8(value=list()): # [dangerous-default-value]
+ """list is mutable and dangerous."""
+ return value
+
+def function9(value=[1, 2, 3, 4]): # [dangerous-default-value]
+ """list with items should not output item values in error message"""
+ return value
+
+def function10(value={'a': 1, 'b': 2}): # [dangerous-default-value]
+ """dictionaries with items should not output item values in error message"""
+ return value
+
+def function11(value=list([1, 2, 3])): # [dangerous-default-value]
+ """list with items should not output item values in error message"""
+ return value
+
+def function12(value=dict([('a', 1), ('b', 2)])): # [dangerous-default-value]
+ """dictionaries with items should not output item values in error message"""
+ return value
+
+OINK = {
+ 'a': 1,
+ 'b': 2
+}
+
+def function13(value=OINK): # [dangerous-default-value]
+ """dictionaries with items should not output item values in error message"""
+ return value
+
+def function14(value=dict([(1, 2), (1, 2, 3)])): # [dangerous-default-value]
+ """a dictionary which will not be inferred to a syntax AST, but to an
+ astroid.Instance.
+ """
+ return value
+
+INVALID_DICT = dict([(1, 2), (1, 2, 3)])
+
+def function15(value=INVALID_DICT): # [dangerous-default-value]
+ """The same situation as function14."""
+ return value
+
+def function16(value={1}): # [dangerous-default-value]
+ """set literal as default value"""
+ return value
diff --git a/pylint/test/functional/dangerous_default_value_py30.rc b/pylint/test/functional/dangerous_default_value_py30.rc
new file mode 100644
index 0000000..8c6eb56
--- /dev/null
+++ b/pylint/test/functional/dangerous_default_value_py30.rc
@@ -0,0 +1,2 @@
+[testoptions]
+min_pyver=3.0 \ No newline at end of file
diff --git a/pylint/test/functional/dangerous_default_value_py30.txt b/pylint/test/functional/dangerous_default_value_py30.txt
new file mode 100644
index 0000000..7571c00
--- /dev/null
+++ b/pylint/test/functional/dangerous_default_value_py30.txt
@@ -0,0 +1,14 @@
+dangerous-default-value:6:function1:Dangerous default value [] as argument
+dangerous-default-value:10:function2:Dangerous default value HEHE (builtins.dict) as argument
+dangerous-default-value:18:function4:Dangerous default value set() (builtins.set) as argument
+dangerous-default-value:28:function6:Dangerous default value GLOBAL_SET (builtins.set) as argument
+dangerous-default-value:32:function7:Dangerous default value dict() (builtins.dict) as argument
+dangerous-default-value:36:function8:Dangerous default value list() (builtins.list) as argument
+dangerous-default-value:40:function9:Dangerous default value [] as argument
+dangerous-default-value:44:function10:Dangerous default value {} as argument
+dangerous-default-value:48:function11:Dangerous default value list() (builtins.list) as argument
+dangerous-default-value:52:function12:Dangerous default value dict() (builtins.dict) as argument
+dangerous-default-value:61:function13:Dangerous default value OINK (builtins.dict) as argument
+dangerous-default-value:65:function14:Dangerous default value dict() (builtins.dict) as argument
+dangerous-default-value:73:function15:Dangerous default value INVALID_DICT (builtins.dict) as argument
+dangerous-default-value:77:function16:Dangerous default value set() as argument \ No newline at end of file
diff --git a/pylint/test/functional/eval_used.py b/pylint/test/functional/eval_used.py
new file mode 100644
index 0000000..799121b
--- /dev/null
+++ b/pylint/test/functional/eval_used.py
@@ -0,0 +1,11 @@
+"""test for eval usage"""
+
+eval('os.listdir(".")') # [eval-used]
+eval('os.listdir(".")', globals={}) # [eval-used]
+
+eval('os.listdir(".")', globals=globals()) # [eval-used]
+
+def func():
+ """ eval in local scope"""
+ eval('b = 1') # [eval-used]
+
diff --git a/pylint/test/functional/eval_used.txt b/pylint/test/functional/eval_used.txt
new file mode 100644
index 0000000..7f0e041
--- /dev/null
+++ b/pylint/test/functional/eval_used.txt
@@ -0,0 +1,4 @@
+eval-used:3::Use of eval
+eval-used:4::Use of eval
+eval-used:6::Use of eval
+eval-used:10:func:Use of eval \ No newline at end of file
diff --git a/pylint/test/input/func_fixme.py b/pylint/test/functional/fixme.py
index 9210be6..9d5d966 100644
--- a/pylint/test/input/func_fixme.py
+++ b/pylint/test/functional/fixme.py
@@ -1,15 +1,18 @@
-"""docstring"""
-# pylint: disable=W0612
-__revision__ = ''
+# pylint: disable=missing-docstring, unused-variable
+
+# +1: [fixme]
# FIXME: beep
def function():
- '''XXX:bop'''
variable = "FIXME: Ignore me!"
+ # +1: [fixme]
test = "text" # FIXME: Valid test
+ # +1: [fixme]
# TODO: Do something with the variables
+ # +1: [fixme]
xxx = "n/a" # XXX: Fix this later
+ # +1: [fixme]
#FIXME: no space after hash
diff --git a/pylint/test/functional/fixme.txt b/pylint/test/functional/fixme.txt
new file mode 100644
index 0000000..581788a
--- /dev/null
+++ b/pylint/test/functional/fixme.txt
@@ -0,0 +1,5 @@
+fixme:5::"FIXME: beep"
+fixme:11::"FIXME: Valid test"
+fixme:14::"TODO: Do something with the variables"
+fixme:16::"XXX: Fix this later"
+fixme:18::"FIXME: no space after hash" \ No newline at end of file
diff --git a/pylint/test/input/func_w0102.py b/pylint/test/functional/function_redefined.py
index 8a8ae4d..412ff28 100644
--- a/pylint/test/input/func_w0102.py
+++ b/pylint/test/functional/function_redefined.py
@@ -12,10 +12,10 @@ class AAAA(object):
def method2(self):
"""docstring"""
- def method2(self):
+ def method2(self): # [function-redefined]
"""docstring"""
-class AAAA(object):
+class AAAA(object): # [function-redefined]
"""docstring"""
def __init__(self):
pass
@@ -29,9 +29,9 @@ def func1():
def func2():
"""docstring"""
-def func2():
+def func2(): # [function-redefined]
"""docstring"""
- __revision__ = 1
+ __revision__ = 1 # [redefined-outer-name]
return __revision__
if __revision__:
@@ -48,7 +48,7 @@ except TypeError:
def exclusive_func2():
"docstring"
else:
- def exclusive_func2():
+ def exclusive_func2(): # [function-redefined]
"this one redefine the one defined line 42"
diff --git a/pylint/test/functional/function_redefined.txt b/pylint/test/functional/function_redefined.txt
new file mode 100644
index 0000000..56fabc5
--- /dev/null
+++ b/pylint/test/functional/function_redefined.txt
@@ -0,0 +1,5 @@
+function-redefined:15:AAAA.method2:method already defined line 12
+function-redefined:18:AAAA:class already defined line 5
+function-redefined:32:func2:function already defined line 29
+redefined-outer-name:34:func2:Redefining name '__revision__' from outer scope (line 3)
+function-redefined:51:exclusive_func2:function already defined line 45
diff --git a/pylint/test/input/func_r0923.py b/pylint/test/functional/interface_not_implemented.py
index 8ab44a1..6244ac4 100644
--- a/pylint/test/input/func_r0923.py
+++ b/pylint/test/functional/interface_not_implemented.py
@@ -1,9 +1,9 @@
-"""test max methods"""
+# pylint: disable=missing-docstring
from __future__ import absolute_import
-__revision__ = None
+
from logilab.common.interface import Interface
-class IAaaa(Interface):
+class IAaaa(Interface): # [interface-not-implemented]
"""yo"""
def meth1(self):
diff --git a/pylint/test/functional/interface_not_implemented.txt b/pylint/test/functional/interface_not_implemented.txt
new file mode 100644
index 0000000..ded0625
--- /dev/null
+++ b/pylint/test/functional/interface_not_implemented.txt
@@ -0,0 +1 @@
+interface-not-implemented:6:IAaaa:Interface not implemented
diff --git a/pylint/test/functional/invalid_name.py b/pylint/test/functional/invalid_name.py
index e86cfb3..1b45748 100644
--- a/pylint/test/functional/invalid_name.py
+++ b/pylint/test/functional/invalid_name.py
@@ -26,3 +26,6 @@ def test():
except ImportError:
re = None
return re
+
+def a(): # [invalid-name]
+ """yo"""
diff --git a/pylint/test/functional/invalid_name.txt b/pylint/test/functional/invalid_name.txt
index 0c8eafe..b5e9b7e 100644
--- a/pylint/test/functional/invalid_name.txt
+++ b/pylint/test/functional/invalid_name.txt
@@ -1,2 +1,3 @@
invalid-name:10::"Invalid constant name ""aaa"""
invalid-name:14::"Invalid constant name ""time"""
+invalid-name:30:a:"Invalid function name ""a"""
diff --git a/pylint/test/input/func_invalid_sequence_index.py b/pylint/test/functional/invalid_sequence_index.py
index b60e0b5..232b727 100644
--- a/pylint/test/input/func_invalid_sequence_index.py
+++ b/pylint/test/functional/invalid_sequence_index.py
@@ -10,19 +10,19 @@ TESTSTR = '123'
# getitem tests with bad indices
def function1():
"""list index is a function"""
- return TESTLIST[id]
+ return TESTLIST[id] # [invalid-sequence-index]
def function2():
"""list index is None"""
- return TESTLIST[None]
+ return TESTLIST[None] # [invalid-sequence-index]
def function3():
"""list index is a float expression"""
- return TESTLIST[float(0)]
+ return TESTLIST[float(0)] # [invalid-sequence-index]
def function4():
"""list index is a str constant"""
- return TESTLIST['0']
+ return TESTLIST['0'] # [invalid-sequence-index]
def function5():
"""list index does not implement __index__"""
@@ -30,22 +30,22 @@ def function5():
"""Class without __index__ method"""
pass
- return TESTLIST[NonIndexType()]
+ return TESTLIST[NonIndexType()] # [invalid-sequence-index]
def function6():
"""Tuple index is None"""
- return TESTTUPLE[None]
+ return TESTTUPLE[None] # [invalid-sequence-index]
def function7():
"""String index is None"""
- return TESTSTR[None]
+ return TESTSTR[None] # [invalid-sequence-index]
def function8():
"""Index of subclass of tuple is None"""
class TupleTest(tuple):
"""Subclass of tuple"""
pass
- return TupleTest()[None]
+ return TupleTest()[None] # [invalid-sequence-index]
# getitem tests with good indices
def function9():
@@ -125,12 +125,12 @@ def function18():
# Test with set and delete statements
def function19():
"""Set with None and integer indices"""
- TESTLIST[None] = 0
+ TESTLIST[None] = 0 # [invalid-sequence-index]
TESTLIST[0] = 0 # no error
def function20():
"""Delete with None and integer indicies"""
- del TESTLIST[None]
+ del TESTLIST[None] # [invalid-sequence-index]
del TESTLIST[0] # no error
def function21():
@@ -141,8 +141,8 @@ def function21():
test = ListTest()
# Set and delete with invalid indices
- test[None] = 0
- del test[None]
+ test[None] = 0 # [invalid-sequence-index]
+ del test[None] # [invalid-sequence-index]
# Set and delete with valid indices
test[0] = 0 # no error
@@ -156,8 +156,10 @@ def function22():
pass
test = ListTest()
- test[None][0] = 0 # failure on the getitem with None
- del test[None]
+ # failure on the getitem with None
+ test[None][0] = 0 # [invalid-sequence-index]
+ # failure on the getitem with None
+ del test[None] # [invalid-sequence-index]
test[0][0] = 0 # getitem with int and setitem with int, no error
test[None] = 0 # setitem overridden, no error
@@ -172,8 +174,10 @@ def function23():
pass
test = ListTest()
- test[None][0] = 0 # failure on the getitem with None
- test[None] = 0 # setitem with invalid index
+ # failure on the getitem with None
+ test[None][0] = 0 # [invalid-sequence-index]
+ # setitem with invalid index
+ test[None] = 0 # [invalid-sequence-index]
test[0][0] = 0 # getitem with int and setitem with int, no error
test[0] = 0 # setitem with int, no error
@@ -188,8 +192,10 @@ def function24():
pass
test = ListTest()
- test[None] = 0 # setitem with invalid index
- del test[None] # delitem with invalid index
+ # setitem with invalid index
+ test[None] = 0 # [invalid-sequence-index]
+ # delitem with invalid index
+ del test[None] # [invalid-sequence-index]
test[None][0] = 0 # getitem overriden, no error
test[0][0] = 0 # getitem with int and setitem with int, no error
@@ -199,7 +205,7 @@ def function24():
# Teest ExtSlice usage
def function25():
"""Extended slice used with a list"""
- return TESTLIST[..., 0]
+ return TESTLIST[..., 0] # [invalid-sequence-index]
def function26():
"""Extended slice used with an object that implements __getitem__"""
diff --git a/pylint/test/functional/invalid_sequence_index.txt b/pylint/test/functional/invalid_sequence_index.txt
new file mode 100644
index 0000000..204aebc
--- /dev/null
+++ b/pylint/test/functional/invalid_sequence_index.txt
@@ -0,0 +1,20 @@
+invalid-sequence-index:13:function1:Sequence index is not an int, slice, or instance with __index__
+invalid-sequence-index:17:function2:Sequence index is not an int, slice, or instance with __index__
+invalid-sequence-index:21:function3:Sequence index is not an int, slice, or instance with __index__
+invalid-sequence-index:25:function4:Sequence index is not an int, slice, or instance with __index__
+invalid-sequence-index:33:function5:Sequence index is not an int, slice, or instance with __index__
+invalid-sequence-index:37:function6:Sequence index is not an int, slice, or instance with __index__
+invalid-sequence-index:41:function7:Sequence index is not an int, slice, or instance with __index__
+invalid-sequence-index:48:function8:Sequence index is not an int, slice, or instance with __index__
+invalid-sequence-index:128:function19:Sequence index is not an int, slice, or instance with __index__
+invalid-sequence-index:133:function20:Sequence index is not an int, slice, or instance with __index__
+invalid-sequence-index:144:function21:Sequence index is not an int, slice, or instance with __index__
+invalid-sequence-index:145:function21:Sequence index is not an int, slice, or instance with __index__
+invalid-sequence-index:159:function22:Sequence index is not an int, slice, or instance with __index__
+invalid-sequence-index:160:function22:Sequence index is not an int, slice, or instance with __index__
+invalid-sequence-index:162:function22:Sequence index is not an int, slice, or instance with __index__
+invalid-sequence-index:178:function23:Sequence index is not an int, slice, or instance with __index__
+invalid-sequence-index:180:function23:Sequence index is not an int, slice, or instance with __index__
+invalid-sequence-index:196:function24:Sequence index is not an int, slice, or instance with __index__
+invalid-sequence-index:198:function24:Sequence index is not an int, slice, or instance with __index__
+invalid-sequence-index:208:function25:Sequence index is not an int, slice, or instance with __index__ \ No newline at end of file
diff --git a/pylint/test/input/func_w1202.py b/pylint/test/functional/logging_format_interpolation.py
index 7efb825..85117bf 100644
--- a/pylint/test/input/func_w1202.py
+++ b/pylint/test/functional/logging_format_interpolation.py
@@ -1,6 +1,4 @@
-# pylint: disable=E1101, no-absolute-import, import-error
-"""test checking use of the logging module
-"""
+# pylint: disable=E1101, no-absolute-import, import-error,line-too-long, missing-docstring
try:
import __builtin__ as builtins
@@ -14,10 +12,10 @@ import os as logging
FORMAT_STR = '{0}, {1}'
# Statements that should be flagged:
-renamed_logging.debug('{0}, {1}'.format(4, 5))
-renamed_logging.log(renamed_logging.DEBUG, 'msg: {}'.format('Run!'))
-renamed_logging.debug(FORMAT_STR.format(4, 5))
-renamed_logging.log(renamed_logging.DEBUG, FORMAT_STR.format(4, 5))
+renamed_logging.debug('{0}, {1}'.format(4, 5)) # [logging-format-interpolation]
+renamed_logging.log(renamed_logging.DEBUG, 'msg: {}'.format('Run!')) # [logging-format-interpolation]
+renamed_logging.debug(FORMAT_STR.format(4, 5)) # [logging-format-interpolation]
+renamed_logging.log(renamed_logging.DEBUG, FORMAT_STR.format(4, 5)) # [logging-format-interpolation]
# Statements that should not be flagged:
renamed_logging.debug(format(66, 'x'))
diff --git a/pylint/test/functional/logging_format_interpolation.txt b/pylint/test/functional/logging_format_interpolation.txt
new file mode 100644
index 0000000..d08878e
--- /dev/null
+++ b/pylint/test/functional/logging_format_interpolation.txt
@@ -0,0 +1,4 @@
+logging-format-interpolation:15::Use % formatting in logging functions but pass the % parameters as arguments
+logging-format-interpolation:16::Use % formatting in logging functions but pass the % parameters as arguments
+logging-format-interpolation:17::Use % formatting in logging functions but pass the % parameters as arguments
+logging-format-interpolation:18::Use % formatting in logging functions but pass the % parameters as arguments
diff --git a/pylint/test/input/func_w1201.py b/pylint/test/functional/logging_not_lazy.py
index a9791d9..ccc8665 100644
--- a/pylint/test/input/func_w1201.py
+++ b/pylint/test/functional/logging_not_lazy.py
@@ -1,17 +1,13 @@
-# pylint: disable=E1101, no-absolute-import
-"""test checking use of the logging module
-"""
-
-__revision__ = ''
+# pylint: disable=missing-docstring,no-member
# Muck up the names in an effort to confuse...
import logging as renamed_logging
import os as logging
# Statements that should be flagged:
-renamed_logging.warn('%s, %s' % (4, 5))
-renamed_logging.exception('%s' % 'Exceptional!')
-renamed_logging.log(renamed_logging.INFO, 'msg: %s' % 'Run!')
+renamed_logging.warn('%s, %s' % (4, 5)) # [logging-not-lazy]
+renamed_logging.exception('%s' % 'Exceptional!') # [logging-not-lazy]
+renamed_logging.log(renamed_logging.INFO, 'msg: %s' % 'Run!') # [logging-not-lazy]
# Statements that should not be flagged:
renamed_logging.warn('%s, %s', 4, 5)
diff --git a/pylint/test/functional/logging_not_lazy.txt b/pylint/test/functional/logging_not_lazy.txt
new file mode 100644
index 0000000..60c6c59
--- /dev/null
+++ b/pylint/test/functional/logging_not_lazy.txt
@@ -0,0 +1,3 @@
+logging-not-lazy:8::Specify string format arguments as logging function parameters
+logging-not-lazy:9::Specify string format arguments as logging function parameters
+logging-not-lazy:10::Specify string format arguments as logging function parameters
diff --git a/pylint/test/input/func_method_could_be_function.py b/pylint/test/functional/no_self_use.py
index 4a4ea8f..9c432f9 100644
--- a/pylint/test/input/func_method_could_be_function.py
+++ b/pylint/test/functional/no_self_use.py
@@ -13,7 +13,7 @@ class Toto(object):
"""this method is a real method since it access to self"""
self.function_method()
- def function_method(self):
+ def function_method(self): # [no-self-use]
"""this method isn' a real method since it doesn't need self"""
print('hello')
diff --git a/pylint/test/functional/no_self_use.txt b/pylint/test/functional/no_self_use.txt
new file mode 100644
index 0000000..e68dcff
--- /dev/null
+++ b/pylint/test/functional/no_self_use.txt
@@ -0,0 +1 @@
+no-self-use:16:Toto.function_method:Method could be a function \ No newline at end of file
diff --git a/pylint/test/functional/nonexistent_operator.py b/pylint/test/functional/nonexistent_operator.py
new file mode 100644
index 0000000..f05a649
--- /dev/null
+++ b/pylint/test/functional/nonexistent_operator.py
@@ -0,0 +1,15 @@
+"""check operator use"""
+# pylint: disable=invalid-name, pointless-statement
+a = 1
+a += 5
+a = +a
+b = ++a # [nonexistent-operator]
+++a # [nonexistent-operator]
+c = (++a) * b # [nonexistent-operator]
+
+a = 1
+a -= 5
+b = --a # [nonexistent-operator]
+b = a
+--a # [nonexistent-operator]
+c = (--a) * b # [nonexistent-operator]
diff --git a/pylint/test/functional/nonexistent_operator.txt b/pylint/test/functional/nonexistent_operator.txt
new file mode 100644
index 0000000..da59f41
--- /dev/null
+++ b/pylint/test/functional/nonexistent_operator.txt
@@ -0,0 +1,6 @@
+nonexistent-operator:6::"Use of the non-existent ++ operator"
+nonexistent-operator:7::"Use of the non-existent ++ operator"
+nonexistent-operator:8::"Use of the non-existent ++ operator"
+nonexistent-operator:12::"Use of the non-existent -- operator"
+nonexistent-operator:14::"Use of the non-existent -- operator"
+nonexistent-operator:15::"Use of the non-existent -- operator"
diff --git a/pylint/test/functional/not_context_manager.py b/pylint/test/functional/not_context_manager.py
index af714df..5c0a587 100644
--- a/pylint/test/functional/not_context_manager.py
+++ b/pylint/test/functional/not_context_manager.py
@@ -43,3 +43,17 @@ with dec: # [not-context-manager]
from missing import Missing
with Missing():
pass
+
+# Tests context managers as names.
+
+def penelopa():
+ return 42
+
+hopa = dec()
+tropa = penelopa()
+
+with tropa: # [not-context-manager]
+ pass
+
+with hopa:
+ pass
diff --git a/pylint/test/functional/not_context_manager.txt b/pylint/test/functional/not_context_manager.txt
index aea524d..a43387d 100644
--- a/pylint/test/functional/not_context_manager.txt
+++ b/pylint/test/functional/not_context_manager.txt
@@ -1,2 +1,3 @@
not-context-manager:23::Context manager 'NotAManager' doesn't implement __enter__ and __exit__.
not-context-manager:37::Context manager 'dec' doesn't implement __enter__ and __exit__.
+not-context-manager:55::Context manager 'int' doesn't implement __enter__ and __exit__.
diff --git a/pylint/test/input/func_r0903.py b/pylint/test/functional/too_few_public_methods.py
index 49008f9..9b3c4b2 100644
--- a/pylint/test/input/func_r0903.py
+++ b/pylint/test/functional/too_few_public_methods.py
@@ -1,16 +1,15 @@
-"""test min methods"""
+# pylint: disable=missing-docstring
from __future__ import print_function
-__revision__ = None
-class Aaaa(object):
- """yo"""
+class Aaaa(object): # [too-few-public-methods]
+
def __init__(self):
pass
+
def meth1(self):
- """hehehe"""
print(self)
+
def _dontcount(self):
- """not public"""
print(self)
diff --git a/pylint/test/functional/too_few_public_methods.txt b/pylint/test/functional/too_few_public_methods.txt
new file mode 100644
index 0000000..be0e73e
--- /dev/null
+++ b/pylint/test/functional/too_few_public_methods.txt
@@ -0,0 +1 @@
+too-few-public-methods:4:Aaaa:Too few public methods (1/2)
diff --git a/pylint/test/functional/too_many_ancestors.py b/pylint/test/functional/too_many_ancestors.py
new file mode 100644
index 0000000..e0f7be2
--- /dev/null
+++ b/pylint/test/functional/too_many_ancestors.py
@@ -0,0 +1,25 @@
+# pylint: disable=missing-docstring, too-few-public-methods
+
+class Aaaa(object):
+ pass
+class Bbbb(object):
+ pass
+class Cccc(object):
+ pass
+class Dddd(object):
+ pass
+class Eeee(object):
+ pass
+class Ffff(object):
+ pass
+class Gggg(object):
+ pass
+class Hhhh(object):
+ pass
+
+class Iiii(Aaaa, Bbbb, Cccc, Dddd, Eeee, Ffff, Gggg, Hhhh): # [too-many-ancestors]
+ pass
+
+class Jjjj(Iiii): # [too-many-ancestors]
+ pass
+
diff --git a/pylint/test/functional/too_many_ancestors.txt b/pylint/test/functional/too_many_ancestors.txt
new file mode 100644
index 0000000..e9f0841
--- /dev/null
+++ b/pylint/test/functional/too_many_ancestors.txt
@@ -0,0 +1,2 @@
+too-many-ancestors:20:Iiii:Too many ancestors (9/7)
+too-many-ancestors:23:Jjjj:Too many ancestors (10/7) \ No newline at end of file
diff --git a/pylint/test/functional/too_many_arguments.py b/pylint/test/functional/too_many_arguments.py
new file mode 100644
index 0000000..99f4e78
--- /dev/null
+++ b/pylint/test/functional/too_many_arguments.py
@@ -0,0 +1,4 @@
+# pylint: disable=missing-docstring
+
+def stupid_function(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9): # [too-many-arguments]
+ return arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9
diff --git a/pylint/test/functional/too_many_arguments.txt b/pylint/test/functional/too_many_arguments.txt
new file mode 100644
index 0000000..8f99a46
--- /dev/null
+++ b/pylint/test/functional/too_many_arguments.txt
@@ -0,0 +1 @@
+too-many-arguments:3:stupid_function:Too many arguments (9/5)
diff --git a/pylint/test/input/func_r0902.py b/pylint/test/functional/too_many_instance_attributes.py
index d0a7483..b77efdb 100644
--- a/pylint/test/input/func_r0902.py
+++ b/pylint/test/functional/too_many_instance_attributes.py
@@ -1,9 +1,7 @@
-# pylint: disable=R0903
-"""test max instance attributes"""
-__revision__ = None
+# pylint: disable=missing-docstring, too-few-public-methods
+
+class Aaaa(object): # [too-many-instance-attributes]
-class Aaaa(object):
- """yo"""
def __init__(self):
self.aaaa = 1
self.bbbb = 2
diff --git a/pylint/test/functional/too_many_instance_attributes.txt b/pylint/test/functional/too_many_instance_attributes.txt
new file mode 100644
index 0000000..652ccea
--- /dev/null
+++ b/pylint/test/functional/too_many_instance_attributes.txt
@@ -0,0 +1 @@
+too-many-instance-attributes:3:Aaaa:Too many instance attributes (21/7)
diff --git a/pylint/test/input/func_r0904.py b/pylint/test/functional/too_many_public_methods.py
index 85daf61..df6134f 100644
--- a/pylint/test/input/func_r0904.py
+++ b/pylint/test/functional/too_many_public_methods.py
@@ -1,8 +1,7 @@
-# pylint: disable=R0201
-"""test max methods"""
-__revision__ = None
-class Aaaa(object):
- """yo"""
+# pylint: disable=missing-docstring
+
+class Aaaa(object): # [too-many-public-methods]
+
def __init__(self):
pass
diff --git a/pylint/test/functional/too_many_public_methods.txt b/pylint/test/functional/too_many_public_methods.txt
new file mode 100644
index 0000000..1b5a250
--- /dev/null
+++ b/pylint/test/functional/too_many_public_methods.txt
@@ -0,0 +1 @@
+too-many-public-methods:3:Aaaa:Too many public methods (21/20)
diff --git a/pylint/test/input/func_w0101.py b/pylint/test/functional/too_many_return_statements.py
index fe543aa..7ae61a9 100644
--- a/pylint/test/input/func_w0101.py
+++ b/pylint/test/functional/too_many_return_statements.py
@@ -1,10 +1,6 @@
-"""test max returns
-"""
+# pylint: disable=missing-docstring
-__revision__ = ''
-
-def stupid_function(arg):
- """reallly stupid function"""
+def stupid_function(arg): # [too-many-return-statements]
if arg == 1:
return 1
elif arg == 2:
diff --git a/pylint/test/functional/too_many_return_statements.txt b/pylint/test/functional/too_many_return_statements.txt
new file mode 100644
index 0000000..4f65db2
--- /dev/null
+++ b/pylint/test/functional/too_many_return_statements.txt
@@ -0,0 +1 @@
+too-many-return-statements:3:stupid_function:Too many return statements (11/6) \ No newline at end of file
diff --git a/pylint/test/input/func_w0105.py b/pylint/test/functional/too_many_statements.py
index d5f8b9b..305db80 100644
--- a/pylint/test/input/func_w0105.py
+++ b/pylint/test/functional/too_many_statements.py
@@ -1,10 +1,8 @@
-"""test max branch
-"""
+# pylint: disable=missing-docstring
from __future__ import print_function
-def stupid_function(arg):
- """reallly stupid function"""
+def stupid_function(arg): # [too-many-statements]
if arg == 1:
print(1)
elif arg == 2:
diff --git a/pylint/test/functional/too_many_statements.txt b/pylint/test/functional/too_many_statements.txt
new file mode 100644
index 0000000..255e97e
--- /dev/null
+++ b/pylint/test/functional/too_many_statements.txt
@@ -0,0 +1 @@
+too-many-statements:5:stupid_function:Too many statements (55/50)
diff --git a/pylint/test/input/func_trailing_whitespace.py b/pylint/test/functional/trailing_whitespaces.py
index 283e3fd..48de809 100644
--- a/pylint/test/input/func_trailing_whitespace.py
+++ b/pylint/test/functional/trailing_whitespaces.py
@@ -2,7 +2,10 @@
# pylint: disable=mixed-line-endings
from __future__ import print_function
+# +1: [trailing-whitespace]
print('some trailing whitespace')
+# +1: [trailing-whitespace]
print('trailing whitespace does not count towards the line length limit')
print('windows line ends are ok')
+# +1: [trailing-whitespace]
print('but trailing whitespace on win is not')
diff --git a/pylint/test/functional/trailing_whitespaces.txt b/pylint/test/functional/trailing_whitespaces.txt
new file mode 100644
index 0000000..38fc2c3
--- /dev/null
+++ b/pylint/test/functional/trailing_whitespaces.txt
@@ -0,0 +1,3 @@
+trailing-whitespace:6::Trailing whitespace
+trailing-whitespace:8::Trailing whitespace
+trailing-whitespace:11::Trailing whitespace
diff --git a/pylint/test/functional/unreachable.py b/pylint/test/functional/unreachable.py
new file mode 100644
index 0000000..b03dec8
--- /dev/null
+++ b/pylint/test/functional/unreachable.py
@@ -0,0 +1,22 @@
+# pylint: disable=missing-docstring
+
+from __future__ import print_function
+
+def func1():
+ return 1
+ print('unreachable') # [unreachable]
+
+def func2():
+ while 1:
+ break
+ print('unreachable') # [unreachable]
+
+def func3():
+ for i in (1, 2, 3):
+ print(i)
+ continue
+ print('unreachable') # [unreachable]
+
+def func4():
+ raise Exception
+ return 1 / 0 # [unreachable]
diff --git a/pylint/test/functional/unreachable.txt b/pylint/test/functional/unreachable.txt
new file mode 100644
index 0000000..adf0526
--- /dev/null
+++ b/pylint/test/functional/unreachable.txt
@@ -0,0 +1,4 @@
+unreachable:7:func1:Unreachable code
+unreachable:12:func2:Unreachable code
+unreachable:18:func3:Unreachable code
+unreachable:22:func4:Unreachable code \ No newline at end of file
diff --git a/pylint/test/input/func_eval_used.py b/pylint/test/input/func_eval_used.py
deleted file mode 100644
index c58b69c..0000000
--- a/pylint/test/input/func_eval_used.py
+++ /dev/null
@@ -1,13 +0,0 @@
-"""test for eval usage"""
-
-__revision__ = 0
-
-eval('os.listdir(".")')
-eval('os.listdir(".")', globals={})
-
-eval('os.listdir(".")', globals=globals())
-
-def func():
- """ eval in local scope"""
- eval('b = 1')
-
diff --git a/pylint/test/input/func_f0401.py b/pylint/test/input/func_f0401.py
deleted file mode 100644
index 66e1240..0000000
--- a/pylint/test/input/func_f0401.py
+++ /dev/null
@@ -1,9 +0,0 @@
-"""test failed import
-"""
-from __future__ import absolute_import, print_function
-__revision__ = 0
-
-def function():
- """yo"""
- from tutu import toto
- print(toto)
diff --git a/pylint/test/input/func_operators.py b/pylint/test/input/func_operators.py
deleted file mode 100644
index 48606bf..0000000
--- a/pylint/test/input/func_operators.py
+++ /dev/null
@@ -1,19 +0,0 @@
-"""check operator use"""
-#pylint: disable=C0103
-#pylint: disable=W0104
-
-__revision__ = 42
-
-a = 1
-a += 5
-a = +a
-b = ++a
-++a
-c = (++a) * b
-
-a = 1
-a -= 5
-b = --a
-b = a
---a
-c = (--a) * b
diff --git a/pylint/test/input/func_r0901.py b/pylint/test/input/func_r0901.py
deleted file mode 100644
index ac69fb6..0000000
--- a/pylint/test/input/func_r0901.py
+++ /dev/null
@@ -1,27 +0,0 @@
-# pylint: disable=W0232, R0903
-"""test max parents"""
-__revision__ = None
-
-class Aaaa(object):
- """yo"""
-class Bbbb(object):
- """yo"""
-class Cccc(object):
- """yo"""
-class Dddd(object):
- """yo"""
-class Eeee(object):
- """yo"""
-class Ffff(object):
- """yo"""
-class Gggg(object):
- """yo"""
-class Hhhh(object):
- """yo"""
-
-class Iiii(Aaaa, Bbbb, Cccc, Dddd, Eeee, Ffff, Gggg, Hhhh):
- """yo"""
-
-class Jjjj(Iiii):
- """yo"""
-
diff --git a/pylint/test/input/func_set_literal_as_default_py27.py b/pylint/test/input/func_set_literal_as_default_py27.py
deleted file mode 100644
index 1bd3f7e..0000000
--- a/pylint/test/input/func_set_literal_as_default_py27.py
+++ /dev/null
@@ -1,7 +0,0 @@
-"""docstring"""
-from __future__ import print_function
-__revision__ = ''
-
-def function1(value={1}):
- """set is mutable and dangerous."""
- print(value)
diff --git a/pylint/test/input/func_unreachable.py b/pylint/test/input/func_unreachable.py
deleted file mode 100644
index 4034e4f..0000000
--- a/pylint/test/input/func_unreachable.py
+++ /dev/null
@@ -1,21 +0,0 @@
-"""docstring"""
-from __future__ import print_function
-__revision__ = ''
-
-def func1():
- """docstring"""
- return 1
- print('unreachable')
-
-def func2():
- """docstring"""
- while 1:
- break
- print('unreachable')
-
-def func3():
- """docstring"""
- for i in (1, 2, 3):
- print(i)
- continue
- print('unreachable')
diff --git a/pylint/test/input/func_w0103.py b/pylint/test/input/func_w0103.py
deleted file mode 100644
index 04cb4c1..0000000
--- a/pylint/test/input/func_w0103.py
+++ /dev/null
@@ -1,8 +0,0 @@
-"""test max branch
-"""
-from __future__ import print_function
-__revision__ = ''
-
-def stupid_function(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9):
- """reallly stupid function"""
- print(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9)
diff --git a/pylint/test/input/func_w0110.py b/pylint/test/input/func_w0110.py
deleted file mode 100644
index c9d9311..0000000
--- a/pylint/test/input/func_w0110.py
+++ /dev/null
@@ -1,10 +0,0 @@
-"""test too short name
-"""
-
-__revision__ = 1
-
-A = None
-
-def a():
- """yo"""
- pass
diff --git a/pylint/test/input/func_w0111.py b/pylint/test/input/func_w0111.py
deleted file mode 100644
index f8ad440..0000000
--- a/pylint/test/input/func_w0111.py
+++ /dev/null
@@ -1,10 +0,0 @@
-"""test black listed name
-"""
-
-__revision__ = 1
-
-A = None
-
-def baz():
- """yo"""
- pass
diff --git a/pylint/test/input/func_w0112.py b/pylint/test/input/func_w0112.py
deleted file mode 100644
index 00f952b..0000000
--- a/pylint/test/input/func_w0112.py
+++ /dev/null
@@ -1,37 +0,0 @@
-"""test max branch
-"""
-from __future__ import print_function
-
-
-def stupid_function(arg):
- """reallly stupid function"""
- if arg == 1:
- print(1)
- elif arg == 2:
- print(2)
- elif arg == 3:
- print(3)
- elif arg == 4:
- print(4)
- elif arg == 5:
- print(5)
- elif arg == 6:
- print(6)
- elif arg == 7:
- print(7)
- elif arg == 8:
- print(8)
- elif arg == 9:
- print(9)
- elif arg == 10:
- print(10)
- else:
- if arg < 1:
- print(0)
- else:
- print(100)
- arg = 0
- if arg:
- print(None)
- else:
- print(arg)
diff --git a/pylint/test/input/func_w0151.py b/pylint/test/input/func_w0151.py
deleted file mode 100644
index e6862c5..0000000
--- a/pylint/test/input/func_w0151.py
+++ /dev/null
@@ -1,5 +0,0 @@
-"""check black listed builtins
-"""
-
-__revision__ = map(str, (1, 2, 3))
-
diff --git a/pylint/test/input/func_w0202.py b/pylint/test/input/func_w0202.py
deleted file mode 100644
index 00b5b0f..0000000
--- a/pylint/test/input/func_w0202.py
+++ /dev/null
@@ -1,17 +0,0 @@
-"""check static method with self or cls as first argument"""
-
-__revision__ = None
-
-class Abcd(object):
- """dummy"""
-
- def method1(self):
- """hehe"""
- method1 = staticmethod(method1)
-
- def method2(cls):
- """hehe"""
- method2 = staticmethod(method2)
-
- def __init__(self):
- pass
diff --git a/pylint/test/input/func_w0402.py b/pylint/test/input/func_w0402.py
index 9f7136e..fcf2fc1 100644
--- a/pylint/test/input/func_w0402.py
+++ b/pylint/test/input/func_w0402.py
@@ -2,11 +2,11 @@
"""
__revision__ = 0
# pylint: disable=no-absolute-import
-from input.func_fixme import *
+from input.indirect1 import *
# This is an unresolved import which still generates the wildcard-import
# warning.
from unknown.package import *
def abcd():
"""use imports"""
- function()
+ TotoInterface()
diff --git a/pylint/test/input/func_w0623_py_30.py b/pylint/test/input/func_w0623_py_30.py
index 2baf542..14c22a8 100644
--- a/pylint/test/input/func_w0623_py_30.py
+++ b/pylint/test/input/func_w0623_py_30.py
@@ -1,5 +1,5 @@
"""Test for W0623, overwriting names in exception handlers."""
-# pylint: disable=broad-except,bare-except,pointless-except,print-statement,no-absolute-import,duplicate-except
+# pylint: disable=broad-except,bare-except,print-statement,no-absolute-import,duplicate-except
__revision__ = ''
import exceptions
diff --git a/pylint/test/input/func_w0704.py b/pylint/test/input/func_w0704.py
deleted file mode 100644
index 524df17..0000000
--- a/pylint/test/input/func_w0704.py
+++ /dev/null
@@ -1,16 +0,0 @@
-"""test empty except
-"""
-
-__revision__ = 1
-
-try:
- __revision__ += 1
-except TypeError:
- pass
-
-try:
- __revision__ += 1
-except TypeError:
- pass
-else:
- __revision__ = None
diff --git a/pylint/test/messages/func_bad_exception_context_py30.txt b/pylint/test/messages/func_bad_exception_context_py30.txt
deleted file mode 100644
index 241195d..0000000
--- a/pylint/test/messages/func_bad_exception_context_py30.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-E: 14:test: Exception context set to something which is not an exception, nor None
-E: 17:test: Exception context set to something which is not an exception, nor None
-E: 23:test: Exception context set to something which is not an exception, nor None \ No newline at end of file
diff --git a/pylint/test/messages/func_dangerous_default.txt b/pylint/test/messages/func_dangerous_default.txt
deleted file mode 100644
index 8980b7c..0000000
--- a/pylint/test/messages/func_dangerous_default.txt
+++ /dev/null
@@ -1,13 +0,0 @@
-W: 7:function1: Dangerous default value [] as argument
-W: 11:function2: Dangerous default value HEHE (__builtin__.dict) as argument
-W: 19:function4: Dangerous default value set() (__builtin__.set) as argument
-W: 29:function6: Dangerous default value GLOBAL_SET (__builtin__.set) as argument
-W: 33:function7: Dangerous default value dict() (__builtin__.dict) as argument
-W: 37:function8: Dangerous default value list() (__builtin__.list) as argument
-W: 41:function9: Dangerous default value [] as argument
-W: 45:function10: Dangerous default value {} as argument
-W: 49:function11: Dangerous default value list() (__builtin__.list) as argument
-W: 53:function12: Dangerous default value dict() (__builtin__.dict) as argument
-W: 62:function13: Dangerous default value OINK (__builtin__.dict) as argument
-W: 66:function14: Dangerous default value dict() (__builtin__.dict) as argument
-W: 74:function15: Dangerous default value INVALID_DICT (__builtin__.dict) as argument
diff --git a/pylint/test/messages/func_dangerous_default_py30.txt b/pylint/test/messages/func_dangerous_default_py30.txt
deleted file mode 100644
index eb05c87..0000000
--- a/pylint/test/messages/func_dangerous_default_py30.txt
+++ /dev/null
@@ -1,13 +0,0 @@
-W: 7:function1: Dangerous default value [] as argument
-W: 11:function2: Dangerous default value HEHE (builtins.dict) as argument
-W: 19:function4: Dangerous default value set() (builtins.set) as argument
-W: 29:function6: Dangerous default value GLOBAL_SET (builtins.set) as argument
-W: 33:function7: Dangerous default value dict() (builtins.dict) as argument
-W: 37:function8: Dangerous default value list() (builtins.list) as argument
-W: 41:function9: Dangerous default value [] as argument
-W: 45:function10: Dangerous default value {} as argument
-W: 49:function11: Dangerous default value list() (builtins.list) as argument
-W: 53:function12: Dangerous default value dict() (builtins.dict) as argument
-W: 62:function13: Dangerous default value OINK (builtins.dict) as argument
-W: 66:function14: Dangerous default value dict() (builtins.dict) as argument
-W: 74:function15: Dangerous default value INVALID_DICT (builtins.dict) as argument
diff --git a/pylint/test/messages/func_eval_used.txt b/pylint/test/messages/func_eval_used.txt
deleted file mode 100644
index ab65307..0000000
--- a/pylint/test/messages/func_eval_used.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-W: 5: Use of eval
-W: 6: Use of eval
-W: 8: Use of eval
-W: 12:func: Use of eval \ No newline at end of file
diff --git a/pylint/test/messages/func_f0401.txt b/pylint/test/messages/func_f0401.txt
deleted file mode 100644
index 27dc386..0000000
--- a/pylint/test/messages/func_f0401.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-F: 8:function: Unable to import 'tutu'
-
diff --git a/pylint/test/messages/func_fixme.txt b/pylint/test/messages/func_fixme.txt
deleted file mode 100644
index deade52..0000000
--- a/pylint/test/messages/func_fixme.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-W: 5: FIXME: beep
-W: 11: FIXME: Valid test
-W: 13: TODO: Do something with the variables
-W: 14: XXX: Fix this later
-W: 15: FIXME: no space after hash \ No newline at end of file
diff --git a/pylint/test/messages/func_invalid_sequence_index.txt b/pylint/test/messages/func_invalid_sequence_index.txt
deleted file mode 100644
index db9edab..0000000
--- a/pylint/test/messages/func_invalid_sequence_index.txt
+++ /dev/null
@@ -1,19 +0,0 @@
-E: 13:function1: Sequence index is not an int, slice, or instance with __index__
-E: 17:function2: Sequence index is not an int, slice, or instance with __index__
-E: 21:function3: Sequence index is not an int, slice, or instance with __index__
-E: 25:function4: Sequence index is not an int, slice, or instance with __index__
-E: 33:function5: Sequence index is not an int, slice, or instance with __index__
-E: 37:function6: Sequence index is not an int, slice, or instance with __index__
-E: 41:function7: Sequence index is not an int, slice, or instance with __index__
-E: 48:function8: Sequence index is not an int, slice, or instance with __index__
-E:128:function19: Sequence index is not an int, slice, or instance with __index__
-E:133:function20: Sequence index is not an int, slice, or instance with __index__
-E:144:function21: Sequence index is not an int, slice, or instance with __index__
-E:145:function21: Sequence index is not an int, slice, or instance with __index__
-E:159:function22: Sequence index is not an int, slice, or instance with __index__
-E:160:function22: Sequence index is not an int, slice, or instance with __index__
-E:175:function23: Sequence index is not an int, slice, or instance with __index__
-E:176:function23: Sequence index is not an int, slice, or instance with __index__
-E:191:function24: Sequence index is not an int, slice, or instance with __index__
-E:192:function24: Sequence index is not an int, slice, or instance with __index__
-E:202:function25: Sequence index is not an int, slice, or instance with __index__
diff --git a/pylint/test/messages/func_method_could_be_function.txt b/pylint/test/messages/func_method_could_be_function.txt
deleted file mode 100644
index 1def89e..0000000
--- a/pylint/test/messages/func_method_could_be_function.txt
+++ /dev/null
@@ -1 +0,0 @@
-R: 16:Toto.function_method: Method could be a function
diff --git a/pylint/test/messages/func_operators.txt b/pylint/test/messages/func_operators.txt
deleted file mode 100644
index ba23690..0000000
--- a/pylint/test/messages/func_operators.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-E: 10: Use of the non-existent ++ operator
-E: 11: Use of the non-existent ++ operator
-E: 12: Use of the non-existent ++ operator
-E: 16: Use of the non-existent -- operator
-E: 18: Use of the non-existent -- operator
-E: 19: Use of the non-existent -- operator
diff --git a/pylint/test/messages/func_r0901.txt b/pylint/test/messages/func_r0901.txt
deleted file mode 100644
index 1f4007f..0000000
--- a/pylint/test/messages/func_r0901.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-R: 22:Iiii: Too many ancestors (9/7)
-R: 25:Jjjj: Too many ancestors (10/7)
diff --git a/pylint/test/messages/func_r0902.txt b/pylint/test/messages/func_r0902.txt
deleted file mode 100644
index 5dcb669..0000000
--- a/pylint/test/messages/func_r0902.txt
+++ /dev/null
@@ -1 +0,0 @@
-R: 5:Aaaa: Too many instance attributes (21/7)
diff --git a/pylint/test/messages/func_r0903.txt b/pylint/test/messages/func_r0903.txt
deleted file mode 100644
index 3ca8004..0000000
--- a/pylint/test/messages/func_r0903.txt
+++ /dev/null
@@ -1 +0,0 @@
-R: 5:Aaaa: Too few public methods (1/2)
diff --git a/pylint/test/messages/func_r0904.txt b/pylint/test/messages/func_r0904.txt
deleted file mode 100644
index 76baf72..0000000
--- a/pylint/test/messages/func_r0904.txt
+++ /dev/null
@@ -1 +0,0 @@
-R: 4:Aaaa: Too many public methods (21/20)
diff --git a/pylint/test/messages/func_r0923.txt b/pylint/test/messages/func_r0923.txt
deleted file mode 100644
index 11ee61d..0000000
--- a/pylint/test/messages/func_r0923.txt
+++ /dev/null
@@ -1 +0,0 @@
-R: 6:IAaaa: Interface not implemented
diff --git a/pylint/test/messages/func_set_literal_as_default_py27.txt b/pylint/test/messages/func_set_literal_as_default_py27.txt
deleted file mode 100644
index ba38ec4..0000000
--- a/pylint/test/messages/func_set_literal_as_default_py27.txt
+++ /dev/null
@@ -1 +0,0 @@
-W: 5:function1: Dangerous default value set() as argument
diff --git a/pylint/test/messages/func_trailing_whitespace.txt b/pylint/test/messages/func_trailing_whitespace.txt
deleted file mode 100644
index bfac360..0000000
--- a/pylint/test/messages/func_trailing_whitespace.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-C: 5: Trailing whitespace
-C: 6: Trailing whitespace
-C: 8: Trailing whitespace
diff --git a/pylint/test/messages/func_unreachable.txt b/pylint/test/messages/func_unreachable.txt
deleted file mode 100644
index bb25be0..0000000
--- a/pylint/test/messages/func_unreachable.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-W: 8:func1: Unreachable code
-W: 14:func2: Unreachable code
-W: 21:func3: Unreachable code
diff --git a/pylint/test/messages/func_w0101.txt b/pylint/test/messages/func_w0101.txt
deleted file mode 100644
index c42ec2c..0000000
--- a/pylint/test/messages/func_w0101.txt
+++ /dev/null
@@ -1 +0,0 @@
-R: 6:stupid_function: Too many return statements (11/6)
diff --git a/pylint/test/messages/func_w0102.txt b/pylint/test/messages/func_w0102.txt
deleted file mode 100644
index 40b6190..0000000
--- a/pylint/test/messages/func_w0102.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-E: 15:AAAA.method2: method already defined line 12
-E: 18:AAAA: class already defined line 5
-E: 32:func2: function already defined line 29
-E: 51:exclusive_func2: function already defined line 45
-W: 34:func2: Redefining name '__revision__' from outer scope (line 3)
diff --git a/pylint/test/messages/func_w0103.txt b/pylint/test/messages/func_w0103.txt
deleted file mode 100644
index 0d6da42..0000000
--- a/pylint/test/messages/func_w0103.txt
+++ /dev/null
@@ -1 +0,0 @@
-R: 6:stupid_function: Too many arguments (9/5)
diff --git a/pylint/test/messages/func_w0105.txt b/pylint/test/messages/func_w0105.txt
deleted file mode 100644
index d664dd4..0000000
--- a/pylint/test/messages/func_w0105.txt
+++ /dev/null
@@ -1 +0,0 @@
-R: 6:stupid_function: Too many statements (55/50)
diff --git a/pylint/test/messages/func_w0110.txt b/pylint/test/messages/func_w0110.txt
deleted file mode 100644
index b61400e..0000000
--- a/pylint/test/messages/func_w0110.txt
+++ /dev/null
@@ -1 +0,0 @@
-C: 8:a: Invalid function name "a"
diff --git a/pylint/test/messages/func_w0111.txt b/pylint/test/messages/func_w0111.txt
deleted file mode 100644
index b2d794b..0000000
--- a/pylint/test/messages/func_w0111.txt
+++ /dev/null
@@ -1 +0,0 @@
-C: 8:baz: Black listed name "baz"
diff --git a/pylint/test/messages/func_w0112.txt b/pylint/test/messages/func_w0112.txt
deleted file mode 100644
index 19b2da5..0000000
--- a/pylint/test/messages/func_w0112.txt
+++ /dev/null
@@ -1 +0,0 @@
-R: 6:stupid_function: Too many branches (15/12)
diff --git a/pylint/test/messages/func_w0151.txt b/pylint/test/messages/func_w0151.txt
deleted file mode 100644
index 9a53967..0000000
--- a/pylint/test/messages/func_w0151.txt
+++ /dev/null
@@ -1 +0,0 @@
-W: 4: Used builtin function 'map'
diff --git a/pylint/test/messages/func_w0202.txt b/pylint/test/messages/func_w0202.txt
deleted file mode 100644
index d10e5bc..0000000
--- a/pylint/test/messages/func_w0202.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-W: 8:Abcd.method1: Static method with 'self' as first argument
-W: 12:Abcd.method2: Static method with 'cls' as first argument
-
diff --git a/pylint/test/messages/func_w0402.txt b/pylint/test/messages/func_w0402.txt
index 453fc06..9f42830 100644
--- a/pylint/test/messages/func_w0402.txt
+++ b/pylint/test/messages/func_w0402.txt
@@ -1,3 +1,3 @@
F: 8: Unable to import 'unknown.package'
-W: 5: Wildcard import input.func_fixme
+W: 5: Wildcard import input.indirect1
W: 8: Wildcard import unknown.package
diff --git a/pylint/test/messages/func_w0623_py30.txt b/pylint/test/messages/func_w0623_py30.txt
index adcd208..5d78dbf 100644
--- a/pylint/test/messages/func_w0623_py30.txt
+++ b/pylint/test/messages/func_w0623_py30.txt
@@ -1,3 +1,2 @@
-W: 15:some_function: Except doesn't do anything
W: 15:some_function: Redefining name 'some_function' from outer scope (line 10) in exception handler
W: 15:some_function: Unused variable 'some_function'
diff --git a/pylint/test/messages/func_w0704.txt b/pylint/test/messages/func_w0704.txt
deleted file mode 100644
index 1eca794..0000000
--- a/pylint/test/messages/func_w0704.txt
+++ /dev/null
@@ -1 +0,0 @@
-W: 8: Except doesn't do anything
diff --git a/pylint/test/messages/func_w0705.txt b/pylint/test/messages/func_w0705.txt
index 0393a88..1cc32a7 100644
--- a/pylint/test/messages/func_w0705.txt
+++ b/pylint/test/messages/func_w0705.txt
@@ -5,11 +5,7 @@ E: 24: Bad except clauses order (NameError is an ancestor class of UnboundLocalE
E: 27: Bad except clauses order (empty except clause should always appear last)
W: 8: Catching too general exception Exception
W: 29: No exception type(s) specified
-W: 30: Except doesn't do anything
W: 31: Catching too general exception Exception
-W: 31: Except doesn't do anything
W: 38: No exception type(s) specified
W: 43: Catching too general exception Exception
-W: 43: Except doesn't do anything
W: 45: No exception type(s) specified
-W: 46: Except doesn't do anything \ No newline at end of file
diff --git a/pylint/test/messages/func_w1201.txt b/pylint/test/messages/func_w1201.txt
deleted file mode 100644
index 45a742e..0000000
--- a/pylint/test/messages/func_w1201.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-W: 12: Specify string format arguments as logging function parameters
-W: 13: Specify string format arguments as logging function parameters
-W: 14: Specify string format arguments as logging function parameters
diff --git a/pylint/test/messages/func_w1202.txt b/pylint/test/messages/func_w1202.txt
deleted file mode 100644
index eb65fbe..0000000
--- a/pylint/test/messages/func_w1202.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-W: 17: Use % formatting in logging functions but pass the % parameters as arguments
-W: 18: Use % formatting in logging functions but pass the % parameters as arguments
-W: 19: Use % formatting in logging functions but pass the % parameters as arguments
-W: 20: Use % formatting in logging functions but pass the % parameters as arguments
diff --git a/pylint/test/unittest_checker_strings.py b/pylint/test/unittest_checker_strings.py
new file mode 100644
index 0000000..eaf7663
--- /dev/null
+++ b/pylint/test/unittest_checker_strings.py
@@ -0,0 +1,41 @@
+# Copyright (c) 2003-2015 LOGILAB S.A. (Paris, FRANCE).
+# http://www.logilab.fr/ -- mailto:contact@logilab.fr
+#
+# This program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+import sys
+import unittest
+
+from astroid import test_utils
+
+from pylint.checkers import strings
+from pylint.testutils import CheckerTestCase
+
+
+class StringCheckerTest(CheckerTestCase):
+ CHECKER_CLASS = strings.StringMethodsChecker
+
+ @unittest.skipUnless(sys.version_info > (3, 0),
+ "Tests that the string formatting checker "
+ "doesn't fail when encountering a bytes "
+ "string with a .format call")
+ def test_format_bytes(self):
+ code = "b'test'.format(1, 2)"
+ node = test_utils.extract_node(code)
+ with self.assertNoMessages():
+ self.checker.visit_callfunc(node)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/pylint/utils.py b/pylint/utils.py
index f220793..c91497a 100644
--- a/pylint/utils.py
+++ b/pylint/utils.py
@@ -133,7 +133,7 @@ def category_id(cid):
def _decoding_readline(stream, module):
return lambda: stream.readline().decode(module.file_encoding,
- 'replace')
+ 'replace')
def tokenize_module(module):
@@ -818,7 +818,7 @@ class PyLintASTWalker(object):
def __init__(self, linter):
# callbacks per node types
- self.nbstatements = 1
+ self.nbstatements = 0
self.visit_events = collections.defaultdict(list)
self.leave_events = collections.defaultdict(list)
self.linter = linter
diff --git a/pylintrc b/pylintrc
index 828f88b..6ef3bed 100644
--- a/pylintrc
+++ b/pylintrc
@@ -60,7 +60,7 @@ confidence=
# --enable=similarities". If you want to run only the classes checker, but have
# no Warning level messages displayed, use"--disable=all --enable=classes
# --disable=W"
-disable=C0103,C0111,C0302,C0330,C0401,C0402,C0403,C1001,E0001,E0011,E0012,E0100,E0101,E0102,E0103,E0104,E0105,E0106,E0107,E0108,E0109,E0110,E0111,E0202,E0203,E0211,E0213,E0221,E0222,E0235,E0236,E0237,E0238,E0239,E0601,E0602,E0603,E0604,E0611,E0701,E0702,E0710,E0711,E0712,E1001,E1002,E1003,E1004,E1101,E1102,E1111,E1120,E1121,E1123,E1124,E1126,E1127,E1200,E1201,E1205,E1206,E1300,E1301,E1302,E1303,E1304,E1305,E1306,E1310,E1601,E1602,E1603,E1604,E1605,E1606,E1607,E1608,F0001,F0002,F0003,F0010,F0202,F0220,F0401,I0001,I0010,I0011,I0012,I0013,I0020,I0021,I0022,R0201,R0401,R0801,R0901,R0902,R0903,R0904,R0911,R0912,R0913,R0914,R0915,R0923,W0101,W0102,W0104,W0105,W0106,W0107,W0108,W0109,W0110,W0120,W0122,W0123,W0141,W0142,W0150,W0199,W0201,W0211,W0212,W0221,W0222,W0223,W0231,W0232,W0233,W0234,W0301,W0311,W0312,W0332,W0401,W0402,W0403,W0404,W0406,W0410,W0511,W0512,W0601,W0602,W0603,W0604,W0611,W0612,W0613,W0614,W0621,W0622,W0623,W0631,W0632,W0633,W0640,W0702,W0703,W0704,W0710,W0711,W1001,W1111,W1201,W1202,W1300,W1301,W1302,W1303,W1304,W1305,W1306,W1307,W1401,W1402,W1501,W1502,W1503,W1504,W1601,W1602,W1603,W1604,W1605,W1606,W1607,W1608,W1609,W1610,W1611,W1612,W1613,W1614,W1615,W1616,W1617,W1618,W1619,W1620,W1621,W1622,W1623,W1624,W1625,W1626,W1627,W1628,W1629,W1630,W1632,W1633,W1634,W1635,W1636,W1637,W1638,W1639
+disable=C0103,C0111,C0302,C1001,E0239,E1101,R0201,R0401,R0801,R0901,R0902,R0903,R0904,R0911,R0912,R0913,R0914,R0915,R0923,W0199,W0201,W0211,W0212,W0221,W0222,W0223,W0231,W0232,W0233,W0234,W0301,W0311,W0312,W0332,W0401,W0402,W0403,W0404,W0406,W0410,W0511,W0512,W0601,W0602,W0603,W0604,W0611,W0612,W0613,W0614,W0621,W0622,W0623,W0631,W0632,W0633,W0640,W0702,W0703,W0704,W0710,W0711,W1001,W1111,W1201,W1202,W1300,W1301,W1302,W1303,W1304,W1305,W1306,W1307,W1401,W1402,W1501,W1502,W1503,W1504,W1601,W1602,W1603,W1604,W1605W1606,W1607,W1608,W1609,W1610,W1611,W1612,W1613,W1614,W1615,W1616,W1617,W1618,W1619,W1620,W1621,W1622,W1623,W1624,W1625,W1626,W1627,W1628,W1629,W1630,W1632,W1633,W1634,W1635,W1636,W1637,W1638,W1639
[REPORTS]