-
-
Notifications
You must be signed in to change notification settings - Fork 385
make_class() fails when passing dict of Attributes #1074
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
Comments
This fixes it for me now , so I can continue working: Lines 2531 to 2532 in 88d2a37
validator=getattr(ca, "_validator", None),
default=getattr(ca, "_default", ca.default), The real problem is probably somewhere else, I leave that up to the authors of the library :) |
Bonus bug report: With the above fix applied, I discovered that one can now pass Attributes in the wrong order: First an attribute with a default set, then one with default=NOTHING will produce this error: Since 3.7 the insertion order of a dict is guaranteed, but I would argue that it would be less painful if |
Oof that's not a bug, but documentation rot, because make_class has fallen a bit to the wayside. As you can see in the example in https://www.attrs.org/en/stable/api.html#attrs.make_class, it doesn't take an instance of Looking closer, in the end this seems to be another instance of #637, but adding the angle of |
would you mind looking at #1075 and telling me if that's clearer? |
Ohh I see. I think the docs are better in that PR, yeah :) What is |
The Counting in CountingAttr comes from the fact that we had to add a class-counter on instantiation in pre-3.6 times to retain order of attribute definitions. :) I have to admit that I'm somewhat confused why it's an public API, but it actually is part of the API docs 😇:
attrs allows a lot of custom meta-programming and this is one of the features that allows the user to modify attributes, after attrs is done with it: https://www.attrs.org/en/stable/extending.html#transform-fields |
I noticed this fails, but in my understanding of the manual it should work:
The text was updated successfully, but these errors were encountered: