Why should we use ->
in def __init__(self, n) -> None:
? I read the following excerpt from PEP 484, but I am unable to understand what it means.
(Note that the return type of
__init__
ought to be annotated with-> None
. The reason for this is subtle. If__init__
assumed a return annotation of-> None
, would that mean that an argument-less, un-annotated__init__
method should still be type-checked? Rather than leaving this ambiguous or introducing an exception to the exception, we simply say that__init__
ought to have a return annotation; the default behavior is thus the same as for other methods.)
What's the subtle difference between using def __init__(self, n) -> None:
and def __init__(self, n):
? Can someone explain the quoted excerpt in simple words?