-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
False positive no-member
for TypedDict.__annotations__
#7126
False positive no-member
for TypedDict.__annotations__
#7126
Comments
I often use a construct like this in Python 3.7 and I get that false positive too:
|
The issue with
However, I don't know it it is the same cause, but I am getting from typing import TypedDict
class Example(TypedDict):
string: str
integer: int
boolean: bool
print(Example.__annotations__) # {'string': <class 'str'>, 'integer': <class 'int'>, 'boolean': <class 'bool'>}
print(Example.__required_keys__) # frozenset({'integer', 'string', 'boolean'})
print(Example.__optional_keys__) # frozenset()
|
I added the help wanted label because checking that the bug is fixed by adding a functional test case can be done without pylint knowledge (the CI will check from python 3.8 to python 3.12 on win/mac/linux).
This require some investigation (And maybe another issue). |
For me the issue is also fixed for It is still there when using the Alternative Syntax though. We use these for TypedDicts whose fields are not valid attribute names in Python, e.g. because they are reserved keywords. |
I have the same issue and from my tests it also only happens when using the alternative syntax from typing import TypedDict
class MyTypedDict(TypedDict):
a: int
b: str
OtherTypedDict = TypedDict('OtherTypedDict', {'a': int, 'b': str})
print(MyTypedDict.__annotations__) # No Error
print(OtherTypedDict.__annotations__) # Error
|
Pylint now does not emit a ``no-member`` error when accessing ``__annotations`` in the following cases: ``` class Test: print(__annotations__) ``` ``` from typing import TypedDict OtherTypedDict = TypedDict('OtherTypedDict', {'a': int, 'b': str}) print(OtherTypedDict.__annotations__) ``` Closes pylint-dev/pylint#7126
Is not fixed in pylint 3.0.3:
|
That’s a slightly different case. The thing that was said to be fixed was not about referencing the attribute in the class body itself. |
Bug description
See #3234 (comment)
Configuration
No response
Command used
Pylint output
Expected behavior
No warning
Pylint version
OS / Environment
No response
Additional dependencies
No response
The text was updated successfully, but these errors were encountered: