Skip to content

Commit 9706473

Browse files
[refactor] Change the name of the stashed messages list in PyLinter
1 parent 0b41dfc commit 9706473

File tree

4 files changed

+16
-17
lines changed

4 files changed

+16
-17
lines changed

pylint/config/callback_actions.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -381,9 +381,9 @@ def __call__(
381381
try:
382382
self.linter.disable(msgid)
383383
except exceptions.UnknownMessageError:
384-
self.linter._stashed_bad_option_value_messages[
385-
self.linter.current_name
386-
].append((option_string, msgid))
384+
self.linter._stashed_messages[self.linter.current_name].append(
385+
(option_string, msgid)
386+
)
387387

388388

389389
class _EnableAction(_AccessLinterObjectAction):
@@ -402,9 +402,9 @@ def __call__(
402402
try:
403403
self.linter.enable(msgid)
404404
except exceptions.UnknownMessageError:
405-
self.linter._stashed_bad_option_value_messages[
406-
self.linter.current_name
407-
].append((option_string, msgid))
405+
self.linter._stashed_messages[self.linter.current_name].append(
406+
(option_string, msgid)
407+
)
408408

409409

410410
class _OutputFormatAction(_AccessLinterObjectAction):

pylint/config/config_initialization.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def _config_initialization(
9191
"unrecognized-option", args=unrecognized_options_message, line=0
9292
)
9393

94-
linter._emit_bad_option_value()
94+
linter._emit_stashed_messages()
9595

9696
# Set the current module to configuration as we don't know where
9797
# the --load-plugins key is coming from

pylint/lint/message_state_handler.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,14 @@ def __init__(self, linter: PyLinter) -> None:
5656
}
5757
self._pragma_lineno: dict[str, int] = {}
5858
# TODO: 3.0: Update key type to str when current_name is always str
59-
self._stashed_bad_option_value_messages: defaultdict[
59+
self._stashed_messages: defaultdict[
6060
str | None, list[tuple[str | None, str]]
6161
] = defaultdict(list)
62-
"""Bad option values for --enable and --disable are encountered too early to
63-
warn about them, i.e. before all option providers have been fully parsed.
62+
"""Some messages in the options (for --enable and --disable) are encountered
63+
too early to warn about them.
6464
65-
Thus,
66-
this dict stores option_value and msg_id needed to (later) emit the
67-
bad-option-value messages keyed on module names.
65+
i.e. before all option providers have been fully parsed. Thus, this dict stores
66+
option_value and msg_id needed to (later) emit the messages keyed on module names.
6867
"""
6968

7069
def _set_one_msg_status(

pylint/lint/pylinter.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1202,15 +1202,15 @@ def add_ignored_message(
12021202
line,
12031203
)
12041204

1205-
def _emit_bad_option_value(self) -> None:
1206-
for modname in self._stashed_bad_option_value_messages:
1205+
def _emit_stashed_messages(self) -> None:
1206+
for modname in self._stashed_messages:
12071207
self.linter.set_current_module(modname)
1208-
values = self._stashed_bad_option_value_messages[modname]
1208+
values = self._stashed_messages[modname]
12091209
for option_string, msg_id in values:
12101210
self.add_message(
12111211
"bad-option-value",
12121212
args=(option_string, msg_id),
12131213
line=0,
12141214
confidence=HIGH,
12151215
)
1216-
self._stashed_bad_option_value_messages = collections.defaultdict(list)
1216+
self._stashed_messages = collections.defaultdict(list)

0 commit comments

Comments
 (0)