microsoft / pylance-release

Documentation and issues for Pylance
Creative Commons Attribution 4.0 International
1.7k stars 768 forks source link

Renaming variable in a function renames it everywhere #5951

Open ibobak opened 4 months ago

ibobak commented 4 months ago

Type: Bug

I have multiple cells in my jupyter notebook. I have a variable which has the same name as the parameter of a function. I am pressing F2 to rename the parameter of the function, and unfortunately, it also renames it everywhere in the notebook, which is VERY undesirable. Please, look at the screenshot

image image

Extension version: 2024.4.0 VS Code version: Code 1.89.1 (dc96b837cf6bb4af9cd736aa3af08cf8279f7685, 2024-05-07T05:16:23.416Z) OS version: Linux x64 6.4.6-060406-generic Modes:

System Info |Item|Value| |---|---| |CPUs|AMD Ryzen 7 3700X 8-Core Processor (16 x 2120)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: disabled_software
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off| |Load (avg)|1, 1, 1| |Memory (System)|46.95GB (31.36GB free)| |Process Argv|--crash-reporter-id d91c5c25-2c49-4af3-80cb-302636dde5af| |Screen Reader|no| |VM|0%| |DESKTOP_SESSION|ubuntu| |XDG_CURRENT_DESKTOP|Unity| |XDG_SESSION_DESKTOP|ubuntu| |XDG_SESSION_TYPE|x11|
A/B Experiments ``` vsliv368cf:30146710 vspor879:30202332 vspor708:30202333 vspor363:30204092 tftest:31042121 vswsl492cf:30256860 vscoreces:30445986 vscod805:30301674 binariesv615:30325510 vsaa593cf:30376535 py29gd2263:31024239 c4g48928:30535728 azure-dev_surveyone:30548225 962ge761:30959799 pythongtdpath:30769146 welcomedialog:30910333 pythonidxpt:30866567 pythonnoceb:30805159 asynctok:30898717 pythontestfixt:30902429 pythonregdiag2:30936856 pythonmypyd1:30879173 pythoncet0:30885854 h48ei257:31000450 pythontbext0:30879054 accentitlementsc:30995553 dsvsc016:30899300 dsvsc017:30899301 dsvsc018:30899302 cppperfnew:31000557 dsvsc020:30976470 pythonait:31006305 chatpanelt:31048053 dsvsc021:30996838 9c06g630:31013171 pythoncenvptcf:31043158 a69g1124:31046351 pythonprc:31047982 dwnewjupyter:31046869 ```
DonJayamanne commented 4 months ago

@ibobak does this issue reproduce when you disable the Pylance extension?

ibobak commented 4 months ago

I disabled pylance, restarted vs code, and how I have this problem:

image

image

How can it be? Why can't I rename the variable as it was done before?

ibobak commented 4 months ago

I re-enabled Pylance, restarted the language server, and now it works as it was before: image

To be honest, I don't know the reason why renaming was not working at all while pylance was not loaded. But I actually googled the solution "renaming symbol is not working in VS code", and the answer was "enable pylance and restart language server" :)

So, is there some way to make it NOT renaming the symbol everywhere, but to do this just inside the function?

ibobak commented 4 months ago

The issue is now with the "info needed" label. Do you need some other info from me? If yes, feel free to ask.

amunger commented 3 months ago

I can repro, so we should be able to look into it. thanks