diff --git a/saltpylint/blacklist.py b/saltpylint/blacklist.py index 3f54edd..86a5aa3 100644 --- a/saltpylint/blacklist.py +++ b/saltpylint/blacklist.py @@ -19,7 +19,6 @@ # Import pylint libs import astroid from saltpylint.checkers import BaseChecker, utils -from pylint.interfaces import IAstroidChecker BLACKLISTED_IMPORTS_MSGS = { 'E9402': ('Uses of a blacklisted module %r: %s', @@ -46,8 +45,6 @@ class BlacklistedImportsChecker(BaseChecker): - __implements__ = IAstroidChecker - name = 'blacklisted-imports' msgs = BLACKLISTED_IMPORTS_MSGS priority = -2 @@ -62,7 +59,6 @@ def open(self): 'unittest', 'unittest2') - @utils.check_messages('blacklisted-imports') def visit_import(self, node): '''triggered when an import statement is seen''' module_filename = node.root().file @@ -75,7 +71,6 @@ def visit_import(self, node): for name in names: self._check_blacklisted_module(node, name) - @utils.check_messages('blacklisted-imports') def visit_importfrom(self, node): '''triggered when a from statement is seen''' module_filename = node.root().file @@ -238,8 +233,6 @@ def _check_blacklisted_module(self, node, mod_path): class BlacklistedLoaderModulesUsageChecker(BaseChecker): - __implements__ = IAstroidChecker - name = 'blacklisted-unmocked-patching' msgs = BLACKLISTED_LOADER_USAGE_MSGS priority = -2 @@ -259,21 +252,18 @@ def close(self): self.process_module = False self.imported_salt_modules = {} - @utils.check_messages('blacklisted-unmocked-patching') def visit_module(self, node): module_filename = node.root().file if not fnmatch.fnmatch(os.path.basename(module_filename), 'test_*.py*'): return self.process_module = True - @utils.check_messages('blacklisted-unmocked-patching') def leave_module(self, node): if self.process_module: # Reset self.process_module = False self.imported_salt_modules = {} - @utils.check_messages('blacklisted-unmocked-patching') def visit_import(self, node): '''triggered when an import statement is seen''' if self.process_module: @@ -287,7 +277,6 @@ def visit_import(self, node): if module not in self.imported_salt_modules: self.imported_salt_modules[module] = module - @utils.check_messages('blacklisted-unmocked-patching') def visit_importfrom(self, node): '''triggered when a from statement is seen''' if self.process_module: @@ -301,7 +290,6 @@ def visit_importfrom(self, node): if module not in self.imported_salt_modules: self.imported_salt_modules[module] = module - @utils.check_messages('blacklisted-loader-usage') def visit_assign(self, node, *args): if not self.process_module: return @@ -363,8 +351,6 @@ def visit_assign(self, node, *args): class ResourceLeakageChecker(BaseChecker): - __implements__ = IAstroidChecker - name = 'resource-leakage' msgs = RESOURCE_LEAKAGE_MSGS priority = -2 @@ -413,8 +399,6 @@ def visit_call(self, node): class MovedTestCaseClassChecker(BaseChecker): - __implements__ = IAstroidChecker - name = 'moved-test-case-class' msgs = MOVED_TEST_CASE_CLASSES_MSGS priority = -2 @@ -425,20 +409,17 @@ def open(self): def close(self): self.process_module = False - @utils.check_messages('moved-test-case-class') def visit_module(self, node): module_filename = node.root().file if not fnmatch.fnmatch(os.path.basename(module_filename), 'test_*.py*'): return self.process_module = True - @utils.check_messages('moved-test-case-class') def leave_module(self, node): if self.process_module: # Reset self.process_module = False - @utils.check_messages('moved-test-case-class') def visit_importfrom(self, node): '''triggered when a from statement is seen''' if self.process_module: @@ -451,7 +432,6 @@ def visit_importfrom(self, node): continue self._check_moved_imports(node, module) - @utils.check_messages('moved-test-case-class') def visit_classdef(self, node): for base in node.bases: if not hasattr(base, 'attrname'): @@ -488,8 +468,6 @@ def _check_moved_imports(self, node, module, import_as=None): class BlacklistedFunctionsChecker(BaseChecker): - __implements__ = IAstroidChecker - name = 'blacklisted-functions' msgs = BLACKLISTED_FUNCTIONS_MSGS priority = -2 @@ -505,16 +483,6 @@ class BlacklistedFunctionsChecker(BaseChecker): def open(self): self.blacklisted_functions = {} - blacklist = [ - x.strip() for x in self.config.blacklisted_functions.split(',')] - for item in [x.strip() for x in - self.config.blacklisted_functions.split(',')]: - try: - key, val = [x.strip() for x in item.split('=')] - except ValueError: - pass - else: - self.blacklisted_functions[key] = val def _get_full_name(self, node): try: @@ -542,7 +510,6 @@ def _get_full_name(self, node): # full name for the function. return '.'.join(ret[::-1]) - @utils.check_messages('blacklisted-functions') def visit_call(self, node): if self.blacklisted_functions: full_name = self._get_full_name(node) diff --git a/saltpylint/fileperms.py b/saltpylint/fileperms.py index 7385d41..7ad4c57 100644 --- a/saltpylint/fileperms.py +++ b/saltpylint/fileperms.py @@ -20,7 +20,6 @@ import stat # Import PyLint libs -from pylint.interfaces import IRawChecker from saltpylint.checkers import BaseChecker @@ -29,8 +28,6 @@ class FilePermsChecker(BaseChecker): Check for files with undesirable permissions ''' - __implements__ = IRawChecker - name = 'fileperms' msgs = {'E0599': ('Module file has the wrong file permissions(expected %s): %s', 'file-perms', diff --git a/saltpylint/minpyver.py b/saltpylint/minpyver.py index 94b37e6..eb8ee26 100644 --- a/saltpylint/minpyver.py +++ b/saltpylint/minpyver.py @@ -18,7 +18,6 @@ import sys # Import PyLint libs -from pylint.interfaces import IRawChecker from saltpylint.checkers import BaseChecker # Import 3rd-party libs @@ -40,8 +39,6 @@ class MininumPythonVersionChecker(BaseChecker): Check the minimal required python version ''' - __implements__ = IRawChecker - name = 'mininum-python-version' msgs = {'E0598': ('Incompatible Python %s code found: %s', 'minimum-python-version', diff --git a/saltpylint/pep263.py b/saltpylint/pep263.py index 407f0d2..0b9ae00 100644 --- a/saltpylint/pep263.py +++ b/saltpylint/pep263.py @@ -16,7 +16,6 @@ import itertools # Import PyLint libs -from pylint.interfaces import IRawChecker from saltpylint.checkers import BaseChecker # Import 3rd-party libs @@ -28,8 +27,6 @@ class FileEncodingChecker(BaseChecker): Check for PEP263 compliant file encoding in file. ''' - __implements__ = IRawChecker - name = 'pep263' msgs = {'W9901': ('PEP263: Multiple file encodings', 'multiple-encoding-in-file', diff --git a/saltpylint/pep8.py b/saltpylint/pep8.py index 82e51ec..6498a2b 100644 --- a/saltpylint/pep8.py +++ b/saltpylint/pep8.py @@ -25,7 +25,6 @@ import six # Import PyLint libs -from pylint.interfaces import IRawChecker from pylint.__pkginfo__ import numversion as pylint_version_info from saltpylint.checkers import BaseChecker @@ -64,8 +63,6 @@ def error(self, line_number, offset, text, check): class _PEP8BaseChecker(BaseChecker): - __implements__ = IRawChecker - name = 'pep8' priority = -1 diff --git a/saltpylint/py3modernize/__init__.py b/saltpylint/py3modernize/__init__.py index 53674fe..5ec39fc 100644 --- a/saltpylint/py3modernize/__init__.py +++ b/saltpylint/py3modernize/__init__.py @@ -20,7 +20,6 @@ ) # Import PyLint libs -from pylint.interfaces import IRawChecker from saltpylint.checkers import BaseChecker if HAS_REQUIRED_LIBS: @@ -95,8 +94,6 @@ class Py3Modernize(BaseChecker): Check for PEP263 compliant file encoding in file. ''' - __implements__ = IRawChecker - name = 'modernize' msgs = {'W1698': ('Unable to run modernize. Parse Error: %s', 'modernize-parse-error', diff --git a/saltpylint/strings.py b/saltpylint/strings.py index a58d78d..495df28 100644 --- a/saltpylint/strings.py +++ b/saltpylint/strings.py @@ -25,13 +25,6 @@ from saltpylint.checkers import BaseChecker, utils from pylint.checkers import BaseTokenChecker -try: - # >= pylint 1.0 - from pylint.interfaces import IAstroidChecker -except ImportError: # < pylint 1.0 - from pylint.interfaces import IASTNGChecker as IAstroidChecker # pylint: disable=no-name-in-module - -from pylint.interfaces import ITokenChecker, IRawChecker from astroid.exceptions import InferenceError try: from astroid.exceptions import NameInferenceError @@ -71,8 +64,6 @@ class NameInferenceError(Exception): class StringCurlyBracesFormatIndexChecker(BaseChecker): - __implements__ = IAstroidChecker - name = 'string' msgs = STRING_FORMAT_MSGS priority = -1 @@ -93,11 +84,7 @@ class StringCurlyBracesFormatIndexChecker(BaseChecker): ), ) - @utils.check_messages(*(STRING_FORMAT_MSGS.keys())) def visit_binop(self, node): - if not self.config.enforce_string_formatting_over_substitution: - return - if node.op != '%': return @@ -112,10 +99,7 @@ def visit_binop(self, node): return if required_keys or required_num_args: - if self.config.string_substitutions_usage_is_an_error: - msgid = 'E1321' - else: - msgid = 'W1321' + msgid = 'W1321' self.add_message( msgid, node=node.left, args=node.left.value ) @@ -125,7 +109,6 @@ def visit_binop(self, node): 'E1322', node=node.left, args=node.left.value ) - @utils.check_messages(*(STRING_FORMAT_MSGS.keys())) def visit_call(self, node): func = utils.safe_infer(node.func) if isinstance(func, astroid.BoundMethod) and func.name == 'format': @@ -151,8 +134,7 @@ def visit_call(self, node): ) if BAD_FORMATTING_SLOT.findall(inferred.value): - if self.config.un_indexed_curly_braces_always_error or \ - sys.version_info[:2] < (2, 7): + if sys.version_info[:2] < (2, 7): self.add_message( 'E1320', node=inferred, args=inferred.value ) @@ -212,7 +194,6 @@ class StringLiteralChecker(BaseTokenChecker): ''' Check string literals ''' - __implements__ = (ITokenChecker, IRawChecker) name = 'string_literal' msgs = STRING_LITERALS_MSGS diff --git a/saltpylint/thirdparty.py b/saltpylint/thirdparty.py index e88a304..07fce9b 100644 --- a/saltpylint/thirdparty.py +++ b/saltpylint/thirdparty.py @@ -22,7 +22,6 @@ import astroid.exceptions import pkgutil from astroid.modutils import is_relative, is_standard_module -from pylint.interfaces import IAstroidChecker from saltpylint.checkers import BaseChecker, utils MSGS = { @@ -49,8 +48,6 @@ def get_import_package(modname): class ThirdPartyImportsChecker(BaseChecker): - __implements__ = IAstroidChecker - name = '3rd-party-imports' msgs = MSGS priority = -2 @@ -83,46 +80,37 @@ def __init__(self, linter=None): self._inside_try_except = False self._inside_funcdef = False self._inside_if = False - self.cwd = self.allowed_3rd_party_modules = None + self.cwd = self.allowed_3rd_party_modules = [] def open(self): super(ThirdPartyImportsChecker, self).open() self.cwd = os.getcwd() - self.allowed_3rd_party_modules = set(self.config.allowed_3rd_party_modules) # pylint: disable=no-member # pylint: disable=unused-argument - @utils.check_messages('3rd-party-imports') def visit_if(self, node): self._inside_if = True - @utils.check_messages('3rd-party-imports') def leave_if(self, node): self._inside_if = True - @utils.check_messages('3rd-party-imports') def visit_tryexcept(self, node): self._inside_try_except = True - @utils.check_messages('3rd-party-imports') def leave_tryexcept(self, node): self._inside_try_except = False - @utils.check_messages('3rd-party-imports') def visit_functiondef(self, node): self._inside_funcdef = True - @utils.check_messages('3rd-party-imports') def leave_functiondef(self, node): self._inside_funcdef = False # pylint: enable=unused-argument - @utils.check_messages('3rd-party-imports') def visit_import(self, node): names = [name for name, _ in node.names] for name in names: self._check_third_party_import(node, name) - @utils.check_messages('3rd-party-imports') def visit_importfrom(self, node): self._check_third_party_import(node, node.modname)