-
Notifications
You must be signed in to change notification settings - Fork 771
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
Usage of namedtuple._replace should not generate warning #1454
Comments
We generally avoid hard-coding knowledge of specific classes, functions or members within Pylance because it's not a scalable approach. We might consider doing it in very special circumstances if we receive a lot of feedback. In this case, the error is emitted only if you enable the |
Thinking about this a bit more, the |
This issue has been fixed in version 2021.6.2, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/main/CHANGELOG.md#202162-16-june-2021 |
This change doesn't seem to include the type name declared in stub files. Some type names, e.g., Language Server version: Pylance language server 2022.1.5 (pyright 8d096292) |
This change was specifically for private class members. I think it's reasonable to add support for module-level symbols as well. I'd appreciate it if you would file a new enhancement request to track this. |
Environment data
Expected behaviour
Pylance should not warn on when calling
_replace
on anamedtuple
.Actual behaviour
Pylance generates a warning:
"_replace" is protected and used outside of the class in which it is declared
.Code Snippet
Notes
The
_replace
method is documented, along with other fields that begin with underscore and are not private. I can guess that the reason why the prepended an underscore to these members' names is to not clash with user-defined field names in the namedtuple.Probably Pylance should keep a whitelist of members that start with underscore but are not private.
The text was updated successfully, but these errors were encountered: