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

Rename does not rename methods across classes in hierarchy #813

Closed
NorbertHauriel opened this issue Jan 6, 2021 · 6 comments
Closed

Rename does not rename methods across classes in hierarchy #813

NorbertHauriel opened this issue Jan 6, 2021 · 6 comments
Assignees
Labels
enhancement New feature or request fixed in next version (main) A fix has been implemented and will appear in an upcoming version

Comments

@NorbertHauriel
Copy link

Issue Type: Bug

If I refactor rename an overridden method, it does not rename the base class method, and vice versa. Also, no references are found. Basically, intellisense has no knowledge of polymorhpism, which can cause havoc in a large codebase, if someone does not know about this lack of feature.

I will provide additional info if needed.

Extension version: 2020.12.2
VS Code version: Code 1.52.1 (ea3859d4ba2f3e577a159bc91e3074c5d85c0523, 2020-12-16T16:34:46.910Z)
OS version: Windows_NT x64 10.0.17134

System Info
Item Value
CPUs Intel(R) Core(TM) i5-4460 CPU @ 3.20GHz (4 x 3200)
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) 7.94GB (1.25GB free)
Process Argv --crash-reporter-id 504acee2-a3ea-41ce-a1e2-99e1630d8500
Screen Reader no
VM 0%
A/B Experiments
vsliv368:30146709
vsreu685:30147344
openlogontheside:30221877
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
vswsl492:30211401
wsl2prompt:30224612
pythonvsdeb440:30237827
unusedpromptcf:30224611
folderexplorercf:30224615
openfilemenu:30224647
pythonvsded773cf:30236630
pythonvspyt859:30241729

@github-actions github-actions bot added the triage label Jan 6, 2021
@NorbertHauriel NorbertHauriel changed the title Intellisense ignores overridden method Intellisense ignores inheritance Jan 6, 2021
@judej judej added needs decision Do we want this enhancement? needs investigation Could be an issue - needs investigation labels Jan 7, 2021
@github-actions github-actions bot removed the triage label Jan 7, 2021
@NorbertHauriel
Copy link
Author

Furthermore, docstring of base method is not inherited in child method, even when there is no child method docstring.

@jakebailey jakebailey changed the title Intellisense ignores inheritance Rename does not rename methods across classes in hierarchy Jan 11, 2021
@jakebailey
Copy link
Member

The original issue was about renaming class methods within a hierarchy, which requires some discussion/thought about what we think is the "correct" behavior; we currently have the safer behavior of not trying to modify a bunch of classes due to a rename.

That docstring example is a different issue, but I'd be curious to see the example because that would indicate there's a bug in the inheritance code as a whole (as we definitely find docstrings). Do you have a codebase that reproduces this?

@NorbertHauriel
Copy link
Author

NorbertHauriel commented Jan 12, 2021

Here I show you a demonstration where

  • method renaming
  • docstring inheritance
  • reference finding

Don't work on my side. In the attached gif, I don't show the renaming, because that is not the root cause of this problem, just a symptom of not finding references. Shall I open another issue based on this gif?

VS Code Pylance bug demonstration

@jakebailey
Copy link
Member

Hm, I guess I don't see that behavior as "wrong" per se; there are no uses of the child method; finding references to the child method shouldn't be going back to the base class the base class technically doesn't call the child class. Would have to see how this is done in other LSs.

RE: docs, I'd be interested in seeing what help says about each of these items in the child class; does Python's own builtin functions go to the base class for overriden functions? From it's POV, I'd have thought it would hit the function and say "no doc" because it can't really know that it's an override without walking the entire MRO to find one... but I know we can choose to do something different in the editor.

@NorbertHauriel
Copy link
Author

Local refactoring works very well as I've tried it, hoping that in the future, more advanced refactoring options will be possible in Pylance. Thank you for what we already have!

@jakebailey jakebailey added the enhancement New feature or request label Sep 1, 2021
@heejaechang heejaechang removed the needs investigation Could be an issue - needs investigation label Mar 17, 2022
@heejaechang heejaechang self-assigned this Mar 23, 2022
@heejaechang heejaechang removed the needs decision Do we want this enhancement? label Mar 23, 2022
@heejaechang heejaechang added the fixed in next version (main) A fix has been implemented and will appear in an upcoming version label Apr 7, 2022
@heejaechang
Copy link
Contributor

This issue has been fixed in version 2022.4.1, which we've just released. You can find the changelog here: CHANGELOG.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request 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

4 participants