Don't overwrite existing attributes with an empty list (#594)

* Don't overwrite existing attributes with an empty list

* Also check for empty lists in __eq__
This commit is contained in:
jjlawren 2020-10-31 00:13:19 -05:00 committed by GitHub
parent 8ec0c4cf42
commit 83947b0e29
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -54,8 +54,8 @@ class PlexObject(object):
return '<%s>' % ':'.join([p for p in [self.__class__.__name__, uid, name] if p]) return '<%s>' % ':'.join([p for p in [self.__class__.__name__, uid, name] if p])
def __setattr__(self, attr, value): def __setattr__(self, attr, value):
# dont overwrite an attr with None unless its a private variable # Don't overwrite an attr with None or [] unless it's a private variable
if value is not None or attr.startswith('_') or attr not in self.__dict__: if value not in [None, []] or attr.startswith('_') or attr not in self.__dict__:
self.__dict__[attr] = value self.__dict__[attr] = value
def _clean(self, value): def _clean(self, value):
@ -283,7 +283,7 @@ class PlexPartialObject(PlexObject):
""" """
def __eq__(self, other): def __eq__(self, other):
return other is not None and self.key == other.key return other not in [None, []] and self.key == other.key
def __hash__(self): def __hash__(self):
return hash(repr(self)) return hash(repr(self))