Skip to content

Auto completion tooltip displays "cls" (class) parameter for class functions #7292

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
hutattedonmyarm opened this issue Sep 9, 2019 · 3 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster

Comments

@hutattedonmyarm
Copy link

Environment data

  • VS Code version: 1.38.0
  • Extension version (available under the Extensions sidebar): 2019.9.34911
  • OS and version: Windows 10 1809
  • Python version (& distribution if applicable, e.g. Anaconda): Python 3.7.4 64-bit
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): N/A
  • Relevant/affected Python packages and their versions: -
  • Jedi or Language Server? (i.e. what is "python.jediEnabled" set to; more info How to update the language server to the latest stable version #3977): Jedi enabled "python.jediEnabled": true

Expected behaviour

Auto completion should skip "cls" (class) parameter for classmethods in autocompletion tooltip, just like it skips the "self" parameter

Actual behaviour

Parameter "cls" is shown alongside the normal parameter list, causeing an off-by-one error for the highlighted parameters in the tooltip, because it doesn't need to be specified in the parameter lsit when calling a class function (same as "self" does not need to be put into the parameter list)

Steps to reproduce:

  1. Write a class function with a few parameters:
def MyClass:
    @classmethod
    def foo(cls, param1, param2):
        pass
  1. Call the class method
    MyClass.foo("foo", "bar")

  2. Autocomplete tooltip should show only param1and param2, but not cls

grafik

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

> /usr/bin/env python3 -c "import sys;print(sys.executable)"
> /usr/bin/env python3 -c "import sys;print(sys.executable)"
> /usr/bin/env python3 -c "import sys;print(sys.executable)"
> /usr/bin/env python3 -c "import sys;print(sys.executable)"
> /usr/bin/env python3 -c "import sys;print(sys.executable)"
> /usr/bin/env python3 -c "import sys;print(sys.executable)"
> /usr/bin/env python3 -c "import sys;print(sys.executable)"
> /usr/bin/env python3 -c "import sys;print(sys.executable)"

Output from Console under the Developer Tools panel (toggle Developer Tools on under Help; turn on source maps to make any tracebacks be useful by running Enable source map support for extension debugging)

[Extension Host] Info Python Extension: 2019-09-09 15:27:31: Cached data exists getEnvironmentVariables, c:\Users\hutat\Dokumente\tw\main.py
console.ts:137 [Extension Host] Info Python Extension: 2019-09-09 15:27:31: > /usr/bin/env python3 -c "import sys;print(sys.executable)"
console.ts:137 [Extension Host] Info Python Extension: 2019-09-09 15:27:31: Cached data exists getEnvironmentVariables, c:\Users\hutat\Dokumente\tw\main.py
console.ts:137 [Extension Host] Info Python Extension: 2019-09-09 15:27:31: > /usr/bin/env python3 -c "import sys;print(sys.executable)"
console.ts:137 [Extension Host] Info Python Extension: 2019-09-09 15:27:34: Cached data exists getEnvironmentVariables, c:\Users\hutat\Dokumente\tw\main.py
console.ts:137 [Extension Host] Info Python Extension: 2019-09-09 15:27:34: > /usr/bin/env python3 -c "import sys;print(sys.executable)"
@hutattedonmyarm hutattedonmyarm added triage-needed Needs assignment to the proper sub-team bug Issue identified by VS Code Team member as probable bug labels Sep 9, 2019
@kimadeline
Copy link

Hi @hutattedonmyarm 👋 Thank you for reaching out. Can you try the following and let me know if it works:

  • try using the language server (set python.jediEnabled to false)
  • try downgrading the extension to 2019.8.30787

Thanks!

@kimadeline kimadeline added info-needed Issue requires more information from poster triage labels Sep 9, 2019
@ghost ghost removed the triage-needed Needs assignment to the proper sub-team label Sep 9, 2019
@kimadeline kimadeline self-assigned this Sep 9, 2019
@hutattedonmyarm
Copy link
Author

hutattedonmyarm commented Sep 10, 2019

@kimadeline Switching from Jedi to the language server fixed the problem in the current version. Additionally I tried the downgrade with mixed results. The language server with 2019.8.30787 worked identically to the current version (that is it worked without issues), and 2019.8.30787 with Jedi didn't produce any meaningful tooltips. (Only args and **kwargs ). However the language server needed a few minutes to analyze the code in the background (and indicated that in the status bar) while Jedi didn't display any status so I tried it immediately without giving it some tiem first.

For now, I've switched back to the current version and am using the language server.

EDIT: As a minor note: Disablign jedi caused me to experience the same issue as in #3292. Manually adding "python.linting.pylintEnabled": true in the workspace settings resolved the issue, even though pylint is globally enabled, so it shouldn't need to be enabled specifially for the workspace again

@kimadeline
Copy link

Thank you for your reply and letting us know that using the language server works 👍

Calling jedi (0.15.1) directly on the MyClass snippet returns [<ParamDefinition name='cls', description='param cls'>, <ParamDefinition name='param1', description='param param1'>, <ParamDefinition name='param2', description='param param2'>], so you can probably file it directly on jedi's repo:
image

About pylint not working unless you enable it in the workspace, the language server didn't provide linting when #3292 was filed (it does now), so the root issues are probably different despite the visible result (and workaround) are the same. In any case, it's now reported here: #7314.

@ghost ghost removed the triage label Sep 10, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Sep 17, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

2 participants