Skip to content
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

"Rename Symbol" often fails to rename when using Rope #52

Closed
NickGrattan opened this issue Nov 12, 2017 · 38 comments · May be fixed by irinazheltisheva/vscode-python#3 or Aqeelkha/vscode-python#4
Closed
Labels
bug Issue identified by VS Code Team member as probable bug

Comments

@NickGrattan
Copy link

Environment data

VS Code version: 1.18.0
Python Extension version: 0.8.0
Python Version: 3.5.3 Anaconda 4.0.0
OS and version: Widows 10 Professional

Actual behavior

"Symbol Rename" for a Python symbol fails to rename in about 50% of cases. The symbol remains as its old name and is not renamed

Expected behavior

Rename to rename symbols everytime.

Steps to reproduce:

  • Select symbol (e.g. "node"), choose "Rename Symbol" from context menu
  • Enter new symbol name (e.g. "node2")
    image
  • Press Enter
    Symbol may not be renamed

Logs

Output from Python output panel
No output

Output from ```Console window``` (Help->Developer Tools menu)
No output
@brettcannon brettcannon added awaiting 1-verification bug Issue identified by VS Code Team member as probable bug labels Nov 14, 2017
@brettcannon
Copy link
Member

I can verify this is an issue. Using the following code:

def fxn():
    B = 42
    Y = B + 13
    return B + Y

I just simply tried renaming B multiple times in a row and after about 3 times it started to work about every other time. Not sure if this is our doing or Rope's doing.

@puzzler10
Copy link

puzzler10 commented Mar 9, 2018

Actually, when I tried doing rename on that code (changing B to O) it went from

def fxn():
    B = 42
    Y = B + 13
    return B + Y

to

def fxn():
    Y = O + 13
    return O + Y

deleting a line completely.

@brettcannon
Copy link
Member

@puzzler10 can you open a new issue?

@fredrikaverpil
Copy link

I'm on the latest vscode (to date) and I find renaming symbols is a "hit or miss" feature. Feels like there's a 50% chance it works with Python code.

@brettcannon
Copy link
Member

@fredrikaverpil the trickiness with this is knowing whether this is our fault or rope not working properly.

@fredrikaverpil
Copy link

fredrikaverpil commented Apr 25, 2018

@brettcannon I understand. Hm. When it misses the next time, is there any way I troubleshoot it and investigate whether it is rope's fault?

EDIT: And by the way, thanks for an absolutely fantastic product. I live and breathe Python in vscode at least 8hrs a day 😉

@brettcannon
Copy link
Member

@fredrikaverpil not at the moment; we have #1131 for adding logging throughout the extension as that's a major shortcoming we have.

And thanks for the compliment!

@pdhorn
Copy link

pdhorn commented May 3, 2018

I'm on VSCode 1.22.2, Mac OS 10.13.4, Python 3.6, just installed rope fresh from pip. I get three different kinds of behavior from the following code (example). My problems seem to be related to the OP's, but somehow a superset of symptoms...

def my_func(x):
    return x

x = 1
y = my_func(x)
z = my_func(y)
print(z)

Action: highlight one of the y and Rename Symbol to yy.

  1. Sometimes I get "No Result" popup
  2. Sometimes it actually renames y to yy.
  3. Sometimes it names z to yy, and in these cases, y stays as y !?!

I'm not sure how to get any of the output logs I've seen on other threads.

@brettcannon brettcannon added this to the May 2018 milestone May 3, 2018
@brettcannon brettcannon removed this from the May 2018 milestone Jun 6, 2018
@singularitti
Copy link

Using the example provided by @pdhorn above, I found some other issues.

When I am renaming x to xx in def my_func(x):, I got such errors:

