From ed7328ba4af4c53fc9ce9a66172d251dc26be2a0 Mon Sep 17 00:00:00 2001 From: carlio Date: Sun, 4 Jan 2015 09:58:04 +0100 Subject: [PATCH 1/2] Adding configuration changes and code comments to reduce the number of warnings generated by prospector --- .prospector.yml | 5 +++++ prospector/autodetect.py | 2 +- prospector/blender_combinations.yaml | 8 ++++++++ prospector/config/__init__.py | 6 +++++- prospector/finder.py | 4 ++++ prospector/formatters/pylint.py | 3 ++- prospector/tools/pyflakes/__init__.py | 4 ++-- 7 files changed, 27 insertions(+), 5 deletions(-) diff --git a/.prospector.yml b/.prospector.yml index 95882507..2012c202 100644 --- a/.prospector.yml +++ b/.prospector.yml @@ -28,9 +28,14 @@ pyroma: run: true pylint: + disable: + - W0141 + - R0903 options: max-line-length: 120 pep8: + disable: + - E126 options: max-line-length: 120 diff --git a/prospector/autodetect.py b/prospector/autodetect.py index be6a8a28..08fbec95 100644 --- a/prospector/autodetect.py +++ b/prospector/autodetect.py @@ -94,7 +94,7 @@ def find_from_path(path): try: encoding = determine_pyfile_encoding(item_path, default='utf8') with codecs.open(item_path, encoding=encoding) as fip: - names |= find_from_imports(fip.read()) + names |= find_from_imports(fip.read()) except UnicodeDecodeError as err: # this warning is issued: (1) in determine_pyfile_encoding for # badly authored files (contains non-utf8 in a comment line), or diff --git a/prospector/blender_combinations.yaml b/prospector/blender_combinations.yaml index 9b1f4d9f..2bb9c513 100644 --- a/prospector/blender_combinations.yaml +++ b/prospector/blender_combinations.yaml @@ -180,3 +180,11 @@ combinations: - # pep8-naming incorrectly suggests that the first argument of a metaclass __new__ method should be 'cls' - pylint: C0204 - pep8: N804 + + - # class names should be camelcase + - pep8: N801 + - pylint: C0103 + + - # too complex + - mccabe: MC0001 + - pylint: R0912 \ No newline at end of file diff --git a/prospector/config/__init__.py b/prospector/config/__init__.py index 0a2bb89f..336aacee 100644 --- a/prospector/config/__init__.py +++ b/prospector/config/__init__.py @@ -9,6 +9,10 @@ class ProspectorConfig(object): + # There are several methods on this class which could technically + # be functions (they don't use the 'self' argument) but that would + # make this module/class a bit ugly. + # pylint:disable=no-self-use def __init__(self): self.config, self.arguments = self._configure_prospector() @@ -92,7 +96,7 @@ def _get_profile(self, path, config): ) for possible_profile in poss_profs: - prospector_yaml = os.path.join(path, *possible_profile) + prospector_yaml = os.path.join(path, *possible_profile) # pylint:disable=star-args if os.path.exists(prospector_yaml) and os.path.isfile(prospector_yaml): profile_provided = True profile_names.append(prospector_yaml) diff --git a/prospector/finder.py b/prospector/finder.py index d9561fcf..bc46ff11 100644 --- a/prospector/finder.py +++ b/prospector/finder.py @@ -8,6 +8,10 @@ class SingleFiles(object): then we'll use this object instead of the FoundFiles to give all the functionality needed to check a single file. """ + # The 'even if ignored' parameters are kept to show this is meant + # to be API compatible with FoundFiles, but pylint will warn, so + # let's disable + # pylint:disable=unused-argument def __init__(self, files, rootpath): self.files = files self.rootpath = rootpath diff --git a/prospector/formatters/pylint.py b/prospector/formatters/pylint.py index f531ce27..fa0f3fe0 100644 --- a/prospector/formatters/pylint.py +++ b/prospector/formatters/pylint.py @@ -24,7 +24,8 @@ def render(self, summary=True, messages=True): output.append(header) # ={path}:{line}: [{msg_id}({symbol}), {obj}] {msg} - # prospector/configuration.py:65: [C0111(missing-docstring), build_default_sources] Missing function docstring + # prospector/configuration.py:65: [C0111(missing-docstring), build_default_sources] \ + # Missing function docstring template = '%(path)s:%(line)s: [%(code)s(%(source)s), %(function)s] %(message)s' output.append(template % { diff --git a/prospector/tools/pyflakes/__init__.py b/prospector/tools/pyflakes/__init__.py index b64f2359..59d12eea 100644 --- a/prospector/tools/pyflakes/__init__.py +++ b/prospector/tools/pyflakes/__init__.py @@ -63,7 +63,7 @@ def record_message( ) self._messages.append(message) - def unexpectedError(self, filename, msg): + def unexpectedError(self, filename, msg): # noqa self.record_message( filename=filename, code='FL9997', @@ -71,7 +71,7 @@ def unexpectedError(self, filename, msg): ) # pylint: disable=R0913 - def syntaxError(self, filename, msg, lineno, offset, text): + def syntaxError(self, filename, msg, lineno, offset, text): # noqa self.record_message( filename=filename, line=lineno, From e0877c40a05eb2679dcbcfa340ac14621af7318c Mon Sep 17 00:00:00 2001 From: carlio Date: Sun, 4 Jan 2015 10:13:02 +0100 Subject: [PATCH 2/2] Further comments to disable warnings on various lines --- prospector/config/__init__.py | 5 ++++- prospector/tools/frosted/__init__.py | 1 + prospector/tools/pylint/__init__.py | 6 +++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/prospector/config/__init__.py b/prospector/config/__init__.py index 336aacee..35fbd2f6 100644 --- a/prospector/config/__init__.py +++ b/prospector/config/__init__.py @@ -12,7 +12,9 @@ class ProspectorConfig(object): # There are several methods on this class which could technically # be functions (they don't use the 'self' argument) but that would # make this module/class a bit ugly. - # pylint:disable=no-self-use + # Also the 'too many instance attributes' warning is ignored, as this + # is a config object and its sole purpose is to hold many properties! + # pylint:disable=no-self-use,too-many-instance-attributes def __init__(self): self.config, self.arguments = self._configure_prospector() @@ -29,6 +31,7 @@ def __init__(self): self.libraries = self._find_used_libraries(self.config) self.tools_to_run = self._determine_tool_runners(self.config, self.profile) self.ignores = self._determine_ignores(self.config, self.profile, self.libraries) + self.configured_by = {} def get_tools(self, found_files): self.configured_by = {} diff --git a/prospector/tools/frosted/__init__.py b/prospector/tools/frosted/__init__.py index 42505f93..f5b65bc9 100644 --- a/prospector/tools/frosted/__init__.py +++ b/prospector/tools/frosted/__init__.py @@ -88,6 +88,7 @@ def run(self, found_files): try: check_path(filepath, reporter) except UnicodeDecodeError: + # pylint:disable=pointless-except pass return reporter.get_messages() diff --git a/prospector/tools/pylint/__init__.py b/prospector/tools/pylint/__init__.py index 0e20893c..0a41a5a1 100644 --- a/prospector/tools/pylint/__init__.py +++ b/prospector/tools/pylint/__init__.py @@ -28,7 +28,7 @@ def flush(self): pass -class stdout_wrapper(object): +class stdout_wrapper(object): # noqa def __init__(self, hide_stdout): self.hide_stdout = hide_stdout @@ -47,6 +47,10 @@ def __exit__(self, exc_type, exc_val, exc_tb): class PylintTool(ToolBase): + # There are several methods on this class which could technically + # be functions (they don't use the 'self' argument) but that would + # make this module/class a bit ugly. + # pylint:disable=no-self-use def __init__(self): self._args = self._extra_sys_path = None