models: Fix review comments

This commit is contained in:
Thomas Adamcik 2015-04-12 16:03:51 +02:00
parent 777a663896
commit 20019edf2d
2 changed files with 3 additions and 4 deletions

View File

@ -150,9 +150,8 @@ class ImmutableObjectMeta(type):
attrs['_instances'] = weakref.WeakValueDictionary()
attrs['__slots__'] = ['_hash'] + fields.values()
anncestors = [b for base in bases for b in inspect.getmro(base)]
for anncestor in anncestors:
if '__weakref__' in getattr(anncestor, '__slots__', []):
for ancestor in [b for base in bases for b in inspect.getmro(base)]:
if '__weakref__' in getattr(ancestor, '__slots__', []):
break
else:
attrs['__slots__'].append('__weakref__')

View File

@ -8,7 +8,7 @@ from mopidy.models import (
TlTrack, Track, model_json_decoder)
class InheritanecTest(unittest.TestCase):
class InheritanceTest(unittest.TestCase):
def test_weakref_and_slots_play_nice_in_subclass(self):
# Check that the following does not happen: