Skip to content

Commit 621effb

Browse files
[bad-option-value] Use old_names to decrease message type to warning
1 parent d98b0ee commit 621effb

22 files changed

+46
-35
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# disable=missnig-docstring # [unknown-option-value]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# disable=missing-docstring

doc/user_guide/messages/messages_overview.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ All messages in the error category:
5858
error/bad-except-order
5959
error/bad-exception-context
6060
error/bad-format-character
61-
error/bad-option-value
6261
error/bad-plugin-value
6362
error/bad-reversed-sequence
6463
error/bad-str-strip-call
@@ -178,6 +177,7 @@ All renamed messages in the error category:
178177
:titlesonly:
179178

180179
error/bad-context-manager
180+
error/bad-option-value
181181
error/maybe-no-member
182182
error/old-non-iterator-returned-2
183183
error/old-unbalanced-tuple-unpacking
@@ -306,6 +306,7 @@ All messages in the warning category:
306306
warning/try-except-raise
307307
warning/unbalanced-tuple-unpacking
308308
warning/undefined-loop-variable
309+
warning/unknown-option-value
309310
warning/unnecessary-ellipsis
310311
warning/unnecessary-lambda
311312
warning/unnecessary-pass

doc/whatsnew/2/2.14/full.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@ Release date: TBA
3131

3232
Closes #6624
3333

34-
* Deleted messages that do not exist anymore in pylint now raise ``useless-option-value`` instead of ``bad-option-value``,
35-
which permit to distinguish between genuine typos and old configuration that could be cleaned.
34+
* ``bad-option-value`` (E0012) is now a warning ``unknown-option-value`` (W0012). Deleted messages that do not exist
35+
anymore in pylint now raise ``useless-option-value`` (I0012) instead of ``bad-option-value``. This permit to
36+
distinguish between genuine typos and old configuration that could be cleaned. Existing message control for
37+
``bad-option-value`` will still work on both new messages.
3638

3739
Refs #6794
3840

pylint/config/callback_actions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ def _call(
384384
].append((option_string, str(e)))
385385
except exceptions.UnknownMessageError:
386386
self.linter._stashed_messages[
387-
(self.linter.current_name, "bad-option-value")
387+
(self.linter.current_name, "unknown-option-value")
388388
].append((option_string, msgid))
389389

390390
@abc.abstractmethod

pylint/lint/message_state_handler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ def process_tokens(self, tokens: list[tokenize.TokenInfo]) -> None:
419419
)
420420
except exceptions.UnknownMessageError:
421421
self.linter.add_message(
422-
"bad-option-value",
422+
"unknown-option-value",
423423
args=(pragma_repr.action, msgid),
424424
line=start[0],
425425
confidence=HIGH,

pylint/lint/pylinter.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -193,18 +193,24 @@ def _load_reporter_by_class(reporter_class: str) -> type[BaseReporter]:
193193
"Used when an unknown inline option is encountered.",
194194
{"scope": WarningScope.LINE},
195195
),
196-
"E0012": (
197-
"Bad option value for '%s', expected a valid pylint message and got '%s'",
198-
"bad-option-value",
199-
"Used when a bad value for an option is encountered.",
200-
{"scope": WarningScope.LINE},
196+
"W0012": (
197+
"Unknown option value for '%s', expected a valid pylint message and got '%s'",
198+
"unknown-option-value",
199+
"Used when an unknown value is encountered for an option.",
200+
{
201+
"scope": WarningScope.LINE,
202+
"old_names": [("E0012", "bad-option-value")],
203+
},
201204
),
202205
"I0012": (
203206
"Useless option value for '%s', %s",
204207
"useless-option-value",
205208
"Used when a value for an option that is now deleted from pylint"
206209
" is encountered.",
207-
{"scope": WarningScope.LINE},
210+
{
211+
"scope": WarningScope.LINE,
212+
"old_names": [("E0012", "bad-option-value")],
213+
},
208214
),
209215
"E0013": (
210216
"Plugin '%s' is impossible to load, is it installed ? ('%s')",

tests/config/functional/ini/pylintrc_with_missing_comma.2.out

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
************* Module {abspath}
2+
{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)

tests/config/functional/setup_cfg/do_not_read_other_tools_configuration/setup.2.out

Lines changed: 0 additions & 2 deletions
This file was deleted.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
************* Module {abspath}
2+
{relpath}:1:0: W0012: Unknown option value for '--enable', expected a valid pylint message and got 'useless-supression' (unknown-option-value)

tests/config/functional/toml/issue_3122/toml_with_missing_comma.2.out

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
************* Module {abspath}
2+
{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)

tests/config/functional/toml/unknown_msgid/enable_unknown_msgid.2.out

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
************* Module {abspath}
2+
{relpath}:1:0: W0012: Unknown option value for '--disable', expected a valid pylint message and got 'logging-not-layzy' (unknown-option-value)
3+
{relpath}:1:0: W0012: Unknown option value for '--enable', expected a valid pylint message and got 'C00000' (unknown-option-value)

tests/config/test_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def test_unknown_message_id(capsys: CaptureFixture) -> None:
6060
"""Check that we correctly raise a message on an unknown id."""
6161
Run([str(EMPTY_MODULE), "--disable=12345"], exit=False)
6262
output = capsys.readouterr()
63-
assert "Command line:1:0: E0012: Bad option value for '--disable'" in output.out
63+
assert "Command line:1:0: W0012: Unknown option value for '--disable'" in output.out
6464

6565

6666
def test_unknown_option_name(capsys: CaptureFixture) -> None:

tests/functional/b/bad_option_value.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
"""Check unknown or deleted option. """
22

33
# Standard disable with unknown value
4-
# pylint: disable=C05048 # [bad-option-value]
4+
# pylint: disable=C05048 # [unknown-option-value]
55
# Standard disable with deleted symbol
66
# pylint: disable=execfile-builtin # [useless-option-value]
77
# Standard disable with deleted msgid
88
# pylint: disable=W1656 # [useless-option-value]
99
# disable-next with unknown value
10-
# pylint: disable-next=R78948 # [bad-option-value]
10+
# pylint: disable-next=R78948 # [unknown-option-value]
1111
# disable-next with deleted symbol
1212
# pylint: disable-next=deprecated-types-field # [useless-option-value]
1313
# disable-next with deleted msgid
1414
# pylint: disable-next=W1634 # [useless-option-value]
1515

1616
# enable with unknown value
17-
# pylint:enable=W04044 # [bad-option-value]
17+
# pylint:enable=W04044 # [unknown-option-value]
1818
# enable with deleted symbol
1919
# pylint:enable=dict-values-not-iterating # [useless-option-value]
2020
# enable with deleted msgid

tests/functional/b/bad_option_value.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
bad-option-value:4:0:None:None::Bad option value for 'disable', expected a valid pylint message and got 'C05048':HIGH
1+
unknown-option-value:4:0:None:None::Unknown option value for 'disable', expected a valid pylint message and got 'C05048':HIGH
22
useless-option-value:6:0:None:None::"Useless option value for 'disable', 'execfile-builtin' was removed from pylint, see https://github.com/PyCQA/pylint/pull/4942.":HIGH
33
useless-option-value:8:0:None:None::"Useless option value for 'disable', 'W1656' was removed from pylint, see https://github.com/PyCQA/pylint/pull/4942.":HIGH
4-
bad-option-value:10:0:None:None::Bad option value for 'disable-next', expected a valid pylint message and got 'R78948':HIGH
4+
unknown-option-value:10:0:None:None::Unknown option value for 'disable-next', expected a valid pylint message and got 'R78948':HIGH
55
useless-option-value:12:0:None:None::"Useless option value for 'disable-next', 'deprecated-types-field' was removed from pylint, see https://github.com/PyCQA/pylint/pull/4942.":HIGH
66
useless-option-value:14:0:None:None::"Useless option value for 'disable-next', 'W1634' was removed from pylint, see https://github.com/PyCQA/pylint/pull/4942.":HIGH
7-
bad-option-value:17:0:None:None::Bad option value for 'enable', expected a valid pylint message and got 'W04044':HIGH
7+
unknown-option-value:17:0:None:None::Unknown option value for 'enable', expected a valid pylint message and got 'W04044':HIGH
88
useless-option-value:19:0:None:None::"Useless option value for 'enable', 'dict-values-not-iterating' was removed from pylint, see https://github.com/PyCQA/pylint/pull/4942.":HIGH
99
useless-option-value:21:0:None:None::"Useless option value for 'enable', 'W1622' was removed from pylint, see https://github.com/PyCQA/pylint/pull/4942.":HIGH
1010
useless-option-value:24:0:None:None::"Useless option value for 'disable', 'no-space-after-operator' was removed from pylint, see https://github.com/PyCQA/pylint/pull/3577.":HIGH

tests/functional/b/bad_option_value_disable.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
# pylint: enable=bad-option-value
99

10-
var = 1 # pylint: disable=a-removed-option # [bad-option-value]
10+
var = 1 # pylint: disable=a-removed-option # [unknown-option-value]
1111

1212
# bad-option-value needs to be disabled before the bad option
13-
var = 1 # pylint: disable=a-removed-option, bad-option-value # [bad-option-value]
13+
var = 1 # pylint: disable=a-removed-option, bad-option-value # [unknown-option-value]
1414
var = 1 # pylint: disable=bad-option-value, a-removed-option
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
bad-option-value:10:0:None:None::Bad option value for 'disable', expected a valid pylint message and got 'a-removed-option':HIGH
2-
bad-option-value:13:0:None:None::Bad option value for 'disable', expected a valid pylint message and got 'a-removed-option':HIGH
1+
unknown-option-value:10:0:None:None::Unknown option value for 'disable', expected a valid pylint message and got 'a-removed-option':HIGH
2+
unknown-option-value:13:0:None:None::Unknown option value for 'disable', expected a valid pylint message and got 'a-removed-option':HIGH

tests/functional/u/use/use_symbolic_message_instead.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# pylint: disable=C0111,R0903,T1234 # [bad-option-value,use-symbolic-message-instead,use-symbolic-message-instead]
1+
# pylint: disable=C0111,R0903,T1234 # [unknown-option-value,use-symbolic-message-instead,use-symbolic-message-instead]
22
# pylint: enable=c0111,w0223 # [use-symbolic-message-instead,use-symbolic-message-instead]
33

44
def my_function(arg): # [missing-function-docstring]

tests/functional/u/use/use_symbolic_message_instead.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
bad-option-value:1:0:None:None::Bad option value for 'disable', expected a valid pylint message and got 'T1234':HIGH
1+
unknown-option-value:1:0:None:None::Unknown option value for 'disable', expected a valid pylint message and got 'T1234':HIGH
22
use-symbolic-message-instead:1:0:None:None::"'C0111' is cryptic: use '# pylint: disable=missing-docstring' instead":UNDEFINED
33
use-symbolic-message-instead:1:0:None:None::"'R0903' is cryptic: use '# pylint: disable=too-few-public-methods' instead":UNDEFINED
44
use-symbolic-message-instead:2:0:None:None::"'c0111' is cryptic: use '# pylint: enable=missing-docstring' instead":UNDEFINED

0 commit comments

Comments
 (0)