There's no code where __init__ should return anything except None, so requiring -> None on it is just useless boilerplate.
I think it should be permitted to omit it, and that it should be inferred, as with self parameters not requiring annotation.
This was already considered, see this section of PEP 484:
(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.)
That's reasonable. I guess I can adjust my IDE snippet to just include it
For others who end up here, it looks like this point is still open for debate in #604 (and perhaps this should be marked as a Duplicate that issue).
This quote from Guido is worth considering: https://github.com/python/mypy/issues/604#issuecomment-83887491
Hm. I think it'd suck if we'd have to develop the habit of adding explicit
"-> None" to all init methods just to make mypy happy.
I'm with him on that.
Is there any way to disable this particular warning?
@gmolau
Is there any way to disable this particular warning?
What warning? You no longer need to put a return type on __init__(), unless it has no arguments other than self.
@gvanrossum Ah sorry, I was on an old mypy version. Thanks for your help!
Most helpful comment
For others who end up here, it looks like this point is still open for debate in #604 (and perhaps this should be marked as a Duplicate that issue).
This quote from Guido is worth considering: https://github.com/python/mypy/issues/604#issuecomment-83887491
I'm with him on that.