Skip to content Skip to sidebar Skip to footer

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)

Solution 1:

self should be omitted from the annotation when it is given as a comment, and __init__() should be marked as -> None. This is all specified explicitly in PEP-0484.


Post a Comment for "Correct Type Annotation For __init__"