Correct Type annotation for __init__
问题 What is the correct type annotation for a __init__ function in python? class MyClass: ... Which of the following would make more sense? def __init__(self): # type: (None) -> None def __init__(self): # type: (MyClass) -> MyClass def __init__(self): # type: (None) -> MyClass Since we would normally instantiate as myclass = MyClass() , but the __init__ function itself has no return value. 回答1: self should be omitted from the annotation when it is given as a comment, and __init__() should be