Refactor failed. expected string or bytes-like object
[<FrameSummary file refactor.py, line 294 in watch>, <FrameSummary file refactor.py, line 275 in _process_request>, <FrameSummary file refactor.py, line 206 in _rename>, <FrameSummary file refactor.py, line 117 in refactor>, <FrameSummary file refactor.py, line 139 in onRefactor>, <FrameSummary file /usr/local/lib/python3.6/site-packages/rope/refactor/rename.py, line 101 in get_changes>, <FrameSummary file /usr/local/lib/python3.6/site-packages/rope/refactor/rename.py, line 117 in _is_renaming_a_module>, <FrameSummary file /usr/local/lib/python3.6/site-packages/rope/base/pynamesdef.py, line 42 in get_object>, <FrameSummary file /usr/local/lib/python3.6/site-packages/rope/base/pyobjectsdef.py, line 69 in get_parameter>, <FrameSummary file /usr/local/lib/python3.6/site-packages/rope/base/utils/__init__.py, line 29 in newfunc>, <FrameSummary file /usr/local/lib/python3.6/site-packages/rope/base/pynames.py, line 188 in get>, <FrameSummary file /usr/local/lib/python3.6/site-packages/rope/base/pyobjectsdef.py, line 40 in _infer_parameters>, <FrameSummary file /usr/local/lib/python3.6/site-packages/rope/base/utils/__init__.py, line 41 in newfunc>, <FrameSummary file /usr/local/lib/python3.6/site-packages/rope/base/oi/soi.py, line 47 in infer_parameter_objects>, <FrameSummary file /usr/local/lib/python3.6/site-packages/rope/base/oi/soi.py, line 130 in _parameter_objects>, <FrameSummary file /usr/local/lib/python3.6/site-packages/rope/base/oi/type_hinting/providers/inheritance.py, line 21 in __call__>, <FrameSummary file /usr/local/lib/python3.6/site-packages/rope/base/oi/type_hinting/providers/composite.py, line 19 in __call__>, <FrameSummary file /usr/local/lib/python3.6/site-packages/rope/base/oi/type_hinting/providers/docstrings.py, line 46 in __call__>, <FrameSummary file /usr/local/lib/python3.6/site-packages/rope/base/oi/type_hinting/providers/numpydocstrings.py, line 20 in __call__>, <FrameSummary file /usr/local/lib/python3.6/site-packages/numpydoc/docscrape.py, line 138 in __init__>, <FrameSummary file /usr/local/Cellar/python/3.6.5_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/textwrap.py, line 430 in dedent>]

Is it a problem of rope or my Python, or Python extension? Could you please recommend a working version of rope and Python? Thanks!

VS Code version: 1.24.1
Python Extension version: 2018.5.0
Python Version: 3.6.5_1 installed from Homebrew
OS and version: macOS 10.13.5

@brettcannon
Copy link
Member

@singularitti we have no recommendation beyond the latest release.

@pdhorn
Copy link

pdhorn commented Jun 20, 2018

My issues seem to have resolved themselves with an upgrade to VS Code 1.24.1 and macOS 10.13.5. Some extensions may have upgraded, too.

@cburgdorf
Copy link

Fails for me sometimes as well. Here's a screenshot with an actual error.

image

Just closing Code and reopening it again fixes that error.

VS Code version: Code 1.24.1 (24f62626b222e9a8313213fb64b10d741a326288, 2018-06-13T17:47:35.732Z)
OS version: Linux x64 4.15.0-23-generic

System Info
Item Value
CPUs Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz (4 x 1499)
GPU Status 2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: disabled_software
rasterization: disabled_software
video_decode: unavailable_software
video_encode: enabled
vpx_decode: unavailable_software
webgl: enabled
webgl2: enabled
Load (avg) 1, 1, 1
Memory (System) 7.68GB (0.14GB free)
Process Argv /usr/share/code/code .
Screen Reader no
VM 0%
Extensions (4)
Extension Author (truncated) Version
tslint eg2 1.0.33
solidity Jua 0.0.43
python ms- 2018.6.0
preview-vscode sea 1.4.2

@philraj

This comment has been minimized.

@fredrikaverpil
Copy link

fredrikaverpil commented Sep 13, 2018

The "Rename symbol" command is made possible because of rope, right?

