Skip to content

Commit 386e778

Browse files
DanielNoordPierre-Sassoulas
authored andcommitted
Mix incorrect parsing of multi-line options in ini files
1 parent 7cd7c8c commit 386e778

File tree

5 files changed

+13
-3
lines changed

5 files changed

+13
-3
lines changed

doc/whatsnew/2/2.14/full.rst

+4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ Release date: TBA
2727

2828
Closes #6818
2929

30+
* Fixed an issue with multi-line ``init-hook`` options which did not record the line endings.
31+
32+
Closes #6888
33+
3034
* Fixed a false positive for ``used-before-assignment`` when a try block returns
3135
but an except handler defines a name via type annotation.
3236

pylint/config/config_file_parser.py

-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ def _parse_ini_file(self, file_path: Path) -> tuple[dict[str, str], list[str]]:
5656
else:
5757
continue
5858
for opt, value in parser[section].items():
59-
value = value.replace("\n", "")
6059
config_content[opt] = value
6160
options += [f"--{opt}", value]
6261
return config_content, options

pylint/config/config_initialization.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def _config_initialization(
4545

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

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

0 commit comments

Comments
 (0)