python-lsp / python-lsp-server

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

Argument completion with decorated funcs provides hints for decorators, not original function #352

Open vvzen opened 1 year ago

vvzen commented 1 year ago

Hi everyone!

I have a simple issue with pylsp, so I was wondering if you could provide context if this is a bug/feature or not. Basically, when I'm writing a function that is decorated, I get a typing suggestion for the decorator, not for the original function. That is not particularly useful when the decorator is mean to act transparently (which I feel is the most common use case for decorators).

For example, while typing some_func(, I see this:

Screen Shot 2023-02-27 at 11 15 16

while I would have liked to see that I should pass some_arg to some_func.

Here's simple MRE that reproduces the error:

import functools

@functools.lru_cache()
def some_func(some_arg: int) -> None:
    pass

some_func()

I'm on https://github.com/helix-editor/helix, but I know this happened also to a coworker which uses vim, which led me to think that it's caused by pylsp itself.

I'm on:

$ pylsp --version
pylsp v1.5.0
$ hx --version
helix 22.12 (96ff64a8)

This is my helix config for python, in case it helps:

[[language]]
name = "python"
indent = { tab-width = 4, unit = " " }

[language.config]
# Disable everything but flake8
pylsp.configurationSources = [ 'flake8' ]
pylsp.plugins.flake8.enabled = true
pylsp.plugins.pycodestyle.enabled = false
pylsp.plugins.pyflakes.enabled = false
pylsp.plugins.pylint.enabled = false
pylsp.plugins.mccabe.enabled = false

Thanks!

Amar1729 commented 1 year ago

I'm seeing this as well (in VSCode with the python extension, as well as neovim using pylsp).

screenshot of completion in vscode:

Screen Shot 2023-03-10 at 2 56 46 PM
$ pylsp --version         
pylsp v1.7.1
ike commented 8 months ago

Any ideas on this? Any workarounds?