|
From: | John Snow |
Subject: | Re: [PATCH v5 19/36] qapi/events.py: add type hint annotations |
Date: | Wed, 7 Oct 2020 11:46:46 -0400 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 |
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.
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.)
--js
[Prev in Thread] | Current Thread | [Next in Thread] |