python-lsp / python-lsp-server

Fork of the python-language-server project, maintained by the Spyder IDE team and the community
MIT License
1.76k stars 186 forks source link

Autocomplete inherited method's signature #458

Open staticf0x opened 9 months ago

staticf0x commented 9 months ago

I don't know if this is pylsp or jedi issue, apologies if this is the wrong place.

Suppose I have this code:

class A:
    def example(self, text: str) -> str:
        return text

class B(A):
    # Cursor here

when I start typing def exam..., autocomplete is shown, but the code filled in that place is then:

class B(A):
    def example(self, text)
    #           ^^^^ self is selected

Would it be possible to also fill the method signature (typing) and perhaps a colon and move the cursor into the method body?

ccordoba12 commented 9 months ago

I agree this would be quite nice to have when overriding a method in a subclass. But I think you should ask in the Jedi repo about it because Pylsp is simply a wrapper for it that makes it work with the LSP protocol.