models: Fix review comments
This commit is contained in:
parent
777a663896
commit
20019edf2d
@ -150,9 +150,8 @@ class ImmutableObjectMeta(type):
|
|||||||
attrs['_instances'] = weakref.WeakValueDictionary()
|
attrs['_instances'] = weakref.WeakValueDictionary()
|
||||||
attrs['__slots__'] = ['_hash'] + fields.values()
|
attrs['__slots__'] = ['_hash'] + fields.values()
|
||||||
|
|
||||||
anncestors = [b for base in bases for b in inspect.getmro(base)]
|
for ancestor in [b for base in bases for b in inspect.getmro(base)]:
|
||||||
for anncestor in anncestors:
|
if '__weakref__' in getattr(ancestor, '__slots__', []):
|
||||||
if '__weakref__' in getattr(anncestor, '__slots__', []):
|
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
attrs['__slots__'].append('__weakref__')
|
attrs['__slots__'].append('__weakref__')
|
||||||
|
|||||||
@ -8,7 +8,7 @@ from mopidy.models import (
|
|||||||
TlTrack, Track, model_json_decoder)
|
TlTrack, Track, model_json_decoder)
|
||||||
|
|
||||||
|
|
||||||
class InheritanecTest(unittest.TestCase):
|
class InheritanceTest(unittest.TestCase):
|
||||||
|
|
||||||
def test_weakref_and_slots_play_nice_in_subclass(self):
|
def test_weakref_and_slots_play_nice_in_subclass(self):
|
||||||
# Check that the following does not happen:
|
# Check that the following does not happen:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user