Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[doc] Add an example for suppressed-message #8328

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/data/messages/s/suppressed-message/bad.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test = ["a" "b"] # pylint: disable=implicit-str-concat # [suppressed-message]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to do this with a pylintrc that enables the message and then disable it here.

The enable in the running of the tests is just additional "headspace" that gets occupied when dealing with these tests.
The fact that we had so many issues with just disabling the cleaning of messages after each file shows that neither of us (or other maintainers) fully understand all the implications of the functional test runners.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried that too (and also enable in file) but I think pylintrc is the baseline that is modified by the command line argument. Not sure if it's possible.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah, of course..

Or... A specific enable in the bad.py file? And then a disable a line later?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh wait, that's what you just said. That doesn't work?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. I tried to use disable-next to enable the suppressed message and that did not work for me

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, not sure why, I think the right order for message control should be "configuration < commande line < file directive according to scope":

$ cat a.py
# pylint: enable=invalid-name
tEsT = "apple"  # pylint: disable=invalid-name
$ pylint a.py --disable=all --enable=invalid-name,suppressed-message,astroid-error,syntax-error
************* Module a
a.py:2:0: I0020: Suppressed 'invalid-name' (from line 2) (suppressed-message)
--------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)
$ pylint a.py --disable=all --enable=suppressed-message,astroid-error,syntax-error 
--------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)

Clearly fixing the message control is a task that is not going to be tackled like a young ballerina by SΓ©bastien Chabal.

5 changes: 4 additions & 1 deletion doc/data/messages/s/suppressed-message/details.rst
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
You can help us make the doc better `by contributing <https://github.com/PyCQA/pylint/issues/5953>`_ !
``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.
2 changes: 1 addition & 1 deletion doc/data/messages/s/suppressed-message/good.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# This is a placeholder for correct code for this message.
test = ["ab"]
2 changes: 1 addition & 1 deletion doc/test_messages_documentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down