Open vapier opened 2 years ago
Thank you for opening the issue, I can reproduce with 2.14.0-dev0:
************* Module a
a.py:3:0: W0611: Unused Iterator imported from typing (unused-import)
a.py:10:0: I0021: Useless suppression of 'unused-import' (useless-suppression)
You should disable on line 3 instead but being able to disable on the specific line would be a nice enhancement.
there are a couple of workarounds, but none are ideal
putting it before the import line turns it off for the entire file after that point (since these comments operate on scope) and requires manual turning off with # pylint: enable=unused-import
after the import line. that also disables it for all the imports on that line (when there are multiple ones like this typing example). trying to split the one import out to a dedicated line works only if the whole thing fits on one line, otherwise black/isort wraps it with parens, and it hits this bug again. when the comment is at the start of the line, black/isort insert blank lines around the section making it more jarring.
putting it before the import line turns it off for the entire file after that point
I think the suggestion was to do this:
from typing import ( # pylint: disable=unused-import
...
gotcha, thanks for the clarification. unfortunately, isort
will reformat that when the first line is longer than 80 cols. i could put in a comment to disable the isort logic, but then i'm back in the same position of adding lots of suppressions :/.
I see! I think disable-next
can be used to still prevent an all-block disable:
# pylint: disable-next=unused-import
from typing import ...
ah, i guess disable-next
is a new thing. time for me to upgrade.
Bug description
Configuration
No response
Command used
Pylint output
Expected behavior
warning should have been suppressed
Pylint version
OS / Environment
No response
Additional dependencies
No response