ericvsmith / dataclasses

Apache License 2.0
587 stars 53 forks source link

Rename __dataclass_post_init__ to just __post_init__. #70

Closed ericvsmith closed 6 years ago

ericvsmith commented 7 years ago

I agree with @ilevkivskyi that we should use a shorter name, and leverage the fact that this is a stdlib object to lay claim to __post_init__. The longer name is annoying because users of the class have to implement a function with this name.

But I'd like to leave __dataclass_fields__, since that's truly an implementation detail and should never be used outside of dataclasses.py.

gvanrossum commented 6 years ago

+1

(I expect someone will find a use for __dataclass_fields__, but I really don't mind if they have to type the full name. :-)

ericvsmith commented 6 years ago

Note that the module-level fields(obj) just returns obj.__dataclass_fields__ and changes AttributeError to ValueError, if it's raised. So hopefully no one would need to look at __dataclass_fields__, but people do funny things!