Auto-Implement Stubs for Interface Implementations #2724
Replies: 6 comments 4 replies
-
Pylance's completion provider will offer to fill in a stub implementation for a method defined in a base class if you start to type the name of that method. For example: class Base(ABC):
@abstractmethod
def test(self, a: int, b: str) -> int:
...
class Child(Base):
def te # Hit tab here and you get... class Child(Base):
def test(self, a: int, b: str) -> int:
return super().test(a, b) |
Beta Was this translation helpful? Give feedback.
-
That's brill @erictraut. Thanks very much. Is there no option to fill in all the stubs? PyCharm has a feature that allows you to right click the child class, and fill in the parent methods as stubs. |
Beta Was this translation helpful? Give feedback.
-
Thanks @yribeiro, moving this issue to discussion as an enhancement request for comments and upvotes. |
Beta Was this translation helpful? Give feedback.
-
Would be great to have this also implemented as a "light bulb", very useful for interfaces with several methods. If I'm not mistaken Typescript has something similar, or maybe C#, not sure. |
Beta Was this translation helpful? Give feedback.
-
Is there any updates or plans? I think this feature (implementing all stubs from abc) is might useful! |
Beta Was this translation helpful? Give feedback.
-
This has been added to our backlog. Use #5362 to track the progress |
Beta Was this translation helpful? Give feedback.
-
At the moment, I do not think there is an auto-complete feature for python classes that implement an abstract interface. It would be super useful to auto generate the function stubs (along with any property decorators) that are defined in the
abc.ABC
interface class.Beta Was this translation helpful? Give feedback.
All reactions