Hello,

I was not quite sure of the status of the 0.26 release wrt to this patch, so the documentation mentions 0.26.1 as the release in which the new disabling option becomes available. It can be easily changed if required.

This patch can also be pulled from https://bitbucket.org/agurney/pylint if things are easier for you that way.

--
Alexandre

 ChangeLog                    |   3 +++
 doc/FAQ.txt                  |  16 +++++++++++++++-
 doc/manual.txt               |   6 +++++-
 doc/quickstart.txt           |   7 ++++---
 lint.py                      |  28 ++++++++++++++++++++++++----
 test/input/func_i0013.py     |   2 +-
 test/input/func_i0014.py     |   8 ++++++++
 test/messages/func_i0014.txt |   2 ++
 utils.py                     |   5 +++++
 9 files changed, 67 insertions(+), 10 deletions(-)


# HG changeset patch
# User Alexandre Fayolle <afayolle...@free.fr>
# Date 1349241828 -7200
# Node ID 68ba9225985eb4f072b9b04abd9d8f71a37ee00a
# Parent  b4988c29949e1acc397bef6be73ed7d0d8e7d0f3
add support for --disable=all option (closes: #105327)

updated the documentation accordingly
deprecate 'disable-all' as an inline directive in favor of 'skip-file'

diff --git a/ChangeLog b/ChangeLog
--- a/ChangeLog
+++ b/ChangeLog
@@ -36,10 +36,13 @@ ChangeLog for PyLint
     * fix cross-interpreter issue (non compatible access to __builtins__)
      * 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
       except handler contains a tuple of names instead of a single name.
       (patch by tma...@google.com)
diff --git a/doc/FAQ.txt b/doc/FAQ.txt
--- a/doc/FAQ.txt
+++ b/doc/FAQ.txt
@@ -250,17 +250,31 @@ No, starting from 0.25.3, you can use sy
      # pylint: disable=fixme, line-too-long
  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
--- a/doc/manual.txt
+++ b/doc/manual.txt
@@ -284,10 +284,14 @@ or disable all checkers using
 ``--enable=w<id>``. 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``
 +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
 expression in special cases). For a full list of options, use ``--help``
 @@ -322,11 +326,11 @@ Daily pylint usage
 ------------------
 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
   activated some time before a release, when I want to cleanup the code.
   And when I do that I simply ignore tons of the false warnings (and I
diff --git a/doc/quickstart.txt b/doc/quickstart.txt
--- a/doc/quickstart.txt
+++ b/doc/quickstart.txt
@@ -161,13 +161,14 @@ First of all, we have two basic (but use
 -h, --help            show help about the command line 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``
  Each checker has some specific options, which can take either a yes/no
diff --git a/lint.py b/lint.py
--- a/lint.py
+++ b/lint.py
@@ -124,10 +124,15 @@ MSGS = {
'Used when an inline option enables a message or a messages \
               category.'),
     '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',
               'syntax-error',
               'Used when a syntax error is raised for a module.'),
@@ -238,21 +243,29 @@ This is used by the global evaluation re
                  {'type' : 'csv', 'metavar': '<msg ids>',
                   'short': 'e',
                   '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>',
                   'short': 'd',
                   'group': 'Messages control',
'help' : 'Disable 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 ' '(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 = (
         ('Messages control', 'Options controling analysis messages'),
         ('Reports', 'Options related to output formating and reporting'),
@@ -408,11 +421,13 @@ This is used by the global evaluation re
             if tok_type not in (comment, newline):
                 continue
             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
             try:
                 opt, value = match.group(1).split('=', 1)
@@ -424,15 +439,20 @@ This is used by the global evaluation re
if opt in self._options_methods or opt in self._bw_options_methods:
                 try:
                     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])
             else:
                 self.add_message('E0011', args=opt, line=start[0])
diff --git a/test/input/func_i0013.py b/test/input/func_i0013.py
--- a/test/input/func_i0013.py
+++ b/test/input/func_i0013.py
@@ -1,6 +1,6 @@
-# pylint: disable-all
+# pylint: skip-file
 """disable-all is usable as an inline option"""
  # no warning should be issued
 try:
     import this
