-
Notifications
You must be signed in to change notification settings - Fork 14
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
WIP: collections as dicts #419
base: master
Are you sure you want to change the base?
Conversation
I didn't try anything with your example, so I don't know how exactly that fails but...
... if it does have something to do with attrs, it's something more particular to how we use it, because this seems to work as expected: import attr
@attr.s
class A(object):
_a = attr.ib(default=attr.Factory(list))
@property
def a(self):
return self._a
@a.setter
def a(self, value):
self._a = value
x = A([0, 1])
print(x.a)
x.a = [0, 2]
print(x.a)
|
Thanks, @kyleam. The test suite fails on a number of tests, but not in ways that were obvious as to the root cause. @yarikoptic, can you shed light on this? Or suggest how I can create getters and setters for DebianDistribution.packages? |
Even without looking into failures: well, we do quite in a few places rely on exploring all those attr's This example doesn't show though the purpose of making |
ah, doh -- re "purpose" the title said it ;-) So, you would like to convert them to be a dict instead of a list... we discussed it a bit during the last call. Do I remember correctly that the main goal is to make lookups (for diff and otherwise) more efficient so we don't need to iterate? I guess the best would be to define a custom class to be used here instead of |
@kyleam it looks like attrs uses the declaration of @yarikoptic my main purpose here was to express an idea by refactoring DebianDistribution -- I wanted to change its internals without affecting its behavior, but attrs limits our options here. We also run into problems because at some point(s?) we redefine I'm rethinking my strategy and I suspect it might be better if the first step is not working on DebianDistribution's internals but rather on its interface, and to try to be stricter about how we can interact with it. This should also keep us from doing things that require crazy workarounds in other areas. |
Why is this refactoring not working? Does it have something to do with attrs?