Rename Refactor does not work for packages with __init__ and PYTHONPATH
See original GitHub issueEnvironment data
- VS Code version: 1.52.1
- Extension version (available under the Extensions sidebar): 2020.12.424452561
- OS and version: WIN 10
- Python version (& distribution if applicable, e.g. Anaconda): 3.6, 64 bit
- Type of virtual environment used (N/A | venv | virtualenv | conda | …): N/A
- Relevant/affected Python packages and their versions: rope, latest version
- Relevant/affected Python-related VS Code extensions and their versions:
- Value of the
python.languageServer
setting: Pylance
Expected behaviour
Refactor works in both ways regardess of how module import is implemented.
Actual behaviour
We have a following setup:
-
Project script(s) on a location A
-
Packages (internal libraries) on a locations B, C, D, … Each of these packages have its own __init__.py file, where relevant modules are imported. User use these libs as
B.<something>
,B.<somethingElse>
-
We have VSC workspace on a location A, but we open it with a batch file, that sets PYTHONPATH so all libs (B, C, D) are available to a project on A.
The problem is that refactoring does not work in both ways, meaning:
- we can navigate to func definition, for example
B.something.func()
and refactor it there. This works, all relevant locations in VSC workspace are fixed, including scripts in A that useB.something.func()
- however, we can’t refactor
B.something.func()
directly from script from A. VSC just showNo results
and that is it.
I assume this is not as expected, since, for example, refactorTest.zip
PyCharm seems to handle this scenario somehow.
Steps to reproduce:
- Open appended workspace via: SET_PYHON_PATH_OPEN_VSC.bat
- Navigate to proj/app.py ->
useLib()
. Refactorlib.m1.func1()
func1
to whatever. Will fail. - Navigate to
func1()
definition with F12. Refactor it to whatetever, will succeed.
Logs
No log statement is generated. However, GUI pop-up is issued, showing only: No results
.
System Info
Item | Value |
---|---|
CPUs | Intel® Core™ i7-6820HQ CPU @ 2.70GHz (8 x 2712) |
GPU Status | 2d_canvas: enabled flash_3d: enabled flash_stage3d: enabled flash_stage3d_baseline: enabled gpu_compositing: enabled multiple_raster_threads: enabled_on oop_rasterization: disabled_off opengl: enabled_on protected_video_decode: unavailable_off rasterization: enabled skia_renderer: disabled_off_ok video_decode: enabled vulkan: disabled_off webgl: enabled webgl2: enabled |
Load (avg) | undefined |
Memory (System) | 15.92GB (5.24GB free) |
Process Argv | –crash-reporter-id 919e0ed9-46f3-4ad4-9e28-f35755bf8266 |
Screen Reader | no |
VM | 0% |
A/B Experiments
vsliv368cf:30146710
vsreu685:30147344
openlogontheside:30221877
python763:30178808
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
python504:30227505
vswsl492:30211401
wsl2prompt:30224612
pythonvsdeb440:30237827
unusedpromptcf:30224611
folderexplorer:30224614
openfilemenu:30224647
pythonvsded773cf:30236630
pythonvspyt859:30237612
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (7 by maintainers)
Top GitHub Comments
@schperplata sorry for the back-and-forth on this. We plan to move to using Jedi for refactoring (#11333) which will then cause us to drop support for Rope (#10440). I will leave this issue open, though, as a reminder of the bug for anyone else who comes across it.
@schperplata actually the absolutely critical bit was what language server you were using which you did not specify.
And while we do appreciate you taking the time to report issues, do also note that our issue volume isn’t small, so we need to be somewhat aggressive in closing issues as the vast majority of people who skip our template never give us the info we need. It’s easier for us to reopen issues for those that do take the time to fill in the info than it is to leave things open and wait for a reply (which is what used to happen to us).
Regardless, Pylance handles refactorings so I am transferring your issue to them.