【发布时间】:2017-03-28 16:20:28
【问题描述】:
如何在下面的函数中定义文档字符串?
def get_object(klass, **kwargs):
"""
:rtype: ???
"""
# perform some tasks
return klass(**kwargs)
我试过klass,type(klass),klass.__class__,
它们都不能在单独的模块文件中工作:
from sample.utils import get_object
from sample.models import User
u = get_object(User, name='test')
u. # no PyCharm hint here
我也试过:type klass: T 和:rtype: T,也没有工作:(
PyCharm 可以在 docstring 中支持这种语法吗? 如何记录?
【问题讨论】:
标签: python pycharm typing docstring