Closed ericvsmith closed 7 years ago
This can just be an extra keyword for field(), right?
Correct. attrs
requires it to be a dict (or really any Mapping, I think) and then wraps it in a types.MappingProxyType
to make it read-only. I haven't done enough research to understand why they do that, but I will. I assume we should just do the same to maximize compatibility.
This is the last item I want to complete before posting the updated PEP on python-dev.
To clarify: I understand why you'd make it read-only if the metadata is a Mapping. What isn't clear to me is why only a Mapping is supported. At first blush I'd think that the metadata could be anything, and we shouldn't restrict it at all. But I'm sure attrs
has a good reason for it.
The answer is in https://github.com/python-attrs/attrs/issues/63#issuecomment-244053386 and the following discussion. A dict is used to force composability without resorting to multiple inheritance verbosity. It seems like a reasonable argument to me.
+1.
Closed via #71.
See http://www.attrs.org/en/stable/extending.html#metadata for the equivalent functionality in attrs.