From cc68ba79329e75d68f842f4ce0bb83601936097d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Noord?= <13665637+DanielNoord@users.noreply.github.com> Date: Mon, 19 Sep 2022 13:09:05 +0200 Subject: [PATCH 1/3] Accept a comma-separated list of messages IDs in ``--help-msg`` --- doc/whatsnew/fragments/7471.bugfix | 3 +++ pylint/config/callback_actions.py | 2 ++ tests/test_self.py | 1 + 3 files changed, 6 insertions(+) create mode 100644 doc/whatsnew/fragments/7471.bugfix diff --git a/doc/whatsnew/fragments/7471.bugfix b/doc/whatsnew/fragments/7471.bugfix new file mode 100644 index 0000000000..b1b6f369c9 --- /dev/null +++ b/doc/whatsnew/fragments/7471.bugfix @@ -0,0 +1,3 @@ +``--help-msg`` now accepts a comma-separated list of message IDs again. + +Closes #7471 diff --git a/pylint/config/callback_actions.py b/pylint/config/callback_actions.py index e2a6017e91..d8b8b3624a 100644 --- a/pylint/config/callback_actions.py +++ b/pylint/config/callback_actions.py @@ -158,6 +158,8 @@ def __call__( option_string: str | None = "--help-msg", ) -> None: assert isinstance(values, (list, tuple)) + assert isinstance(values[0], str) + values = values[0].split(",") self.run.linter.msgs_store.help_message(values) sys.exit(0) diff --git a/tests/test_self.py b/tests/test_self.py index 292a4b95de..d5167cfe67 100644 --- a/tests/test_self.py +++ b/tests/test_self.py @@ -1229,6 +1229,7 @@ def test_output_of_callback_options( [["--help-msg", "W0101"], ":unreachable (W0101)", False], [["--help-msg", "WX101"], "No such message id", False], [["--help-msg"], "--help-msg: expected at least one argumen", True], + [["--help-msg", "C0102,C0103"], ":invalid-name (C0103):", False], ], ) def test_help_msg( From 2bc6c10311d6d6f370cc40ec67ba2c32c7cb2703 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Noord?= <13665637+DanielNoord@users.noreply.github.com> Date: Mon, 19 Sep 2022 13:28:19 +0200 Subject: [PATCH 2/3] Fix --- pylint/config/callback_actions.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pylint/config/callback_actions.py b/pylint/config/callback_actions.py index d8b8b3624a..4d52ae870b 100644 --- a/pylint/config/callback_actions.py +++ b/pylint/config/callback_actions.py @@ -158,9 +158,11 @@ def __call__( option_string: str | None = "--help-msg", ) -> None: assert isinstance(values, (list, tuple)) - assert isinstance(values[0], str) - values = values[0].split(",") - self.run.linter.msgs_store.help_message(values) + values_to_print: list[str] = [] + for msg in values: + assert isinstance(msg, str) + values_to_print += msg.split(",") + self.run.linter.msgs_store.help_message(values_to_print) sys.exit(0) From 35a5a6f2ff4b010da00a2e40536fa1a144932951 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Noord?= <13665637+DanielNoord@users.noreply.github.com> Date: Mon, 19 Sep 2022 13:29:58 +0200 Subject: [PATCH 3/3] Fix --- pylint/config/callback_actions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pylint/config/callback_actions.py b/pylint/config/callback_actions.py index 4d52ae870b..a4c6334641 100644 --- a/pylint/config/callback_actions.py +++ b/pylint/config/callback_actions.py @@ -161,7 +161,7 @@ def __call__( values_to_print: list[str] = [] for msg in values: assert isinstance(msg, str) - values_to_print += msg.split(",") + values_to_print += utils._check_csv(msg) self.run.linter.msgs_store.help_message(values_to_print) sys.exit(0)