From bf2ee31f956447fa42ae85dc69820405eda8c490 Mon Sep 17 00:00:00 2001 From: "Chris St. Pierre" Date: Mon, 9 Dec 2013 07:16:53 -0500 Subject: testsuite: made pylint tests at least kinda work with pylint 1.0 They still don't pass, partially due to what appear to be bugs in pylint and partially due to a few new things that pylint is checking for in 1.0, but we don't use pylint 1.0 in travis-ci so i'm not terribly worried about that right now. --- testsuite/ext/exception_messages.py | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/testsuite/ext/exception_messages.py b/testsuite/ext/exception_messages.py index 877ba42a1..cd3d7112c 100644 --- a/testsuite/ext/exception_messages.py +++ b/testsuite/ext/exception_messages.py @@ -1,16 +1,30 @@ -from logilab import astng -from pylint.interfaces import IASTNGChecker +try: + from logilab import astng as ast + from pylint.interfaces import IASTNGChecker as IChecker + PYLINT = 0 # pylint 0.something +except ImportError: + import astroid as ast + from pylint.interfaces import IAstroidChecker as IChecker + PYLINT = 1 # pylint 1.something from pylint.checkers import BaseChecker from pylint.checkers.utils import safe_infer +if PYLINT == 0: + # this is not quite correct; later versions of pylint 0.* wanted a + # three-tuple for messages as well + msg = ('Exception raised without arguments', + 'Used when an exception is raised without any arguments') +else: + msg = ('Exception raised without arguments', + 'exception-without-args', + 'Used when an exception is raised without any arguments') +msgs = {'R9901': msg} + class ExceptionMessageChecker(BaseChecker): - __implements__ = IASTNGChecker + __implements__ = IChecker name = 'Exception Messages' - msgs = \ - {'R9901': ('Exception raised without arguments', - 'Used when an exception is raised without any arguments')} options = ( ('exceptions-without-args', dict(default=('NotImplementedError',), @@ -23,9 +37,9 @@ class ExceptionMessageChecker(BaseChecker): def visit_raise(self, node): if node.exc is None: return - if isinstance(node.exc, astng.Name): + if isinstance(node.exc, ast.Name): raised = safe_infer(node.exc) - if (isinstance(raised, astng.Class) and + if (isinstance(raised, ast.Class) and raised.name not in self.config.exceptions_without_args): self.add_message('R9901', node=node.exc) -- cgit v1.2.3-1-g7c22