profile
viewpoint

Ask questionsrename feature failed with 'Refactor failed'

Environment data

  • VS Code version: 1.39.1(system setup)
  • Extension version (available under the Extensions sidebar): 2019.10.41019
  • OS and version: Windows 10 Home (local), wsl ubuntu 18.04 (access remotely)
  • Python version (& distribution if applicable, e.g. Anaconda): Py3.7.3 & Anaconda:4.7.10
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): The code runs on remote WSL ubuntu 18.04 with local network
  • Relevant/affected Python packages and their versions: n/a
  • Jedi or Language Server? (i.e. what is "python.jediEnabled" set to; more info #3977): not enable

Expected behaviour

Expect rename success.

Actual behaviour

An Error as “Refactor failed”

Steps to reproduce:

  1. double click a variable;
  2. press F2;
  3. enter a new name of it.

<!-- Note: If you think a GIF of what is happening would be helpful, consider tools like https://www.cockos.com/licecap/, https://github.com/phw/peek or https://www.screentogif.com/ . -->

Logs

Refactor failed. Syntax error in file <this_is_my_code.py> line <177>: unindent does not match any outer indentation level [<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 /home/hkb/anaconda3/lib/python3.7/site-packages/rope/refactor/rename.py, line 23 in init>, <FrameSummary file /home/hkb/anaconda3/lib/python3.7/site-packages/rope/base/project.py, line 116 in get_pymodule>, <FrameSummary file /home/hkb/anaconda3/lib/python3.7/site-packages/rope/base/pycore.py, line 142 in resource_to_pyobject>, <FrameSummary file /home/hkb/anaconda3/lib/python3.7/site-packages/rope/base/pycore.py, line 255 in get_pymodule>, <FrameSummary file /home/hkb/anaconda3/lib/python3.7/site-packages/rope/base/pyobjectsdef.py, line 162 in init>, <FrameSummary file /home/hkb/anaconda3/lib/python3.7/site-packages/rope/base/pyobjectsdef.py, line 191 in _init_source>]

microsoft/vscode-python

Answer questions karthiknadig

We use https://github.com/python-rope/rope for refactoring. Looks like there might have been an indentation issue in your code. If you feel there is still an issue please report it to the linked repository.

useful!
source:https://uonfu.com/
answerer
Karthik Nadig karthiknadig @Microsoft Redmond Developer at Microsoft, working on VS Code Python and Python Debugger.
Github User Rank List