You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When not using def to overwrite a parent method but using a variable or import instead, the tooltip and signature of the parent is preserved instead of displaying the new one.
Environment data
Using with VSCode
Pylance version: 2024.8.101 (pyright version 1.1.375, commit d2c0938f)
OS and version: Ubuntu 22.04
Python version: miniconda: Any
Code Snippet
defexternalbar(a: int):
"""external Bar"""classA:
@staticmethoddefbar(a:int):
"""This is A.bar"""classB(A):
bar=staticmethod(externalbar)
# or# from somemodule import bardeffoo(self):
self.bar# Tooltip is: "This is A.bar"; expected 'external Bar'B.bar# "This is A.bar"; expected 'external Bar'
Expected behavior
Expected that B.bar / self.bar links to externalbar and used it as tooltip instead of using A.bar.
CTRL + click should send me to externalbar
Actual behavior
Falls back to A.bar and ignores the overwrite. CTRL + click sends me to A.bar
The text was updated successfully, but these errors were encountered:
Thanks for the issue but this is by design. Pylance (and Pyright that Pylance is based upon) is a static based analyzer. Dynamically changing the value of a member at runtime cannot be modeled by Pylance.
I believe the root problem here is it's not defined whether the A.bar definition happens before or after the assignment in B.
When not using
def
to overwrite a parent method but using a variable or import instead, the tooltip and signature of the parent is preserved instead of displaying the new one.Environment data
Code Snippet
Expected behavior
Expected that
B.bar / self.bar
links toexternalbar
and used it as tooltip instead of usingA.bar
.CTRL + click should send me to
externalbar
Actual behavior
Falls back to
A.bar
and ignores the overwrite. CTRL + click sends me toA.bar
The text was updated successfully, but these errors were encountered: