John Snow <js...@redhat.com> writes: > On 10/7/20 7:49 AM, Markus Armbruster wrote: >> Looks like commit message of PATCH 24 has an answer. >> Copy to all the commits that omit -> None similarly? > > Probably not needed. > > It's covered by the class basics section in the mypy manual; > https://mypy.readthedocs.io/en/stable/class_basics.html#annotating-init-methods > > and if you should happen to omit annotations for __init__ entirely as > a novice, you will be treated to messages such as these: > > qapi/source.py:18: error: Function is missing a return type annotation > qapi/source.py:18: note: Use "-> None" if function does not return a value > Found 1 error in 1 file (checked 14 source files) > > Pretty good error! > > There's no error if you DO explicitly add a -> None from __init__, but > at worst it's just extraneous (but correct) information.
Let me apply the zero-one-infinity rule: * Zero: explain it in none of the commit messages, i.e. dumb down PATCH 24. * One: explain it in one. Do it in the first one, please (here, I think). * Infinity: explain it in every one. Up to you! > I could add a note to the style guide that I prefer omitting the > return from __init__. I like omitting as much as I possibly can. > > (You'll notice I don't always type every local, either -- when local > inference is accurate, I leave it alone.) Type inference can save us from repeating the obvious over and over, and that's lovely.