Skip to content

Refactor errors with Rope #500

Closed
Closed

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_root variable 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>]

Activity

  1. fernandocollova commented on Jan 8, 2018

    @fernandocollova

    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.pythonPath in the configs and change it to whatever running which python35 in a terminal returns.

  2. ericsnowcurrently commented on Jan 22, 2018

    @ericsnowcurrently

    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:

    import rope
    rope.VERSION
    

    We can go from there.

  3. michaelaye commented on Jan 23, 2018

    @michaelaye
    Author

    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.

  4. te0006 commented on Mar 9, 2018

    @te0006

    problem still exists in Anaconda3-5.1.0-Windows-x86_64 (VS Code 1.20.1, rope 0.10.7) on Win10_x64.

  5. 22 remaining items

  6. brettcannon commented on Dec 11, 2018

    @brettcannon
    Member

    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).

  7. shivendra90 commented on Dec 12, 2018

    @shivendra90

    That would be very beneficial. Looking forward to it!

  8. marknormanread commented on Dec 18, 2018

    @marknormanread

    Uninstalling numpydoc with "pip uninstall numpydoc" worked for me immediately; didn't even need to re-launch anything.

  9. Jimtomr commented on Dec 31, 2018

    @Jimtomr

    uninstalled numpydoc, it works.

  10. jonha892 commented on Mar 16, 2019

    @jonha892

    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

  11. brettcannon commented on Jul 29, 2019

    @brettcannon
    Member

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

  12. michaelaye commented on Jul 29, 2019

    @michaelaye
    Author

    Whatever happened to:

    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).

    ?

  13. brettcannon commented on Jul 30, 2019

    @brettcannon
    Member

    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.

  14. michaelaye commented on Jul 30, 2019

    @michaelaye
    Author

    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?

  15. brettcannon commented on Jul 31, 2019

    @brettcannon
    Member

    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.

  16. michaelaye commented on Jul 31, 2019

    @michaelaye
    Author

    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!

  17. changed the title [-]Refactor errors[/-] [+]Refactor errors with Rope[/+] on Jul 31, 2019
  18. locked as resolved and limited conversation to collaborators on Aug 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue identified by VS Code Team member as probable bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions