Search code examples
python-3.xvisual-studio-codedocstring

Where does VSCode get the docstring signature?


Where does the VSCode get docstring signatures? I could not find any relevant section in the settings.

In my installation, it is clear that VSCode is not using the signature from the __doc__ attribute. I would like to see the __doc__ (or set it to output of pydoc), but I am getting something like below

enter image description here

Here is the signature I get from __doc__ or pydoc

print(value, ..., sep=' ', end='\\n', file=sys.stdout, flush=False)

Solution

  • It looks like it's pulling them from mypy's stub files as well as a portion of the docstring.

    The stub files for builtins and the standard library can be found at. <python path>\Lib\site-packages\mypy\typeshed\stdlib\. The print statement in particular can be found in __builtin__.pyi in the 2 folder around line 1354.

    if sys.version_info >= (3,):
        class _Writer(Protocol):
            def write(self, __s: str) -> Any: ...
        def print(
            *values: object, sep: Optional[Text] = ..., end: Optional[Text] = ..., file: Optional[_Writer] = ..., flush: bool = ...
        ) -> None: ...
    

    Github link to the relevant line. This is a newer version so it's not entirely identical.