As far as I understand, rope does not support Python 3, although their pypi page says "Full python3 support is in progress… stay tuned". Could it be that we are seeing issues with "Rename symbol" because of working with Python 3?
This would explain why I am experiencing very slow renames or just failed ones, as I am pretty much only using Python 3.x.

This is my vscode version (as of writing this) and I'm working with a venv which is Python 3.6 or 3.7 with rope 0.11.0 pip-installed in the venvs:

Version: 1.27.1 (user setup)
Commit: 5944e81f3c46a3938a82c701f96d7a59b074cfdc
Date: 2018-09-06T09:21:18.328Z
Electron: 2.0.7
Chrome: 61.0.3163.100
Node.js: 8.9.3
V8: 6.1.534.41
Architecture: x64

@perphyyoung
Copy link

Did anywhere exist other extension support renaming variable of python code within vscode? I could not find one on the extensions panel.

@cipri-tom

This comment has been minimized.

@cipri-tom

This comment has been minimized.

@brettcannon
Copy link
Member

@cipri-tom please open a new issue as this issue is specific to those using Rope (and thus are not using the language server). I also can't reproduce the problem, so please try to give details like whether the file was dirty, the name of the file, etc.

@brettcannon brettcannon changed the title "Rename Symbol" often fails to rename "Rename Symbol" often fails to rename when using Rope Nov 22, 2018
@v-kydela
Copy link

It's not hit-or-miss for me. It's just miss. I've tried around 20 times and it never ever works. I press enter, the input box closes, and nothing changes.

@kammoh
Copy link

kammoh commented Apr 10, 2019

It seems Python symbol refactoring has stopped working for me altogether!
VS Code 1.33.0, macOS 10.14.4, Python 3.7.3, Python extension: 2019.3.6558

@themotu
Copy link

themotu commented Apr 11, 2019

No worky for me. Box closes, no change. Using current insiders

@BBI-DiWang
Copy link

BBI-DiWang commented Apr 11, 2019

same issue, can not solve it. "find all references" stopped working as well.

@brettcannon
Copy link
Member

We're actively working to getting renaming working with our new language server which should replace our need to rely on Rope.

@calvin620707
Copy link

We're actively working to getting renaming working with our new language server which should replace our need to rely on Rope.

I already disabled Jedi and using language server. Is this the reason why I can't use rename with rope?

@BBI-DiWang
Copy link

I added python.jediEnabled": true in the settings.json, temporary solution.

@brettcannon
Copy link
Member

@calvin620707 correct, but the new language server has built-in support (at least in the beta channel as of version 0.2.53).

@karrtikr
Copy link

FAIL CASE

Rename Symbol ALWAYS fails without error when NO WORKSPACE FOLDER is open. (#5301)

@ThatAIGeek
Copy link

Are there any plans to fix this? I'm still getting this with Version: 1.35.1

@v-kydela
Copy link

v-kydela commented Jul 2, 2019

@karrtikr - I notice that you closed that other issue, saying it is working as desired. VSCode gives no explanation for why the rename failed. That hardly seems like desirable behavior.

@brettcannon
Copy link
Member

@ThatAIGeek there's nothing really to fix directly; Rope simply failed and we don't control Rope. Please try the language server to see if it's renaming support works for you (see #3977 for instructions on how to do that).

@v-kydela as I mention above, Rope only provides us so much. Please try the language server to see if it does the renaming you want as that we do control and can fix.

@fireattack
Copy link

fireattack commented Jul 3, 2019

I'm a little confused. So disabling Jedi will enable language server instead, right? But how it's related to rope? Are rope and Jedi the same thing?

@brettcannon
Copy link
Member

@fireattack Correct, disabling Jedi will activate the language server. It's related to Rope because the language server subsumes functionality of Jedi, Rope, and Pylint for the extension. So if you turn on the language server we do not use Jedi or Rope and we stop prompting you to install Pylint to get syntax errors and such (but it will still run, it's just more of an opt-in thing).

@brettcannon
Copy link
Member

Closing as this is an upstream issue which we don't have direct control or influence over.

@ghost ghost removed the needs upstream fix label Jul 29, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Aug 5, 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
Projects
None yet