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

Code prompt docstring displays incorrectly #6419

Open
xiaosiyu0603 opened this issue Sep 21, 2024 · 3 comments
Open

Code prompt docstring displays incorrectly #6419

xiaosiyu0603 opened this issue Sep 21, 2024 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@xiaosiyu0603
Copy link

xiaosiyu0603 commented Sep 21, 2024

Environment data

  • VS Code version: 1.93.1 (system setup) 38c31bc77e0dd6ae88a4e9cc93428cc27a56ba40
  • Electron: 30.4.0
  • ElectronBuildId: 10073054
  • Chromium: 124.0.6367.243
  • Node.js: 20.15.1
  • V8: 12.4.254.20-electron.0
  • Pylance version: v2024.9.1
  • OS and version: Windows 10 22H2 (Windows_NT x64 10.0.19045.4894)
  • Python version (& distribution if applicable, e.g. Anaconda): Python 3.11.5

Another PC with Windows 11, latest release VS Code and Python 3.11.7 has the same phenomenon.

Code Snippet

class BinFileReaderBase():

    ...

    def read_file(self, filename: str):
        """
            实现文件读取功能

            Args:
            ------
            `filename`: str
                要读取的二进制文件

            Return:
            ------
            `file_read`: bool
                是否成功读取文件
        """
        ...

    ...

Repro Steps

Type in the code, and mouse over function or method. Code prompt only shows the first line of docstring.

Expected behavior

Display code documents like this:

图片

Actual behavior

图片

Seems that specific strings - at present I found Args:, Params: and Parameters: (with colon) - can cause the error.

Logs

I'm not sure if log refers to this --

2024-09-21 13:38:25.672 [info] (44828) [FG] parsing: file:///d%3A/Home/Desktop/ttttt.py (1ms)
2024-09-21 13:38:25.672 [info] (44828) [FG] binding: file:///d%3A/Home/Desktop/ttttt.py (0ms)
2024-09-21 13:38:25.920 [info] (44828) [BG(1)] SemanticTokens delta previousResultId:1726897061467 at file:///d%3A/Home/Desktop/ttttt.py ...
2024-09-21 13:38:25.920 [info] (44828) [BG(1)]   parsing: file:///d%3A/Home/Desktop/ttttt.py (1ms)
2024-09-21 13:38:25.920 [info] (44828) [BG(1)]   binding: file:///d%3A/Home/Desktop/ttttt.py (0ms)
2024-09-21 13:38:25.925 [info] (44828) [BG(1)] SemanticTokens delta previousResultId:1726897061467 at file:///d%3A/Home/Desktop/ttttt.py (5ms)
2024-09-21 13:38:25.927 [info] (44828) [BG(1)] analyzing: file:///d%3A/Home/Desktop/ttttt.py ...
2024-09-21 13:38:25.927 [info] (44828) [BG(1)]   checking: file:///d%3A/Home/Desktop/ttttt.py (2ms)
2024-09-21 13:38:25.927 [info] [Info  - 13:38:25] (44828) Heap stats: total_memory_size=16236MB, total_free_size=4937MB, total_heap_size=38MB, used_heap_size=36MB, cross_worker_used_heap_size=36MB, total_physical_size=38MB, total_available_size=4060MB, heap_size_limit=4096MB
2024-09-21 13:38:25.927 [info] (44828) [BG(1)] analyzing: file:///d%3A/Home/Desktop/ttttt.py (2ms)
2024-09-21 13:38:25.940 [info] (44828) [BG(1)] SemanticTokens delta previousResultId:1726897105919 at file:///d%3A/Home/Desktop/ttttt.py (1ms)
2024-09-21 13:38:36.126 [info] (44828) Attempting to resolve using local imports: 要读取的二进制文件


2024-09-21 13:38:36.126 [info] (44828) Attempting to resolve using root path 'file:///d%3A/Home/Desktop'
2024-09-21 13:38:40.921 [info] (44828) Attempting to resolve using local imports: 实现文件读取功能


2024-09-21 13:38:40.921 [info] (44828) Attempting to resolve using root path 'file:///d%3A/Home/Desktop'
2024-09-21 13:38:56.430 [info] [Info  - 13:38:56] (44828) Heap stats: total_memory_size=16236MB, total_free_size=4926MB, total_heap_size=41MB, used_heap_size=39MB, cross_worker_used_heap_size=39MB, total_physical_size=41MB, total_available_size=4057MB, heap_size_limit=4096MB
@github-actions github-actions bot added the needs repro Issue has not been reproduced yet label Sep 21, 2024
@KacieKK
Copy link
Contributor

KacieKK commented Sep 23, 2024

Thanks for reporting this issue. I can reproduce it.
In the meantime, we recommend using our new feature for docstring generation.
Use this setting to turn on our native support for the docstring template:
"python.analysis.supportDocstringTemplate" : true
With this, you could trigger a docstring template using completion in your function

def read_file(self, filename: str):
    """
    |<--- Trigger completion here
    """
    file_read : bool
    return file_read

Modify as you like

def read_file(self, filename: str):
    """
    Docstring for read_file
    
    :param filename: 要读取的二进制文件
    :type filename: str 
    :return: 是否成功读取文件
    :rtype: bool
    """
    file_read : bool
    return file_read

It will be rendered this way
image

@debonte debonte added bug Something isn't working and removed needs repro Issue has not been reproduced yet labels Sep 23, 2024
@xiaosiyu0603
Copy link
Author

Thanks a lot!

But I didn't find python.analysis.supportDocstringTemplate works in my latest release VS Code, maybe I should wait for future upgrades.

Further more, I found a new mistakes with code like this:

class A():
    """
        some docs

        ```c
            double a[10];
        ```

        some docs
    """

@KacieKK
Copy link
Contributor

KacieKK commented Sep 24, 2024

Yeah, it's best to use this setting in the next stable 2024.10.1, which will be out approximately next week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants