docstrings in python stub files (*.pyi)

Viewed 411

I have a python module used in production. This module is very old, that's why it doesn't have type annotations or docstrings. I can't modify this module. Using stub files (.pyi) I can write type annotations without any changes in the working files. Unfortunatelly, when I add docstrings into stub files (.pyi), PyCharm will not use them.

hello.py

def hello_func(item):
    return [item]

hello.pyi

from typing import List, TypeVar

_T = TypeVar('_T')


    def hello_func(item):  # type: (_T) -> List[_T]
        """
        Wrap Item into list
        
        :param item: an object to wrap
        :return: A list with an ``item`` inside
        """
        ...

PyCharm doesn't show a docstring hint :(

enter image description here

0 Answers
Related