Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Symbol renaming not working in open file mode #1300

Closed
NemoYuan2008 opened this issue May 17, 2021 · 9 comments
Closed

Symbol renaming not working in open file mode #1300

NemoYuan2008 opened this issue May 17, 2021 · 9 comments
Labels
bug Something isn't working fixed in next version (main) A fix has been implemented and will appear in an upcoming version

Comments

@NemoYuan2008
Copy link

NemoYuan2008 commented May 17, 2021

  • Visual Studio Code Version: 1.56.2 (Universal)
  • Language Server version: 2021.5.2
  • OS and version: darwin arm64
  • Python version: Python 3.8.2 64-bit
  • python.analysis.indexing: undefined
  • python.analysis.typeCheckingMode: off

I'am editing a python script with no folders or workspaces open (using file>open to open a python script, with system-wide interpreter).
When renaming variable foo in the following code, the message No result. pops up.

foo = 1
print(foo)

Note that symbol renaming works fine if I'm editing a python script in a workspace, either with the system-wide interpreter or a virtualenv interpreter.

The output generated in python language server panel is shown below.

[Info  - 7:20:39 PM] Pylance language server 2021.5.2 (pyright df8b6b3c) starting
[Info  - 7:20:39 PM] Server root directory: /Users/yuan/.vscode/extensions/ms-python.vscode-pylance-2021.5.2/dist
[Info  - 7:20:39 PM] No pyproject.toml file found.
[Info  - 7:20:39 PM] Setting pythonPath for service "<default>": "/usr/bin/python3"
[Warn  - 7:20:39 PM] stubPath typings is not a valid directory.
[Info  - 7:20:39 PM] Assuming Python version 3.8
[Info  - 7:20:39 PM] Assuming Python platform Darwin
Search paths for 
  /Users/yuan/.vscode/extensions/ms-python.vscode-pylance-2021.5.2/dist/typeshed-fallback/stdlib
  
  typings
  /Users/yuan/.vscode/extensions/ms-python.vscode-pylance-2021.5.2/dist/typeshed-fallback/stubs/...
  /Users/yuan/.vscode/extensions/ms-python.vscode-pylance-2021.5.2/dist/bundled/stubs
  /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8
  /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/lib-dynload
  /Users/yuan/Library/Python/3.8/lib/python/site-packages
  /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages
  /Library/Python/3.8/site-packages
[Info  - 7:20:39 PM] Searching for source files
[Info  - 7:20:39 PM] No source files found.
[FG] parsing: /Users/yuan/test.py (9ms)
[FG] parsing: /Users/yuan/.vscode/extensions/ms-python.vscode-pylance-2021.5.2/dist/typeshed-fallback/stdlib/builtins.pyi [fs read 2ms] (57ms)
[FG] binding: /Users/yuan/.vscode/extensions/ms-python.vscode-pylance-2021.5.2/dist/typeshed-fallback/stdlib/builtins.pyi (18ms)
[FG] binding: /Users/yuan/test.py (0ms)
[Info  - 7:20:39 PM] Background analysis(1) root directory: /Users/yuan/.vscode/extensions/ms-python.vscode-pylance-2021.5.2/dist
[Info  - 7:20:39 PM] Background analysis(1) started
Background analysis message: setConfigOptions
Background analysis message: ensurePartialStubPackages
Background analysis message: setTrackedFiles
Background analysis message: markAllFilesDirty
Background analysis message: setFileOpened
Background analysis message: getDiagnosticsForRange
Background analysis message: getSemanticTokens full
[BG(1)] getSemanticTokens full at /Users/yuan/test.py ...
[BG(1)]   parsing: /Users/yuan/test.py (9ms)
[BG(1)]   parsing: /Users/yuan/.vscode/extensions/ms-python.vscode-pylance-2021.5.2/dist/typeshed-fallback/stdlib/builtins.pyi [fs read 1ms] (59ms)
[BG(1)]   binding: /Users/yuan/.vscode/extensions/ms-python.vscode-pylance-2021.5.2/dist/typeshed-fallback/stdlib/builtins.pyi (17ms)
[BG(1)]   binding: /Users/yuan/test.py (0ms)
[BG(1)]   parsing: /Users/yuan/.vscode/extensions/ms-python.vscode-pylance-2021.5.2/dist/typeshed-fallback/stdlib/typing.pyi [fs read 1ms] (19ms)
[BG(1)]   binding: /Users/yuan/.vscode/extensions/ms-python.vscode-pylance-2021.5.2/dist/typeshed-fallback/stdlib/typing.pyi (6ms)
[BG(1)]   parsing: /Users/yuan/.vscode/extensions/ms-python.vscode-pylance-2021.5.2/dist/typeshed-fallback/stdlib/_typeshed/__init__.pyi [fs read 0ms] (7ms)
[BG(1)]   binding: /Users/yuan/.vscode/extensions/ms-python.vscode-pylance-2021.5.2/dist/typeshed-fallback/stdlib/_typeshed/__init__.pyi (1ms)
[BG(1)]   parsing: /Users/yuan/.vscode/extensions/ms-python.vscode-pylance-2021.5.2/dist/typeshed-fallback/stdlib/typing_extensions.pyi [fs read 0ms] (2ms)
[BG(1)]   binding: /Users/yuan/.vscode/extensions/ms-python.vscode-pylance-2021.5.2/dist/typeshed-fallback/stdlib/typing_extensions.pyi (0ms)
[BG(1)] getSemanticTokens full at /Users/yuan/test.py (133ms)
Background analysis message: getSemanticTokens range
[BG(1)] getSemanticTokens range 0:0 - 2:0 at /Users/yuan/test.py (0ms)
Background analysis message: getDiagnosticsForRange
Background analysis message: analyze
[BG(1)] analyzing: /Users/yuan/test.py ...
[BG(1)]   checking: /Users/yuan/test.py (1ms)
[BG(1)] analyzing: /Users/yuan/test.py (1ms)
Background analysis message: resumeAnalysis
Background analysis message: getDiagnosticsForRange
Background analysis message: getDiagnosticsForRange
Background analysis message: getDiagnosticsForRange
Background analysis message: getDiagnosticsForRange
Background analysis message: getDiagnosticsForRange
Background analysis message: getDiagnosticsForRange
[FG] parsing: /Users/yuan/.vscode/extensions/ms-python.vscode-pylance-2021.5.2/dist/typeshed-fallback/stdlib/typing.pyi [fs read 4ms] (54ms)
[FG] binding: /Users/yuan/.vscode/extensions/ms-python.vscode-pylance-2021.5.2/dist/typeshed-fallback/stdlib/typing.pyi (7ms)
[FG] parsing: /Users/yuan/.vscode/extensions/ms-python.vscode-pylance-2021.5.2/dist/typeshed-fallback/stdlib/_typeshed/__init__.pyi [fs read 1ms] (10ms)
[FG] binding: /Users/yuan/.vscode/extensions/ms-python.vscode-pylance-2021.5.2/dist/typeshed-fallback/stdlib/_typeshed/__init__.pyi (2ms)
[FG] parsing: /Users/yuan/.vscode/extensions/ms-python.vscode-pylance-2021.5.2/dist/typeshed-fallback/stdlib/typing_extensions.pyi [fs read 0ms] (3ms)
[FG] binding: /Users/yuan/.vscode/extensions/ms-python.vscode-pylance-2021.5.2/dist/typeshed-fallback/stdlib/typing_extensions.pyi (0ms)
@jakebailey
Copy link
Member

