-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Separate makers for hash, dict, eq, and repr #82
Comments
This would be a great addition @pfw , thanks for suggesting it ! Would you like to propose such mod yourself in a PR ? Otherwise I'll try to find some time in the upcoming weeks. |
Great. I'll have a look and see if I understand the code enough to propose sensible changes. I'm finding myself putting together classes like below and I very much like that pyfields lets you build up the functionality rather than having to turn things off or override. Nice work.
|
Great thanks for the feedback @pfw ! For the implementation, the only tricky thing is that you'll see that If we follow the same pattern with the methods you suggest (e.g. |
I've found myself using make_init with arguments rather than @autoclass with parameters as it is more convenient for the cases where I need to write a customise the various dunder methods for hash, dict, eq and repr. For some cases I need init, to_dict and repr to include different fields - make_init makes this easy with the usage like:
init = make_init(height)
particularly useful when subclassing makes sense and it can include fields from the parent.
What do you think about exposing the builders for hash, dict, eq, and repr rather than having them in _apply_decorator of @autoclass?
The text was updated successfully, but these errors were encountered: