-
Notifications
You must be signed in to change notification settings - Fork 767
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
Incorrect reportUndefinedVariable for builtin __qualname__ #1376
Comments
The documentation for The same PEP introduced Mypy (another popular type checker) also reports the use of So I wonder whether this is intended behavior or just an implementation detail that you should not be relying on. Do you happen to know of any official Python documentation that explains that the use of |
Hi @erictraut , thanks for replying so quick! I do not have any official documentation other than that PEP, sorry. I have seen it in the dataclass implementation, which is where I found out about it I wanted to use it to build a qualified name hierarchy for logging so instead of:
I can do
and this future-proofs any code refactoring of the module name. |
I've updated the logic in pyright/pylance to handle this case consistently with the Python interpreter. I also filed a bug report for mypy, since it contains the same problem. After some experimentation, I found that This will be fixed in the next release of pylance. Thanks for reporting the problem. |
This issue has been fixed in version 2021.6.0, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/main/CHANGELOG.md#202160-2-june-2021 |
@erictraut, there is unfortunately a regression of this bug since |
I'll note that mypy doesn't handle this correctly either. It's not surprising given that it appears to be a very strange special case. I've added some logic that makes this work. This will be included in the next release. |
This issue has been fixed in version 2021.12.1, which we've just released. You can find the changelog here: CHANGELOG.md |
Pylance mistakenly raises a reportUndefinedVariable warning for dundermethod__qualname__
Environment data
Expected behaviour
Pylance should recognise qualname as valid dundermethod in a class defintion and not raise any warning.
Example:
Actual behaviour
Pylance raises reportUndefinedVariable for the above code.
Logs
The text was updated successfully, but these errors were encountered: