summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--doc/FAQ.txt16
-rw-r--r--doc/manual.txt6
-rw-r--r--doc/quickstart.txt7
-rw-r--r--lint.py28
-rw-r--r--test/input/func_i0013.py2
-rw-r--r--test/input/func_i0014.py8
-rw-r--r--test/messages/func_i0014.txt2
-rw-r--r--utils.py5
9 files changed, 67 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index c46bf4a..e7821de 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -38,6 +38,9 @@ ChangeLog for PyLint
* stop including tests files in distribution, they causes crash when
installed with python3 (#72022, #82417, #76910)
+ * add support for --disable=all option (#105327)
+
+ * deprecate the 'disable-all' inline directive in favour of 'skip-file'
2012-07-17 -- 0.25.2
* #93591: Correctly emit warnings about clobbered variable names when an
diff --git a/doc/FAQ.txt b/doc/FAQ.txt
index 992190a..e61549a 100644
--- a/doc/FAQ.txt
+++ b/doc/FAQ.txt
@@ -252,13 +252,27 @@ No, starting from 0.25.3, you can use symbolic names for messages::
You can show these symbols in the output with the `-sy` option.
+4.7 How can I tell Pylint to never check a given module?
+--------------------------------------------------------
+
+With pylint < 0.25, add "#pylint: disable-all" at the beginning of the
+module. Pylint 0.26.1 and up have renamed that directive to
+"#pylint: skip-file" (but the first version will be kept for backward
+compatibility).
+
+In order to ease finding which modules are ignored a Information-level
+message I0013 is emited. With recent versions of Pylint, if you use
+the old syntax, an additional I0014 message is emited.
+
+
+
5. Classes and Inheritance
==========================
5.1 When is pylint considering a class as an interface?
-------------------------------------------------------
-A class is considered as an interface if there is a class named "Interface"
+A class is considered as an interface if there is a class named "Interface"
somewhere in its inheritance tree.
5.2 When is pylint considering that a class is implementing a given interface?
diff --git a/doc/manual.txt b/doc/manual.txt
index 98f6065..3bb049f 100644
--- a/doc/manual.txt
+++ b/doc/manual.txt
@@ -286,6 +286,10 @@ description of provided checkers with their functionalities.
The ``--disable`` and ``--enable`` options can be used with comma separated lists
mixing checkers, message ids and categories like ``-d C,W,E0611,design``
+It is possible to disable all messages with ``--disable=all``. This is
+useful to enable only a few checkers or a few messages by first
+disabling everything, and then re-enabling only what you need.
+
Each checker has some specific options, which can take either a yes/no
value, an integer, a python regular expression, or a comma separated
list of values (which are generally used to override a regular
@@ -324,7 +328,7 @@ What pylint says is not to be taken as gospel. While getting as
few false positives for errors as possible is a goal for us -- and
python makes it hard enough, it is not the case for warnings.
-:Quoting Alexandre:
+:Quoting Alexandre Fayolle:
My usage pattern for pylint is to generally run pylint -e quite often to
get stupid errors flagged before launching an application (or before
committing). I generally run pylint with all the bells and whistles
diff --git a/doc/quickstart.txt b/doc/quickstart.txt
index c320348..a50989e 100644
--- a/doc/quickstart.txt
+++ b/doc/quickstart.txt
@@ -163,9 +163,10 @@ First of all, we have two basic (but useful) options.
Pylint is architectured around several checkers. By default all
checkers are enabled. You can disable a specific checker or some of its
messages or messages categories by specifying
-``--disable=<id>``. A more general disable can be enabled with
-or disable all checkers using
-``--enable=w<id>``. See the list of available features_ for a
+``--disable=<id>``. If you want to enable only some checkers or some
+message ids, first use ``--disable=all`` then
+``--enable=<id>`` with <id> being a comma separated list of checker
+names and message identifiers. See the list of available features_ for a
description of provided checkers with their functionalities.
The ``--disable`` and ``--enable`` options can be used with comma separated lists
mixing checkers, message ids and categories like ``-d C,W,E0611,design``
diff --git a/lint.py b/lint.py
index b8225a6..bb07091 100644
--- a/lint.py
+++ b/lint.py
@@ -126,6 +126,11 @@ MSGS = {
'I0013': ('Ignoring entire file',
'file-ignored',
'Used to inform that the file will not be checked'),
+ 'I0014': ('Used deprecated directive "pylint:disable-all" or "pylint:disable=all"',
+ 'deprecated-disable-all',
+ 'You should preferably use "pylint:skip-file" as this directive '
+ 'has a less confusing name. Do this only if you are sure that all '
+ 'people running Pylint on your code have version >= 0.26'),
'E0001': ('%s',
@@ -240,7 +245,8 @@ This is used by the global evaluation report (RP0004).'}),
'group': 'Messages control',
'help' : 'Enable the message, report, category or checker with the '
'given id(s). You can either give multiple identifier '
- 'separated by comma (,) or put this option multiple time.'}),
+ 'separated by comma (,) or put this option multiple time. '
+ 'See also the "--disable" option for examples. '}),
('disable',
{'type' : 'csv', 'metavar': '<msg ids>',
@@ -250,7 +256,14 @@ This is used by the global evaluation report (RP0004).'}),
'with the given id(s). You can either give multiple identifier'
' separated by comma (,) or put this option multiple time '
'(only on the command line, not in the configuration file '
- 'where it should appear only once).'}),
+ 'where it should appear only once).'
+ 'You can also use "--disable=all" to disable everything first '
+ 'and then reenable specific checks. For example, if you want '
+ 'to run only the similarities checker, you can use '
+ '"--disable=all --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"'}),
)
option_groups = (
@@ -410,7 +423,9 @@ This is used by the global evaluation report (RP0004).'}),
match = OPTION_RGX.search(line)
if match is None:
continue
- if match.group(1).strip() == "disable-all":
+ if match.group(1).strip() == "disable-all" or match.group(1).strip() == 'skip-file':
+ if match.group(1).strip() == "disable-all":
+ self.add_message('I0014', line=start[0])
self.add_message('I0013', line=start[0])
self._ignore_file = True
return
@@ -426,11 +441,16 @@ This is used by the global evaluation report (RP0004).'}),
meth = self._options_methods[opt]
except KeyError:
meth = self._bw_options_methods[opt]
- warn('%s is deprecated, replace it by %s (%s, line %s)' % (
+ warn('%s is deprecated, replace it with %s (%s, line %s)' % (
opt, opt.split('-')[0], self.current_file, line),
DeprecationWarning)
for msgid in splitstrip(value):
try:
+ if (opt, msgid) == ('disable', 'all'):
+ self.add_message('I0014', line=start[0])
+ self.add_message('I0013', line=start[0])
+ self._ignore_file = True
+ return
meth(msgid, 'module', start[0])
except UnknownMessage:
self.add_message('E0012', args=msgid, line=start[0])
diff --git a/test/input/func_i0013.py b/test/input/func_i0013.py
index 63ff37c..0a3f833 100644
--- a/test/input/func_i0013.py
+++ b/test/input/func_i0013.py
@@ -1,4 +1,4 @@
-# pylint: disable-all
+# pylint: skip-file
"""disable-all is usable as an inline option"""
# no warning should be issued
diff --git a/test/input/func_i0014.py b/test/input/func_i0014.py
new file mode 100644
index 0000000..63ff37c
--- /dev/null
+++ b/test/input/func_i0014.py
@@ -0,0 +1,8 @@
+# pylint: disable-all
+"""disable-all is usable as an inline option"""
+
+# no warning should be issued
+try:
+ import this
+except:
+ pass
diff --git a/test/messages/func_i0014.txt b/test/messages/func_i0014.txt
new file mode 100644
index 0000000..d179cd1
--- /dev/null
+++ b/test/messages/func_i0014.txt
@@ -0,0 +1,2 @@
+I: 1: Ignoring entire file
+I: 1: Used deprecated directive "pylint:disable-all" or "pylint:disable=all"
diff --git a/utils.py b/utils.py
index 5661d76..32ad4e9 100644
--- a/utils.py
+++ b/utils.py
@@ -172,6 +172,11 @@ class MessagesHandlerMixIn:
def disable(self, msgid, scope='package', line=None):
"""don't output message of the given id"""
assert scope in ('package', 'module')
+ # handle disable=all by disabling all categories
+ if msgid == 'all':
+ for msgid in MSG_TYPES:
+ self.disable(msgid, scope, line)
+ return
# msgid is a category?
catid = category_id(msgid)
if catid is not None: