-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow used variables to be properly consumed when different checks ar…
…e enabled / disabled When everything else was disabled, except `unused-import`, pylint was emitting `unused-import` even though the imports in questions were used. The emission occurred due to the fact that disabling all the messages also disabled the calling of `visit_name`, which deals with `undefined-variable`. This resulted in `visit_name` not marking as consumed the earlier import as expected. This fix still allows `visit_name` to be called, but the emission of `undefined-variable` and friends is controlled via a flag prior to emission call site. This is somewhat of a "temporary" hack, a better solution would be to separate the emission / checking of undefined variable from marking the variables as consumed. Close #3445
- Loading branch information
1 parent
4024949
commit c518188
Showing
4 changed files
with
30 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
"""Test that unused-import is not emitted here when everything else is disabled | ||
https://github.com/PyCQA/pylint/issues/3445 | ||
""" | ||
from os import environ | ||
|
||
for k, v in environ.items(): | ||
print(k, v) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[Messages Control] | ||
disable=all | ||
enable=unused-import |