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

Underscores are escaped with backslashes in Docstrings when writing Python in Visual Studio Code #528

Closed
StevenTeglman opened this issue Oct 27, 2020 · 3 comments
Labels
waiting for user response Requires more information from user

Comments

@StevenTeglman
Copy link

Environment data

  • VS Code version: 1.50.1
  • Extension version (available under the Extensions sidebar): v2020.9.114305
  • OS and version: Windows 10 Home, v10.0.18363 Build 18363
  • Python version (& distribution if applicable, e.g. Anaconda): 3.8.6 64-bit
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): venv
  • Relevant/affected Python packages and their versions: N/A
  • Relevant/affected Python-related VS Code extensions and their versions: N/A
  • Value of the python.languageServer setting: Microsoft and/or Pylance

[NOTE: If you suspect that your issue is related to the Microsoft Python Language Server (python.languageServer: 'Microsoft'), please download our new language server Pylance from the VS Code marketplace to see if that fixes your issue]

Expected behaviour

Show the document popup with a value of as:
tex_t (String): The text you want to print.

Actual behaviour

Any underscores in the Docstrings are preceded by a backslash
tex_t (String): The text you want to print.
Capture

Steps to reproduce:

[NOTE: Self-contained, minimal reproducing code samples are extremely helpful and will expedite addressing your issue]

  1. Copy and paste this:
def printl(text):
    """
    Clears the console and prints whatever text is inputed, under a heading.

    Parameters
    ----------
    tex_t (String) : The text you want to print.

    Returns
    -------
        Nothing
    """
    return
  1. Type in "printl(" and look the code preview

Note

After changing the python.languageServer setting, I found out this is only produced if set to Microsoft or Pylance. Setting it to Jedi eliminates the problem.

@brettcannon brettcannon transferred this issue from microsoft/vscode-python Oct 27, 2020
@jakebailey
Copy link
Member

This doesn't reproduce as written above:

image

However, I believe you may be missing the indent in the Parameters section in your code snippet. Is that correct?

If you did have it indented, then this would be a dupe of #48, as we're treating indented blocks as code blocks (per RST and markdown), but this specific docstring format is I believe the numpy one which has a different syntax.

@jakebailey jakebailey added the waiting for user response Requires more information from user label Oct 27, 2020
@github-actions github-actions bot removed the triage label Oct 27, 2020
@StevenTeglman
Copy link
Author

I added an indent, yet the problem persists.
image

@jakebailey
Copy link
Member

The indent is what causes the problem; removing it makes the text not monospace and you don't see the escaping.

This is a dupe of #48, then, since this format will take special care due to the differences between it and regular reStructuredText or Markdown.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting for user response Requires more information from user
Projects
None yet
Development

No branches or pull requests

2 participants