-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
useless-suppression false positive with ungrouped-imports #2366
Comments
Thanks, I can reproduce this bug. While |
So this particular check as a quit early conditional before adding the message: if not self.linter.is_message_enabled('ungrouped-imports', import_node.fromlineno):
continue Removing the line fixes the issue. Do we want to remove these guards to allow |
This is still an issue with
on Python 3.8.2. I believe my example code is functionally identical to the OP's: """False-positive useless-suppression."""
# pylint: enable=useless-suppression
from numpy import array
from pandas import DataFrame
if True and True:
from numpy import zeros # pylint:disable=ungrouped-imports
print(array, DataFrame, zeros) This code gives
If you remove
|
Fixes pylint properly and avoids pylint-dev/pylint#2366
Please know that the example in #2366 (comment) is functionally different because according to #4212 (comment), the |
Major changes: - Return None in mount_single_layer function when something goes wrong. Do a check for the target_dir string existing before passing it on for analysis. - Return None for DriverManager try-except calls when there is a NoMatches exception. This modifies all instantiations of Stevedore's DriverManager class. - Iterate over the dictionary using .items() rather than just the plain dictionary. - Use "with" to open files and subprocess pipes. This may result in certain errors not being raised, but it is hard to know at this point. Minor changes: - Used the "maxsplit" argument in __main__.py as we only need the first item. - Used [] rather than list() to initialize lists. - Specify encoding as 'utf-8' when opening files. - Update re-raises to explicitly state which exception they are re-raising from using "from". - Use "enumerate" for looping through list's index while throwing out the unused value. - Suppressed the "useless-suppression" message along with "too-many-branches" suppression due to pylint bug: pylint-dev/pylint#2366 - Wraped some lines that were too long, except in the HTML format file due to the need to keep the literal HTML formatting. - Updated the year on some modified files. Signed-off-by: Nisha K <nishak@vmware.com>
Major changes: - Return None in mount_single_layer function when something goes wrong. Do a check for the target_dir string existing before passing it on for analysis. - Return None for DriverManager try-except calls when there is a NoMatches exception. This modifies all instantiations of Stevedore's DriverManager class. - Iterate over the dictionary using .items() rather than just the plain dictionary. - Use "with" to open files and subprocess pipes. This may result in certain errors not being raised, but it is hard to know at this point. Minor changes: - Used the "maxsplit" argument in __main__.py as we only need the first item. - Used [] rather than list() to initialize lists. - Specify encoding as 'utf-8' when opening files. - Update re-raises to explicitly state which exception they are re-raising from using "from". - Use "enumerate" for looping through list's index while throwing out the unused value. - Suppressed the "useless-suppression" message along with "too-many-branches" suppression due to pylint bug: pylint-dev/pylint#2366 - Wraped some lines that were too long, except in the HTML format file due to the need to keep the literal HTML formatting. - Updated the year on some modified files. Signed-off-by: Nisha K <nishak@vmware.com>
This also adds a new method to ``MessagesHandlerMixIn`` which adds messages to the list of the ignored messages without doing anything else. This will be useful for some other ``useless-suppression`` false positives. This closes pylint-dev#2366
This also adds a new method to ``MessagesHandlerMixIn`` which adds messages to the list of the ignored messages without doing anything else. This can be used to avoid ``useless-suppression`` false positives. This closes #2366
Steps to reproduce
Run pylint on the following code:
Current behavior
This message is issued:
However, if the comment is removed from line 4, this message is issued:
Expected behavior
Since there is an actual message being suppressed, I would expect to get no
useless-suppression
message.pylint --version output
The text was updated successfully, but these errors were encountered: