pylint: Allow disable-all to be specified inline From: Daniel Drake Can be used as: # pylint: disable-all Index: pylint-0.12.2/lint.py =================================================================== --- pylint-0.12.2.orig/lint.py +++ pylint-0.12.2/lint.py @@ -96,6 +96,8 @@ be used inside modules.'), 'I0012': ('Locally enabling %s', 'Used when an inline option enable a message or a messages \ category.'), + 'I0013': ('Ignoring entire file', + 'Used to inform that the file will not be checked'), 'E0001': ('%s', 'Used when a syntax error is raised for a module.'), @@ -244,6 +246,7 @@ This is used by the global evaluation re self.reporter = None self.manager = ASTNGManager() self._checkers = {} + self._ignore_file = False # visit variables self.base_name = None self.base_file = None @@ -388,6 +391,10 @@ This is used by the global evaluation re match = OPTION_RGX.search(line) if match is None: continue + if match.group(1).strip() == "disable-all": + self.add_message('I0013', line=start[0]) + self._ignore_file = True + return try: opt, value = match.group(1).split('=', 1) except ValueError: @@ -492,6 +499,7 @@ This is used by the global evaluation re self.base_name = modname self.base_file = normpath(filepath) # check this module + self._ignore_file = False astng = self._check_file(filepath, modname, checkers) if astng is None: return @@ -516,7 +524,8 @@ This is used by the global evaluation re # if its actually a c extension self.current_file = astng.file # and check it - self.check_astng_module(astng, checkers) + if not self.check_astng_module(astng, checkers): + astng = None return astng def set_current_module(self, modname, filepath=None): @@ -564,6 +573,8 @@ This is used by the global evaluation re # invoke IRawChecker interface on self to fetch module/block # level options self.process_module(stream) + if self._ignore_file: + return False # walk ast to collect line numbers orig_state = self._module_msgs_state.copy() self._module_msgs_state = {} @@ -576,6 +587,7 @@ This is used by the global evaluation re # generate events to astng checkers self.astng_events(astng, [checker for checker in checkers if implements(checker, IASTNGChecker)]) + return True def astng_events(self, astng, checkers, _reversed_checkers=None): """generate event to astng checkers according to the current astng Index: pylint-0.12.2/test/input/func_i0010.py =================================================================== --- pylint-0.12.2.orig/test/input/func_i0010.py +++ pylint-0.12.2/test/input/func_i0010.py @@ -1,3 +1,3 @@ -# pylint: disable-all -"""disable-all is not usable as an inline option""" +# pylint: errors-only +"""errors-only is not usable as an inline option""" __revision__ = None Index: pylint-0.12.2/test/messages/func_i0010.txt =================================================================== --- pylint-0.12.2.orig/test/messages/func_i0010.txt +++ pylint-0.12.2/test/messages/func_i0010.txt @@ -1 +1 @@ -I: 1: Unable to consider inline option 'disable-all' +I: 1: Unable to consider inline option 'errors-only'