
On 3/7/22 3:34 PM, Erik De Bonte wrote:
* ``hash`` is an alias for the ``unsafe_hash`` parameter.
Reasoning for providing this alias? Seems inconsistent.
@Eric Traut <mailto:erictr@microsoft.com>, I assume this was added because attrs uses "hash" instead of "unsafe_hash". However, the attrs hashing documentation [1] strongly discourages users from setting hash to True. I assume that means that it is infrequently used. Perhaps we should remove this alias and if attrs feels that this is important they should add an unsafe_hash alias on their side?
I would be in favor of removing the "hash" alias to "unsafe_hash" in @dataclass_transform, in favor of the attrs project instead adding a new "unsafe_hash" alias (to the now-attrs-specific "hash"). But to do that we would need buy-in from a maintainer of attrs. Know anyone we could ask?
@dataclass_tranform *could* be used on Django's models.Model base class.
This is great news! I've been trying to find a Django contributor who might be interested in experimenting with dataclass_transform and providing feedback. If you know a good contact, please let me know.
I'm a Django contributor myself. However my bandwidth is limited while I'm shepherding my own PEP (655) in before the Python 3.11 alphas close, so I might not have enough time myself. What kinds of feedback are you looking for? I have a medium-sized Django-based project (~200,000 lines of Python code) at my disposal.
Is there potential openness to adding support for declaring that a particular dataclass_transform does autogenerate
certain "extra fields" with known names and types (like "id: int")? Either in this PEP or in a future PEP?
In future PEPs, yes. Pradeep suggested an add_attributes decorator during a discussion back in November [3]. Since this would be useful outside of dataclasses, I think it would be better to spec it separately from dataclass_transform.
The @add_attributes decorator idea is quite interesting. Definitely worth revisiting later. Cheers, -- David Foster | Seattle, WA, USA Contributor to TypedDict, mypy, and Python's typing system