Skip to content

Commit

Permalink
Mix incorrect parsing of multi-line options in ini files
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielNoord authored and Pierre-Sassoulas committed Jun 15, 2022
1 parent 7cd7c8c commit 386e778
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 3 deletions.
4 changes: 4 additions & 0 deletions doc/whatsnew/2/2.14/full.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ Release date: TBA

Closes #6818

* Fixed an issue with multi-line ``init-hook`` options which did not record the line endings.

Closes #6888

* Fixed a false positive for ``used-before-assignment`` when a try block returns
but an except handler defines a name via type annotation.

Expand Down
1 change: 0 additions & 1 deletion pylint/config/config_file_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ def _parse_ini_file(self, file_path: Path) -> tuple[dict[str, str], list[str]]:
else:
continue
for opt, value in parser[section].items():
value = value.replace("\n", "")
config_content[opt] = value
options += [f"--{opt}", value]
return config_content, options
Expand Down
2 changes: 1 addition & 1 deletion pylint/config/config_initialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def _config_initialization(

# Run init hook, if present, before loading plugins
if "init-hook" in config_data:
exec(utils._unquote(config_data["init-hook"])) # pylint: disable=exec-used
exec(config_data["init-hook"]) # pylint: disable=exec-used

# Load plugins if specified in the config file
if "load-plugins" in config_data:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
************* Module {abspath}
{relpath}:1:0: W0012: Unknown option value for '--disable', expected a valid pylint message and got 'logging-not-lazylogging-format-interpolation' (unknown-option-value)
{relpath}:1:0: W0012: Unknown option value for '--enable', expected a valid pylint message and got 'locally-disabledsuppressed-message' (unknown-option-value)
{relpath}:1:0: W0012: Unknown option value for '--enable', expected a valid pylint message and got 'locally-disabled
suppressed-message' (unknown-option-value)
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Reported in https://github.com/PyCQA/pylint/issues/6888
[MASTER]
init-hook=
try: import pylint_venv
except ImportError: pass
else: pylint_venv.inithook()

0 comments on commit 386e778

Please sign in to comment.