-
Notifications
You must be signed in to change notification settings - Fork 15.8k
Closed
Labels
Description
It would be great to generate type hints (PEP484/PEP526) for the python generated class so we have IDE completion and type incompatibility warnings.
Eg for :
message Foo {
string bar = 1;
}
generate
@overload
class Foo:
bar = None # type: str
def __init__(self, bar=None): # type: (str) -> None
pass
Foo = _reflection.GeneratedProtocolMessageType('Foo', (_message.Message,), dict(
Note: this way of writing types works with both python 2 and 3. With python >= 3.6, the Foo class could be documented more nicely.
The type annotations are well handled at least by pycharm.
kluikens, okorolev, misty-fungus, WillySchu, pviotti and 228 moresamuela, jankislinger, stevenbedrick, anirudh-chhangani, alapini and 43 morecaowenbin08, iamnoah, TylerYep, lishunan246, telugu-boy and 4 morehonglei