Closed kgreav closed 3 years ago
You're probably aware of this but worth noting since it isn't explicitly stated: this only affects slots=True
. And I'm not even sure it's anything to do with dataclassy. Converting the classes into their closest "normal class" equivalents:
class Foo(object):
__slots__= ('foo_prop', )
def __init__(self):
self.foo_prop = "foo_prop_value"
class Bar(Foo):
__slots__ = ('bar_prop',)
def __init__(self):
self.bar_prop = "bar_prop_value"
class FooBar(Bar):
pass
get_foo_prop = Foo().foo_prop
get_bar_prop = Bar().bar_prop
and then running the print
lines from there on raises the same exception. Am I missing something? Do you know why this is happening or if there's a workaround you would like to see? Sorry about the extra-long response time by the way.
Hm I actually didn't link it back to slots but that makes sense. Well, guess it's a slots bug then. Probably nothing we can do about it in that case other than raise a bug with python. I'll look around and see if this is an issue reported elsewhere. Sorry for wasting your time.
Absolutely no need to apologise! Python has a few weird low-level edge cases like this (see #36) that are frustrating to work around so at least this situation is highly specific (even if that sadly doesn't help you).
Hi,
Having a rather subtle issue with properties in inherited classes more than 2 levels deep:
output:
It's odd that get causes an AttributeError on FooBar (2 levels of inheritance) but
getattr
works fine. I'd expect both to work.Worth noting this also breaks dataclasses, but seems like something we should fix.