From eec147d459569e2b6baa479083508a7639fcd1a9 Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Wed, 22 Feb 2023 21:02:02 +0100 Subject: [PATCH 1/2] [doc] Add an example for suppressed-message The message would not be triggered if implicit-str-concat is not activated too. I initially wanted to activate invalid-name so we follow pep8 in our examples but there's more than 50 violations right now. So 'implicit-str-concat' it is. --- doc/data/messages/s/suppressed-message/bad.py | 1 + doc/data/messages/s/suppressed-message/details.rst | 5 ++++- doc/data/messages/s/suppressed-message/good.py | 2 +- doc/test_messages_documentation.py | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 doc/data/messages/s/suppressed-message/bad.py diff --git a/doc/data/messages/s/suppressed-message/bad.py b/doc/data/messages/s/suppressed-message/bad.py new file mode 100644 index 0000000000..028d5164f9 --- /dev/null +++ b/doc/data/messages/s/suppressed-message/bad.py @@ -0,0 +1 @@ +test = ["a" "b"] # pylint: disable=implicit-str-concat # [suppressed-message] diff --git a/doc/data/messages/s/suppressed-message/details.rst b/doc/data/messages/s/suppressed-message/details.rst index ab82045295..ceb0ba72cf 100644 --- a/doc/data/messages/s/suppressed-message/details.rst +++ b/doc/data/messages/s/suppressed-message/details.rst @@ -1 +1,4 @@ -You can help us make the doc better `by contributing `_ ! +``suppressed-message`` is simply a way to see messages that would be raised +without the disable in your codebase. It should not be activated most +of the time. See also ``useless-suppression`` if you want to see the message +that are disabled for no reasons. diff --git a/doc/data/messages/s/suppressed-message/good.py b/doc/data/messages/s/suppressed-message/good.py index c40beb573f..707721a39d 100644 --- a/doc/data/messages/s/suppressed-message/good.py +++ b/doc/data/messages/s/suppressed-message/good.py @@ -1 +1 @@ -# This is a placeholder for correct code for this message. +test = ["ab"] diff --git a/doc/test_messages_documentation.py b/doc/test_messages_documentation.py index 80e44c4a28..e8bcef78fe 100644 --- a/doc/test_messages_documentation.py +++ b/doc/test_messages_documentation.py @@ -106,7 +106,7 @@ def __init__(self, test_file: tuple[str, Path]) -> None: args = [ str(full_path), "--disable=all", - f"--enable=F,{msgid},astroid-error,syntax-error", + f"--enable=F,implicit-str-concat,{msgid},astroid-error,syntax-error", ] print(f"Command used:\npylint {' '.join(args)}") _config_initialization( From 573be0060658623f9cfdfc12321f64b1029da70c Mon Sep 17 00:00:00 2001 From: Daniel van Noord <13665637+DanielNoord@users.noreply.github.com> Date: Wed, 22 Feb 2023 23:12:29 +0100 Subject: [PATCH 2/2] Add another example --- doc/data/messages/s/suppressed-message/bad.py | 10 +++++++++- doc/data/messages/s/suppressed-message/good.py | 2 +- doc/test_messages_documentation.py | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/doc/data/messages/s/suppressed-message/bad.py b/doc/data/messages/s/suppressed-message/bad.py index 028d5164f9..5b4c437acf 100644 --- a/doc/data/messages/s/suppressed-message/bad.py +++ b/doc/data/messages/s/suppressed-message/bad.py @@ -1 +1,9 @@ -test = ["a" "b"] # pylint: disable=implicit-str-concat # [suppressed-message] +### This is a contrived example, to show how suppressed-message works. +### First we enable all messages +# pylint: enable=all + +### Here we disable two messages so we get two warnings +# pylint: disable=locally-disabled, useless-suppression # [suppressed-message, suppressed-message] + +### Here we disable a message, so we get a warning for suppressed-message again. +"A" # pylint: disable=pointless-statement # [suppressed-message, suppressed-message] diff --git a/doc/data/messages/s/suppressed-message/good.py b/doc/data/messages/s/suppressed-message/good.py index 707721a39d..39c3624803 100644 --- a/doc/data/messages/s/suppressed-message/good.py +++ b/doc/data/messages/s/suppressed-message/good.py @@ -1 +1 @@ -test = ["ab"] +"""Instead of a single string somewhere in the file, write a module docstring!""" diff --git a/doc/test_messages_documentation.py b/doc/test_messages_documentation.py index e8bcef78fe..80e44c4a28 100644 --- a/doc/test_messages_documentation.py +++ b/doc/test_messages_documentation.py @@ -106,7 +106,7 @@ def __init__(self, test_file: tuple[str, Path]) -> None: args = [ str(full_path), "--disable=all", - f"--enable=F,implicit-str-concat,{msgid},astroid-error,syntax-error", + f"--enable=F,{msgid},astroid-error,syntax-error", ] print(f"Command used:\npylint {' '.join(args)}") _config_initialization(