[英]Sphinx docstring: specify class type instead of object?
In Sphinx, say that you had a function that takes one parameter. 在Sphinx中,假设您有一个采用一个参数的函数。 Your docstring might look like the following: 您的文档字符串可能如下所示:
class A(object):
pass
def funct1(a_object):
"""
:type a_object: A
"""
pass
funct1(A())
However, what if you aren't passing an object of class A, but rather the class "A" itself? 但是,如果您不是传递类A的对象,而是传递类“ A”本身,该怎么办? How would that docstring look? 该文档字符串看起来如何?
class B(object):
pass
def funct2(b_class):
"""
:type b_class: ?????
"""
pass
funct2(B)
I think that this should work for type hinting, even if it isn't 100% technically accurate: 我认为这应该适用于类型提示,即使技术上并非100%准确:
class B(object):
pass
def funct2(b_class):
"""
:type b_class: () -> B
"""
pass
funct2(B)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.