Skip to content

Commit

Permalink
[#227 #492] Fixing loading of external pylint configuration to append…
Browse files Browse the repository at this point in the history
… rather than replace prospector profile configuration
  • Loading branch information
carlio committed Feb 28, 2022
1 parent 9889095 commit f1590d3
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 18 deletions.
15 changes: 14 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
#########
Changelog
#########
this here

Version 1.7.4
-------------

Mea culpa release

**Fix**

The effort to allow pylint configuration in ``pyproject.toml`` to be used as an external config source (issue here <https://github.com/PyCQA/prospector/issues/485>)`_ had the unintended side effect where any project using poetry would now use that configuration and thus would ignore the pylint configuration in the profile. This was true even if the ``pyproject.toml`` had no pylint directives in it.

The behaviour has now been fixed where pylint will be configured using configuration from the profile *first* and then if any additional settings are found in a ``pylintrc`` or ``pyproject.toml`` or ``setup.cfg`` then these will override the profile configuration, instead of replacing it entirely.

This also has the benefit of fixing `#277 <https://github.com/PyCQA/prospector/issues/227>`_.

Version 1.7.3
-------------

Expand Down
25 changes: 9 additions & 16 deletions prospector/tools/pylint/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ def __init__(self):

def _prospector_configure(self, prospector_config, linter):
errors = []
linter.load_default_plugins()

if "django" in prospector_config.libraries:
linter.load_plugin_modules(["pylint_django"])
Expand Down Expand Up @@ -90,7 +89,6 @@ def _error_message(self, filepath, message):

def _pylintrc_configure(self, pylintrc, linter):
errors = []
linter.load_default_plugins()
are_plugins_loaded = linter.config_from_file(pylintrc)
if not are_plugins_loaded and hasattr(linter.config, "load_plugins"):
for plugin in linter.config.load_plugins:
Expand All @@ -102,7 +100,6 @@ def _pylintrc_configure(self, pylintrc, linter):

def configure(self, prospector_config, found_files):

config_messages = []
extra_sys_path = found_files.get_minimal_syspath()

check_paths = self._get_pylint_check_paths(found_files)
Expand All @@ -112,11 +109,8 @@ def configure(self, prospector_config, found_files):

linter = ProspectorLinter(found_files)

ext_found = False
configured_by = None

config_messages, configured_by = self._get_pylint_configuration(
check_paths, config_messages, configured_by, ext_found, linter, prospector_config, pylint_options
check_paths, linter, prospector_config, pylint_options
)

# we don't want similarity reports right now
Expand Down Expand Up @@ -170,9 +164,13 @@ def _get_pylint_check_paths(self, found_files):
check_paths = [found_files.to_absolute_path(p) for p in check_paths]
return check_paths

def _get_pylint_configuration(
self, check_paths, config_messages, configured_by, ext_found, linter, prospector_config, pylint_options
):
def _get_pylint_configuration(self, check_paths, linter, prospector_config, pylint_options):
self._args = linter.load_command_line_configuration(check_paths)
linter.load_default_plugins()

config_messages = self._prospector_configure(prospector_config, linter)
configured_by = None

if prospector_config.use_external_config("pylint"):
# try to find a .pylintrc
pylintrc = pylint_options.get("config_file")
Expand All @@ -191,13 +189,8 @@ def _get_pylint_configuration(
if pylintrc is not None:
# load it!
configured_by = pylintrc
ext_found = True

self._args = linter.load_command_line_configuration(check_paths)
config_messages += self._pylintrc_configure(pylintrc, linter)
if not ext_found:
self._args = linter.load_command_line_configuration(check_paths)
config_messages = self._prospector_configure(prospector_config, linter)

return config_messages, configured_by

def _combine_w0614(self, messages):
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "prospector"
version = "1.7.3"
version = "1.7.4"
description = ""
authors = ["Carl Crowder <git@carlcrowder.com>"]
maintainers = ["Carl Crowder <git@carlcrowder.com>",
Expand Down

0 comments on commit f1590d3

Please sign in to comment.