Comments (38)
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
from vscode-python.
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__>]
from vscode-python.
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
from vscode-python.
@singularitti we have no recommendation beyond the latest release.
from vscode-python.
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)
from vscode-python.
Did anywhere exist other extension support renaming variable of python code within vscode? I could not find one on the extensions panel.
from vscode-python.
@calvin620707 correct, but the new language server has built-in support (at least in the beta channel as of version 0.2.53).
from vscode-python.
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
.
- Sometimes I get "No Result" popup
- Sometimes it actually renames
y
toyy
. - Sometimes it names
z
toyy
, and in these cases,y
stays asy
!?!
I'm not sure how to get any of the output logs I've seen on other threads.
from vscode-python.
We're actively working to getting renaming working with our new language server which should replace our need to rely on Rope.
from vscode-python.
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.
from vscode-python.
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.
from vscode-python.
@puzzler10 can you open a new issue?
from vscode-python.
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.
from vscode-python.
@fredrikaverpil the trickiness with this is knowing whether this is our fault or rope not working properly.
from vscode-python.
@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 😉
from vscode-python.
@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!
from vscode-python.
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
from vscode-python.
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.
from vscode-python.
Fails for me sometimes as well. Here's a screenshot with an actual error.
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 |
from vscode-python.
same here.
from vscode-python.
I'm currently working on a project with a friend on a windows machine, but with a slightly different setup in that he's not using the portable version. He said that refactoring worked for him. I'll report back if we gain any insights.
from vscode-python.
Regarding my problem, I think it was because the current file I was refactoring didn't import the relevant package. That's the difference between global find-replace (Cmd+Shift+H) and refactoring. So it might be that, at least in my case, it actually worked as it should.
EDIT: However I still get the problem for real from time to time.
from vscode-python.
I just got this problem when renaming the properties of a class in Typescript. It successfully renamed them in normal .ts
files, but skipped renaming in all of my test .spec.ts
files.
from vscode-python.
I also cannot rename symbols. For me, it fails with this error:
[Error - 2:46:11 PM] Request textDocument/rename failed.
Message: unknown document
Code: -32000
[object Object]
I am trying to rename an import at the beginning of the file
from vscode-python.
in Version 1.28.2 I get a stack trace when the error happens:
[Error - 5:30:01 PM] Request textDocument/rename failed.
Message: unknown document
Code: -32000
at Microsoft.Python.LanguageServer.Implementation.ProjectFiles.GetEntry(Uri documentUri, Boolean throwIfMissing)
at Microsoft.Python.LanguageServer.Implementation.Server.FilterPrivatePrefixed(Dictionary`2 refs, String originalName, String privatePrefix, String newName, Uri documentReaderUri, IDocumentReader documentReader)
at Microsoft.Python.LanguageServer.Implementation.Server.Rename(RenameParams params, CancellationToken cancellationToken)
at Microsoft.Python.LanguageServer.Implementation.LanguageServer.Rename(JToken token, CancellationToken cancellationToken)
And this is the code where it fails:
def get_sample(self, shape):
noise = np.random.uniform(size=shape)
salt = (noise > self.amount).astype(np.uint8) * 255
grains = np.transpose(salt.nonzero())
for grain_pos in grains:
new_pos = np.copy(grain_pos)
for _ in range(np.random.randint(self.chain_length)):
n = random.choice(neighbours)
if not is_inside(noodle, new_pos + n):
continue
# set_trace()
new_pos += n
noodle[new_pos[0], new_pos[1]] = 255
Trying to rename n
into neighbour
from vscode-python.
@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.
from vscode-python.
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.
from vscode-python.
No worky for me. Box closes, no change. Using current insiders
from vscode-python.
same issue, can not solve it. "find all references" stopped working as well.
from vscode-python.
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?
from vscode-python.
I added python.jediEnabled": true
in the settings.json
, temporary solution.
from vscode-python.
FAIL CASE
Rename Symbol ALWAYS fails without error when NO WORKSPACE FOLDER is open. (#5301)
from vscode-python.
Are there any plans to fix this? I'm still getting this with Version: 1.35.1
from vscode-python.
@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.
from vscode-python.
@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.
from vscode-python.
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?
from vscode-python.
@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).
from vscode-python.
Closing as this is an upstream issue which we don't have direct control or influence over.
from vscode-python.
Related Issues (20)
- REPL check box is empty HOT 1
- Test web issue report
- Environments HOT 1
- Python 2.7 should not be reported by Native Locator
- Ensure base environments are named `base` in the quick pick when using Native Locator
- Python Interpreter not working HOT 1
- Python REPL conflicts with Jupyter IW HOT 1
- Create tests for Python REPL
- Python REPL should omit empty output
- Have smart send work with native REPL
- Support interrupt for Python REPL-Windows
- Rename existing Start Python REPL to Terminal REPL
- python.execInREPL steals shift+enter HOT 3
- Test Explorer duplicates tests when test name is same and parameterized fixture is shared across multiple classes. HOT 1
- python debugger ignores breakpoints?
- index1.py HOT 2
- Read launch config from devcontainer file
- Replaces User home with ~ HOT 2
- Load signal on test discovery
- Update tests for testController.ts
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vscode-python.