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 symbol refactoring: docstrings have the blank line removed #4540

Closed
wgmo opened this issue Jun 26, 2023 · 2 comments
Closed

Moving symbol refactoring: docstrings have the blank line removed #4540

wgmo opened this issue Jun 26, 2023 · 2 comments
Assignees
Labels
bug Something isn't working fixed in next version (main) A fix has been implemented and will appear in an upcoming version P2

Comments

@wgmo
Copy link

wgmo commented Jun 26, 2023

Environment data

  • Language Server version: 2023.6.31
  • OS and version: Debian GNU/Linux 12 (bookworm) (running in WSL2 on Windows 11 Pro 22H2 22621.1848 Windows Feature Experience Pack 1000.22642.1000.0)
  • Python version (& distribution if applicable, e.g. Anaconda): 3.10.12

Code Snippet

The original content of the file a.py:

class A:
    def __init__(self, x):
        """Make an A from an x.

        This is more complicated than you might expect. That's why it needs a more
        detailed description down here, separated from the summary by a blank line.
        """

After refactoring by moving the symbol into the file b.py:

class A:
    def __init__(self, x):
        """Make an A from an x.
        This is more complicated than you might expect. That's why it needs a more
        detailed description down here, separated from the summary by a blank line.
        """

... note that the necessary blank line has disappeared from the docstring.

Repro Steps

  1. Enable the "move symbol" refactoring feature ("python.analysis.refactoring.allowMovingSymbols": true, in settings.json).
  2. Move a symbol which includes a docstring with a detailed description, separated from the summary by a blank line, to another file.

Note that it seems this problem affects all docstrings in the affected symbol (e.g. the docstrings for all methods in a class which is moved).

Expected behavior

The docstrings are preserved verbatim when the symbol has been refactored from file a.py to file b.py

Actual behavior

The docstrings are preserved in their textual content, but the required blank line between the summary and the detailed description is removed.

Logs

I can provide logs if necessary, but they're big so I'll only add them here if there's a specific need, the problem should be trivial to reproduce!

Great to see this refactoring feature approaching production, looking forward to seeing it make it into a release from prerelease!

@rchiodo
Copy link
Contributor

rchiodo commented Jun 26, 2023

Thanks for the issue.

Yes, it's very easy to repro. Hopefully it will be as easy to fix :)

@rchiodo rchiodo added bug Something isn't working triage-needed labels Jun 26, 2023
@debonte debonte added P2 and removed triage-needed labels Jun 26, 2023
@heejaechang heejaechang self-assigned this Jul 10, 2023
@PylanceBot PylanceBot added the fixed in next version (main) A fix has been implemented and will appear in an upcoming version label Jul 11, 2023
@heejaechang
Copy link
Contributor

This issue has been fixed in prerelease version 2023.7.21, 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
bug Something isn't working fixed in next version (main) A fix has been implemented and will appear in an upcoming version P2
Projects
None yet
Development

No branches or pull requests

5 participants