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
Pylint incorrectly flags as unused-import
things that are used in type comments
#3112
Comments
Wow. Thanks for fixing that so fast! |
I'm still having the same issue with python 3.7.4 on linux: from typing import Optional
class A:
def __init__(self):
self.field = None # type: Optional[str] pylint Test.py
************* Module Test
...
Test.py:1:0: W0611: Unused Optional imported from typing (unused-import)
pylint --version
pylint 2.4.2
astroid 2.3.1
Python 3.7.4 (default, Jul 23 2019, 10:08:33)
[GCC 4.8.5] Interestingly I don't get this issue on windows with python 3.7.3:
Any ideas what could cause this issue? |
"""yes"""
from datetime import datetime
from typing import Optional, Any
def magic(alpha, beta, gamma):
# type: (str, Optional[str], Optional[datetime]) -> Any
"""going strong"""
return alpha, beta, gamma
See the above also throws this. |
@davidgiga1993 The fix was released as part of 2.4.3, it seems you are using 2.4.2. Can you also give it a try with 2.4.3 and see if it works for you? @gaborbernat Thanks, I can reproduce that one using the latest version. |
The previous code was assuming that only ``typing`` names need to be exempted, but we need to do that for the rest of the type comment names as well. Close #3112
Thanks for that additional example @gaborbernat This is now fixed in |
This issue was supposed to have been fixed in #1063, but it appears that it was not completely fixed.
Current Behavior
The following example works correctly, and all imports from the typing module are correctly identified as being "used":
But use of the one-arg-per-line form of pep 484 is not properly detected by pylint:
Expected Behavior
There should be no error: all items should be detected as being used, as in the first example
Environment
I also tried with python 3.6.1. Same issue.
The text was updated successfully, but these errors were encountered: