最佳答案
Python 中 __init__
函数的正确类型注释是什么?
class MyClass:
...
下列哪一个更有意义?
def __init__(self):
# type: (None) -> None
def __init__(self):
# type: (MyClass) -> MyClass
def __init__(self):
# type: (None) -> MyClass
因为我们通常实例化为 myclass = MyClass()
,但是 __init__
函数本身没有返回值。