admin管理员组

文章数量:1315354

Sometime ago, I remember that when I was hovering over a declared variable in a python script (not in debug mode), I could see its value. That was very handy, as (I) I could see the value of the variable right away and (II) I could copy the value if necessary.

I regularly update VS code as well as the python extension, so my suspicion is that this default behaviour changed in any of the updates.

I have tried a few things as listed below, but nothing helped. When I hover over a variable (e.g. reads = ['R1', 'R2'], I see (variable) reads: list[str] whereas in the past I could see the list with its values i.e. R1 and R2

  1. My language sever is Pylance
  2. I have enabled hover tooltips (setting is python.analysis.inlayHints.variableTypes)
  3. I have played around with python.analysis.typeCheckingMode: from basic to strict

How can I re-enable that feature inside a python script in VSCode?

Sometime ago, I remember that when I was hovering over a declared variable in a python script (not in debug mode), I could see its value. That was very handy, as (I) I could see the value of the variable right away and (II) I could copy the value if necessary.

I regularly update VS code as well as the python extension, so my suspicion is that this default behaviour changed in any of the updates.

I have tried a few things as listed below, but nothing helped. When I hover over a variable (e.g. reads = ['R1', 'R2'], I see (variable) reads: list[str] whereas in the past I could see the list with its values i.e. R1 and R2

  1. My language sever is Pylance
  2. I have enabled hover tooltips (setting is python.analysis.inlayHints.variableTypes)
  3. I have played around with python.analysis.typeCheckingMode: from basic to strict

How can I re-enable that feature inside a python script in VSCode?

Share Improve this question edited Jan 31 at 8:25 BCArg asked Jan 30 at 9:38 BCArgBCArg 2,2502 gold badges24 silver badges39 bronze badges 2
  • Currently, the issue needs more details to help us reproduce the problem. Have you tried installing specific version? – Minxin Yu - MSFT Commented Feb 3 at 8:27
  • For reasons that are unknown to me, the behaviour of displaying the variables values is back. Python extension version is 2024.22.2, Vs code version is 1.96.4 - the same as when the issue was reported. The only thing that I have done since then is sudo apt update and sudo apt upgrade. Some old libraries were removed, but no newer version of VS code was installed. Can this be an explanation? – BCArg Commented Feb 4 at 9:07
Add a comment  | 

2 Answers 2

Reset to default -1

If you set a breakpoint and run in debug mode you get that when you hover on a variable the value is shown.

If you are in the editor the variable name and type is shown.

Since you mentioned copying values. It is an option available in debug mode.

Is this what you have seen in the past?

本文标签: pythonVS code no longer displays value of variable when mousehovering itStack Overflow