diff --git a/test/input/func_i0014.py b/test/input/func_i0014.py
new file mode 100644
--- /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
--- /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
--- a/utils.py
+++ b/utils.py
@@ -170,10 +170,15 @@ class MessagesHandlerMixIn:
         return ':%s%s:\n%s' % (msg.msgid, symbol_part, desc)
      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:
             for _msgid in self._msgs_by_category.get(catid):
                 self.disable(_msgid, scope, line)

# HG changeset patch
# User Alexandre Fayolle <afayolle...@free.fr>
# Date 1349241828 -7200
# Node ID 68ba9225985eb4f072b9b04abd9d8f71a37ee00a
# Parent  b4988c29949e1acc397bef6be73ed7d0d8e7d0f3
add support for --disable=all option (closes: #105327)

updated the documentation accordingly
deprecate 'disable-all' as an inline directive in favor of 'skip-file'

diff --git a/ChangeLog b/ChangeLog
--- a/ChangeLog
+++ b/ChangeLog
@@ -36,10 +36,13 @@ ChangeLog for PyLint
     * fix cross-interpreter issue (non compatible access to __builtins__)
 
     * 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
       except handler contains a tuple of names instead of a single name.
       (patch by tma...@google.com)
diff --git a/doc/FAQ.txt b/doc/FAQ.txt
--- a/doc/FAQ.txt
+++ b/doc/FAQ.txt
@@ -250,17 +250,31 @@ No, starting from 0.25.3, you can use sy
 
     # pylint: disable=fixme, line-too-long
 
 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
--- a/doc/manual.txt
+++ b/doc/manual.txt
@@ -284,10 +284,14 @@ or disable all checkers using
 ``--enable=w<id>``. 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``
 
+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
 expression in special cases). For a full list of options, use ``--help``
 
@@ -322,11 +326,11 @@ Daily pylint usage
 ------------------
 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
   activated some time before a release, when I want to cleanup the code.
   And when I do that I simply ignore tons of the false warnings (and I
diff --git a/doc/quickstart.txt b/doc/quickstart.txt
--- a/doc/quickstart.txt
+++ b/doc/quickstart.txt
@@ -161,13 +161,14 @@ First of all, we have two basic (but use
 -h, --help            show help about the command line 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``
 
 Each checker has some specific options, which can take either a yes/no
diff --git a/lint.py b/lint.py
--- a/lint.py
+++ b/lint.py
@@ -124,10 +124,15 @@ MSGS = {
               'Used when an inline option enables a message or a messages \
               category.'),
     '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',
               'syntax-error',
               'Used when a syntax error is raised for a module.'),
@@ -238,21 +243,29 @@ This is used by the global evaluation re
                  {'type' : 'csv', 'metavar': '<msg ids>',
                   'short': 'e',
                   '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>',
                   'short': 'd',
                   'group': 'Messages control',
                   'help' : 'Disable 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 '
                   '(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 = (
         ('Messages control', 'Options controling analysis messages'),
         ('Reports', 'Options related to output formating and reporting'),
@@ -408,11 +421,13 @@ This is used by the global evaluation re
             if tok_type not in (comment, newline):
                 continue
             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
             try:
                 opt, value = match.group(1).split('=', 1)
@@ -424,15 +439,20 @@ This is used by the global evaluation re
             if opt in self._options_methods or opt in self._bw_options_methods:
                 try:
                     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])
             else:
                 self.add_message('E0011', args=opt, line=start[0])
diff --git a/test/input/func_i0013.py b/test/input/func_i0013.py
--- a/test/input/func_i0013.py
+++ b/test/input/func_i0013.py
@@ -1,6 +1,6 @@
-# pylint: disable-all
+# pylint: skip-file
 """disable-all is usable as an inline option"""
 
 # no warning should be issued
 try:
     import this
diff --git a/test/input/func_i0014.py b/test/input/func_i0014.py
new file mode 100644
--- /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
--- /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
--- a/utils.py
+++ b/utils.py
@@ -170,10 +170,15 @@ class MessagesHandlerMixIn:
         return ':%s%s:\n%s' % (msg.msgid, symbol_part, desc)
 
     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:
             for _msgid in self._msgs_by_category.get(catid):
                 self.disable(_msgid, scope, line)

_______________________________________________
Python-Projects mailing list
Python-Projects@lists.logilab.org
http://lists.logilab.org/mailman/listinfo/python-projects

Reply via email to