Skip to content

Commit

Permalink
Replace is_property by a more generic solution that's able to retriev…
Browse files Browse the repository at this point in the history
…e property objects
  • Loading branch information
ramnes committed Nov 8, 2017
1 parent d7ef9d6 commit ec31148
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions thingy.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,12 @@ def __new__(cls, name, bases, attrs):
return klass


def is_property(attr, instance):
return any(attr in cls.__dict__ for cls in type(instance).__mro__)
def getclassattr(instance, attr):
for cls in type(instance).mro():
try:
return cls.__dict__[attr]
except KeyError:
pass


@six.add_metaclass(ThingyMetaClass)
Expand All @@ -85,7 +89,7 @@ def __getattribute__(self, attr):
try:
return object.__getattribute__(self, attr)
except AttributeError:
if not is_property(attr, self) and self._silent:
if type(getclassattr(self, attr)) is not property and self._silent:
return None
raise

Expand Down

0 comments on commit ec31148

Please sign in to comment.