Your template is missing trace logs; can you please provide them? https://github.com/microsoft/pylance-release/blob/main/TROUBLESHOOTING.md#filing-an-issue

You need to enable a specific setting to get trace logs, and if that's enabled there will definitely be lots of info.

@jakebailey jakebailey added the waiting for user response Requires more information from user label May 17, 2021
@github-actions github-actions bot removed the triage label May 17, 2021
@NemoYuan2008
Copy link
Author

NemoYuan2008 commented May 18, 2021

@jakebailey Thanks. I've added the trace logs in the python language panel above. All the logs were generated before renaming. No additional output was produced when I clicked "Rename Symbol" and tried to rename the variable. Can you please see what's going wrong?

@jakebailey
Copy link
Member

Thanks. I'm a bit concerned by this: "/Users/yuan/tests/issue/bin/python3"

What is your folder structure? Are you opening the virtual environment itself? I don't think your workspace should be containing the python binary itself, as that confuses what is actually the interpreter versus your user code.

@NemoYuan2008
Copy link
Author

NemoYuan2008 commented May 19, 2021

@jakebailey Thanks for reminding me. I'm new to virtualenv and I've mistakenly put the python script in the same directory as the virtual environment. The problem is solved when I put the environment files in a subdirectory of the project.

However, the problem still exists when editing a python script with no folders or workspaces open (using file>open to open a python script, with system-wide interpreter). I've updated my issue with the corresponding info.

@jakebailey
Copy link
Member

If you're using open file mode, then this is likely similar to #1301; the open folder / workspace modes are pretty well tested, but opening single files is less so.

@jakebailey jakebailey added needs investigation Could be an issue - needs investigation and removed waiting for user response Requires more information from user labels May 19, 2021
@NemoYuan2008 NemoYuan2008 changed the title Rename Symbol: No result. Symbol renaming not working in open file mode May 20, 2021
@DervishD
Copy link

I have the exact same problem, symbol renaming only works in open folder mode. I've tried to investigate the issue myself with no result (no pun intended).

@kodecraft
Copy link

Just wanted to chime in here that it is still a problem for me to rename symbols on a ** standalone ** (i.e. not in a virtual env) python file that is ** already saved **.

VSCode still returns "No Result" with no renaming actually performed if I tried to rename any symbol. I could not get trace log even after setting python.analysis.logLevel to 'Trace'.

My environment
Version: 1.58.2
Commit: c3f126316369cd610563c75b1b1725e0679adfb3
Date: 2021-07-14T22:10:15.214Z
Electron: 12.0.13
Chrome: 89.0.4389.128
Node.js: 14.16.0
V8: 8.9.255.25-electron.0
OS: Windows_NT x64 10.0.19043

@erictraut
Copy link
Contributor

This will be fixed in the next release. When in "single-file mode", the rename will be performed only within the current file. In "workspace mode", the rename will be performed across the workspace.

@erictraut erictraut added bug Something isn't working fixed in next version (main) A fix has been implemented and will appear in an upcoming version and removed needs investigation Could be an issue - needs investigation labels Aug 1, 2021
@heejaechang
Copy link
Contributor

heejaechang commented Aug 4, 2021

fixed in 2021.8.0 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed in next version (main) A fix has been implemented and will appear in an upcoming version
Projects
None yet
Development

No branches or pull requests

6 participants