vscode-python: "Rename Symbol" often fails to rename when using Rope

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

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 36
  • Comments: 38 (11 by maintainers)

Most upvoted comments

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

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

Also getting this other times:

Refactor failed. Rename refactoring should be performed on resolvable python identifiers.
[<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 138 in onRefactor>, <FrameSummary file C:\Users\[USER]\AppData\Local\Continuum\anaconda3\lib\site-packages\rope\refactor\rename.py, line 28 in __init__>]

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

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

I have the same problem.

If I use Rename Symbol, it works within the same file, but does not rename the symbol in the other files of the project / open folder. The only way I can make sure everything is renamed is to run a Search: Find in Files and manually rename all instances.

I’m on Code 1.26.0-insider + vscode-python 2018.6.0 (20 June 2018)

@singularitti we have no recommendation beyond the latest release.

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

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.