Summary
In VS code when using the F12 go to definition feature.
Example:
class Base:
def __init__(self, x: int) -> None:
self.x = x
print("Base init")
class Generic[T](Base):
def __init__(self, x: int, y: T):
# Definition does not resolve to Base.__init__ but super.__init__ using ty,
# Pylance resolves to Base.__init__
super().__init__(x)
self.y = y
print("Generic init")
if __name__ == "__main__":
a = Generic[float](1, 2.3)
# prints
# Base init
# Generic init
# x=1, y=2.3
print(f"x={a.x}, y={a.y}")
The super().__init__() call resolves to super.__init__ when using ty.
Switching to Pylance resolves the problem and it resolves to Base.__init__.
It may be wort noting that hovering over the super().__init__(x) displays a "@todo"
Version
ty 0.0.17
Summary
In VS code when using the F12 go to definition feature.
Example:
The
super().__init__()call resolves tosuper.__init__when using ty.Switching to Pylance resolves the problem and it resolves to
Base.__init__.It may be wort noting that hovering over the
super().__init__(x)displays a "@todo"Version
ty 0.0.17