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

Moving Folders And Multiple Files - Python Imports Not Refactoring #24909

Open
RealTachyon opened this issue Mar 17, 2025 · 0 comments
Open

Moving Folders And Multiple Files - Python Imports Not Refactoring #24909

RealTachyon opened this issue Mar 17, 2025 · 0 comments
Labels
triage-needed Needs assignment to the proper sub-team

Comments

@RealTachyon
Copy link

Type: Bug

Behaviour

When moving a folder within a python workspace to another location, all the modules that reference relative imports to another location outside the folder are not automatically updated.

The automatic update behavior is only executed when a single file is moved at once.

The same breaking behavior can be observed when multiple (2 or more) files are moved at the same time to a new folder.

Original structure:
As a screenshot
Image
As a zip
parent_folder.zip

Correct behavior

Moving a single file

Steps to Reproduce:

  1. Write out the structure that's given in the screenshot. (You can also find it as an attachment to this post.)
  2. Drag and drop the "animal.py" file into the "new_source_module" folder.
  3. Observe that the imports in the "human.py" are correctly updated to reflect the new location.
    The import line changed from
    from ..source_modules.animal import Animal
    to
    from ..new_source_modules.animal import Animal

Problematic behavior

Moving folders

Steps to Reproduce:

  1. Write out the structure that's given in the screenshot. (You can also find it as an attachment to this post.)
  2. Drag and drop the "source_modules" folder into the "new_source_module" folder.
  3. Observe that the imports in the "human.py" are not updated to reflect the new locations.

Moving multiple files

Steps to Reproduce:

  1. Write out the structure that's given in the screenshot. (You can also find it as an attachment to this post.)
  2. Drag and drop the "animal.py" and "toy.py" files into the "new_source_module" folder.
  3. Observe that the imports in the "human.py" are not updated to reflect the new locations.

See also the issue here

Diagnostic data

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

2025-03-17 13:41:41.574 [info] Experiment 'pythonRecommendTensorboardExt' is active
2025-03-17 13:41:41.575 [info] Experiment 'pythonTerminalEnvVarActivation' is active
2025-03-17 13:41:41.575 [info] Experiment 'pythonTestAdapter' is active
2025-03-17 13:41:41.575 [info] Native locator: Refresh started
2025-03-17 13:41:41.575 [info] > pyenv which python
2025-03-17 13:41:41.575 [info] cwd: .
2025-03-17 13:41:42.684 [info] Poetry environment manager found at: C:\Users\David\AppData\Local\Programs\Python\Python313\Scripts\poetry.exe
2025-03-17 13:41:42.763 [info] Python interpreter path: ~\AppData\Local\Programs\Python\Python313\python.exe
2025-03-17 13:41:43.690 [info] Native locator: Refresh finished in 9555 ms
2025-03-17 13:41:53.726 [info] Starting Pylance language server.
2025-03-17 13:43:53.296 [info] > conda info --json
2025-03-17 13:59:12.530 [info] Discover tests for workspace name: playground_2 - uri: l:\Programming\Python\Projects\Experiments\playground_2\refactoring_test\source_stuff\toy.py
2025-03-17 13:59:20.428 [info] Discover tests for workspace name: playground_2 - uri: l:\Programming\Python\Projects\Experiments\playground_2\refactoring_test\target_stuff\human.py
2025-03-17 13:59:22.064 [info] Discover tests for workspace name: playground_2 - uri: l:\Programming\Python\Projects\Experiments\playground_2\refactoring_test\target_stuff\human.py
2025-03-17 15:51:17.950 [info] Discover tests for workspace name: undefined - uri: c:\Users\David\AppData\Roaming\Code\User\settings.json
2025-03-17 15:54:37.547 [info] Experiment 'pythonRecommendTensorboardExt' is active
2025-03-17 15:54:37.547 [info] Experiment 'pythonTerminalEnvVarActivation' is active
2025-03-17 15:54:37.547 [info] Experiment 'pythonTestAdapter' is active
2025-03-17 15:54:37.547 [info] Native locator: Refresh started
2025-03-17 15:54:37.564 [info] > pyenv which python
2025-03-17 15:54:37.564 [info] cwd: .
2025-03-17 15:54:38.048 [info] Poetry environment manager found at: C:\Users\David\AppData\Local\Programs\Python\Python313\Scripts\poetry.exe
2025-03-17 15:54:38.051 [info] Python interpreter path: ~\AppData\Local\Programs\Python\Python313\python.exe
2025-03-17 15:54:38.125 [info] Native locator: Refresh finished in 640 ms
2025-03-17 15:54:38.797 [info] Starting Pylance language server.

Extension version: 2025.2.0
VS Code version: Code 1.98.2 (ddc367ed5c8936efe395cffeec279b04ffd7db78, 2025-03-12T13:32:45.399Z)
OS version: Windows_NT x64 10.0.19045
Modes:

  • Python version (& distribution if applicable, e.g. Anaconda): 3.13.1
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): System
  • Value of the python.languageServer setting: Default
User Settings


languageServer: "Pylance"

Installed Extensions
Extension Name Extension Id Version
debugpy ms- 2025.4.1
js-debug ms- 1.97.1
js-debug-companion ms- 1.1.3
python ms- 2025.2.0
vscode-js-profile-table ms- 1.0.10
vscode-pylance ms- 2025.3.2
System Info
Item Value
CPUs AMD Ryzen Threadripper 2970WX 24-Core Processor (48 x 2994)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) undefined
Memory (System) 95.88GB (53.22GB free)
Process Argv --crash-reporter-id 0f924fbb-88c9-44bf-bd09-f8e30396fdf9 --crash-reporter-id 0f924fbb-88c9-44bf-bd09-f8e30396fdf9
Screen Reader no
VM 0%
A/B Experiments
vsliv368:30146709
vspor879:30202332
vspor708:30202333
vspor363:30204092
vscod805cf:30301675
binariesv615:30325510
py29gd2263:31024239
vscaat:30438848
c4g48928:30535728
azure-dev_surveyone:30548225
962ge761:30959799
h48ei257:31000450
pythontbext0:30879054
cppperfnew:31000557
dwnewjupytercf:31046870
nativerepl1:31139838
pythonrstrctxt:31112756
nativeloc1:31192215
iacca1:31171482
5fd0e150:31155592
dwcopilot:31170013
6074i472:31201624
dwoutputs:31242946
customenabled:31248079
hdaa2157:31222309
copilot_t_ci:31222730
968h8231:31259996
jda6j935:31233686
pythoneinst12:31257679
fh1c7952:31258891
4gafe986:31261448
31787653:31256342

@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Mar 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage-needed Needs assignment to the proper sub-team
Projects
None yet
Development

No branches or pull requests

1 participant