danielgtaylor / python-betterproto

Clean, modern, Python 3.6+ code generator & library for Protobuf 3 and async gRPC
MIT License
1.47k stars 205 forks source link

Simplify the generated code by explicitly removing dataclasses decorator #334

Open Gobot1234 opened 2 years ago

Gobot1234 commented 2 years ago

If PEP 681 is accepted we would be able to simplify the generated code by removing the dataclasses decorator and then implictly make betterproto.Messages be dataclasses by defining __init_subclass__ and retain the typed constructor:

def __init_subclass__(cls) -> None:
    dataclasses.dataclass(eq=False, repr=False)(cls)

I think this would be a nice readabilty improvement.

Gobot1234 commented 2 years ago

Small update https://mail.python.org/archives/list/python-dev@python.org/thread/JWMSWJ6JZJNNG3JKPBYDMQUUHZFD2FZL, this will probably have to wait for b6

Gobot1234 commented 2 years ago

PEP 681 has now been accepted so this should be ok to implement