pylance-release
pylance-release copied to clipboard
Method override completion doesn't return the correct return type
Environment data
- Language Server version:2024.4.1
Code Snippet
# file1.py
class Parent:
def method(self) -> str:
pass
# file2.py
from sys import version
from file1 import Parent
print(version)
class Child(Parent):
def meth # <- trigger completion here
Repro Steps
- Type
meth
and accept completion
Expected behavior
class Child(Parent):
def method(self) -> str:
return super().method()
Actual behavior
class Child(Parent):
def method(self) -> version:
return super().method()
The return type is wrong.
I debugged a little bit and found the wrong type is returned from https://github.com/microsoft/pyrx/blob/50b9544f921007da1d758ac69e61081987c6a65b/packages/pylance-internal/src/services/typeStringGenerator.ts#L60
I can take a closer look later. Also tagging @heejaechang
Similar, if not the same: https://github.com/microsoft/pylance-release/issues/5534
Looks like it only repros if the other symbol imported is the same type as the return type.
Can no longer repro this with v2024.5.1
Doesn't repro for me with the latest pylance version 2024.5.103. Closing it out.
This was a duplicate of https://github.com/microsoft/pylance-release/issues/5693 which was fixed in 2024.4.100.