Repository navigation
Refactor errors with Rope #500
Copy link
Copy link
Closed
Labels
bugIssue identified by VS Code Team member as probable bugIssue identified by VS Code Team member as probable bug
Description
Environment data
VS Code version: Version 1.19.1 (1.19.1)
Python Extension version: 0.9.1
Python Version: 3.6.3 (conda-forge)
OS and version: macOS 10.12.6
Actual behavior
While trying to refactor, an error pops up and a file list with a lot of files that are not part of the project
Expected behavior
Refactor executes.
Steps to reproduce:
- git clone git@github.com:michaelaye/planet4.git
- find planet4/markings.py in that repo
- find
data_rootvariable in line 26 - Use F2 to start refactor, while cursor is on
data_root - Type 'DATA_ROOT' to replace with upper case and press RETURN
- Some calculation happens, after a few seconds, an error pops up:
Refactor failed. expected string or bytes-like object
Logs
Output from Python output panel
No panel is popping up
Output from Console window (Help->Developer Tools menu)
Refactor failed. expected string or bytes-like object
[<FrameSummary file refactor.py, line 271 in watch>, <FrameSummary file refactor.py, line 252 in _process_request>, <FrameSummary file refactor.py, line 183 in _rename>, <FrameSummary file refactor.py, line 94 in refactor>, <FrameSummary file refactor.py, line 116 in onRefactor>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/refactor/rename.py, line 101 in get_changes>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/refactor/rename.py, line 117 in _is_renaming_a_module>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/pynamesdef.py, line 22 in get_object>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/utils/__init__.py, line 29 in newfunc>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/pynames.py, line 188 in get>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/utils/__init__.py, line 29 in newfunc>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/pynamesdef.py, line 19 in _get_inferred>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/utils/__init__.py, line 41 in newfunc>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/oi/soi.py, line 71 in infer_assigned_object>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/utils/__init__.py, line 41 in newfunc>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/oi/soi.py, line 142 in _infer_assignment>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/utils/__init__.py, line 41 in newfunc>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/oi/soi.py, line 175 in _follow_pyname>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/evaluate.py, line 27 in eval_node>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/evaluate.py, line 32 in eval_node2>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/ast.py, line 39 in walk>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/evaluate.py, line 188 in _Call>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/evaluate.py, line 169 in _get_returned>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/pyobjectsdef.py, line 73 in get_returned_object>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/utils/__init__.py, line 29 in newfunc>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/pynames.py, line 188 in get>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/pyobjectsdef.py, line 45 in _infer_returned>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/utils/__init__.py, line 41 in newfunc>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/oi/soi.py, line 25 in infer_returned_object>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/oi/soi.py, line 114 in _infer_returned>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/pynamesdef.py, line 22 in get_object>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/utils/__init__.py, line 29 in newfunc>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/pynames.py, line 188 in get>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/utils/__init__.py, line 29 in newfunc>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/pynamesdef.py, line 19 in _get_inferred>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/utils/__init__.py, line 41 in newfunc>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/oi/soi.py, line 71 in infer_assigned_object>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/utils/__init__.py, line 41 in newfunc>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/oi/soi.py, line 142 in _infer_assignment>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/utils/__init__.py, line 41 in newfunc>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/oi/soi.py, line 175 in _follow_pyname>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/evaluate.py, line 27 in eval_node>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/evaluate.py, line 32 in eval_node2>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/ast.py, line 39 in walk>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/evaluate.py, line 174 in _Call>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/evaluate.py, line 169 in _get_returned>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/pyobjectsdef.py, line 73 in get_returned_object>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/utils/__init__.py, line 29 in newfunc>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/pynames.py, line 188 in get>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/pyobjectsdef.py, line 45 in _infer_returned>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/utils/__init__.py, line 41 in newfunc>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/oi/soi.py, line 22 in infer_returned_object>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/oi/objectinfo.py, line 90 in get_exact_returned>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/oi/objectinfo.py, line 96 in _args_to_textual>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/arguments.py, line 20 in get_arguments>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/arguments.py, line 33 in get_pynames>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/arguments.py, line 41 in _evaluate>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/evaluate.py, line 27 in eval_node>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/evaluate.py, line 32 in eval_node2>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/ast.py, line 39 in walk>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/evaluate.py, line 292 in _Subscript>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/evaluate.py, line 301 in _call_function>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/evaluate.py, line 27 in eval_node>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/evaluate.py, line 32 in eval_node2>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/ast.py, line 39 in walk>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/evaluate.py, line 292 in _Subscript>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/evaluate.py, line 316 in _call_function>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/pyobjectsdef.py, line 73 in get_returned_object>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/utils/__init__.py, line 29 in newfunc>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/pynames.py, line 188 in get>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/pyobjectsdef.py, line 45 in _infer_returned>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/utils/__init__.py, line 41 in newfunc>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/oi/soi.py, line 25 in infer_returned_object>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/oi/soi.py, line 111 in _infer_returned>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/evaluate.py, line 27 in eval_node>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/evaluate.py, line 32 in eval_node2>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/ast.py, line 39 in walk>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/evaluate.py, line 292 in _Subscript>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/evaluate.py, line 303 in _call_function>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/pynamesdef.py, line 22 in get_object>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/utils/__init__.py, line 29 in newfunc>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/pynames.py, line 188 in get>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/utils/__init__.py, line 29 in newfunc>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/pynamesdef.py, line 19 in _get_inferred>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/utils/__init__.py, line 41 in newfunc>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/oi/soi.py, line 71 in infer_assigned_object>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/utils/__init__.py, line 41 in newfunc>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/oi/soi.py, line 142 in _infer_assignment>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/utils/__init__.py, line 41 in newfunc>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/oi/soi.py, line 175 in _follow_pyname>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/evaluate.py, line 27 in eval_node>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/evaluate.py, line 32 in eval_node2>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/ast.py, line 39 in walk>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/evaluate.py, line 162 in _Call>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/evaluate.py, line 283 in _get_primary_and_object_for_node>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/evaluate.py, line 32 in eval_node2>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/ast.py, line 39 in walk>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/evaluate.py, line 155 in _Attribute>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/pynamesdef.py, line 42 in get_object>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/pyobjectsdef.py, line 69 in get_parameter>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/utils/__init__.py, line 29 in newfunc>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/pynames.py, line 188 in get>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/pyobjectsdef.py, line 40 in _infer_parameters>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/utils/__init__.py, line 41 in newfunc>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/oi/soi.py, line 47 in infer_parameter_objects>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/oi/soi.py, line 130 in _parameter_objects>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/oi/type_hinting/providers/inheritance.py, line 21 in __call__>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/oi/type_hinting/providers/composite.py, line 19 in __call__>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/oi/type_hinting/providers/docstrings.py, line 46 in __call__>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/rope/base/oi/type_hinting/providers/numpydocstrings.py, line 20 in __call__>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/site-packages/numpydoc/docscrape.py, line 123 in __init__>, <FrameSummary file /Users/klay6683/miniconda3/envs/stable/lib/python3.6/textwrap.py, line 430 in dedent>]
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugIssue identified by VS Code Team member as probable bugIssue identified by VS Code Team member as probable bug
Activity
fernandocollova commentedon Jan 8, 2018
I had the exact same problem in a a setup almost like yours (except for the OS, that in my case was Fedora 27) and I worked around it by configuring vscode to use Python3.5
If that's a possibility for you (Like, if you don't NEED Python3.6, and you can install Python3.5 in your system) you can search for
python.pythonPathin the configs and change it to whatever runningwhich python35in a terminal returns.ericsnowcurrently commentedon Jan 22, 2018
Thanks for reporting this problem. Unfortunately, I was unable to reproduce this using stock Python 3.6 (3.6.4) on linux. So we'll need a bit more info.
FWIW, we use a tool for "Rename Symbol" called rope, which the extension installs under your configured interpreter when needed. Unfortunately Python 3 support in rope is still incomplete. It may be that the version of rope you have installed (i.e. via anaconda) is just old enough to have issues here. I have version 0.10.7 installed. Could you let us know which version you have. You can check by running the following at your interpreter's REPL:
We can go from there.
michaelaye commentedon Jan 23, 2018
I cannot reproduce the problem anymore. Anaconda also is using 0.10.7 of rope, so that can't be it.
Recent updates on conda were a bit iffy, so maybe something was messed up with my virtual envs. Sorry for the noise.
te0006 commentedon Mar 9, 2018
problem still exists in Anaconda3-5.1.0-Windows-x86_64 (VS Code 1.20.1, rope 0.10.7) on Win10_x64.
22 remaining items
brettcannon commentedon Dec 11, 2018
Shivendra Sharma (@shivendra90) we are working to subsume the functionality provided by Rope into our language server (i.e. renaming is currently supported, working on refactoring).
shivendra90 commentedon Dec 12, 2018
That would be very beneficial. Looking forward to it!
marknormanread commentedon Dec 18, 2018
Uninstalling numpydoc with "pip uninstall numpydoc" worked for me immediately; didn't even need to re-launch anything.
Jimtomr commentedon Dec 31, 2018
uninstalled numpydoc, it works.
jonha892 commentedon Mar 16, 2019
I have the same error but I don't have numpydoc installed.
Here is a list of all currently installed python packages, if that is of any help.
https://gist.github.com/J0-nas/6e2811498dd6076ca960cb6816492c57
brettcannon commentedon Jul 29, 2019
Closing as this is an upstream issue which we don't have direct control or influence over.
michaelaye commentedon Jul 29, 2019
Whatever happened to:
?
brettcannon commentedon Jul 30, 2019
Michael Aye (@michaelaye) we have already landed support in the language server (see #3977 on how to turn it on). Please give it a try and if you run into any issues please file them at https://github.com/microsoft/python-language-server.
michaelaye commentedon Jul 30, 2019
i'm just very confused now, either you can't fix it b/c it's upstream, or you implemented the solution in the language server? Or did you mean you can't fix it for the cases where people don't use the language server?
brettcannon commentedon Jul 31, 2019
Michael Aye (@michaelaye) we can't fix rope, so if you're using Jedi (and thus Rope) we can't really do much about it. If you use the language server instead of Jedi you get refactoring support provided by us directly. So I think the answer is "yes" to your last question.
michaelaye commentedon Jul 31, 2019
Thanks for the clarification, that makes sense. Considering the general title it looked like you wouldn't care about making refactoring work, but I guess that's one of the reasons why you built your own language server and features, I guess. Thanks again!
[-]Refactor errors[/-][+]Refactor errors with Rope[/+]