From 5989d3a01707ce3b6e75192aedb7037e946bd600 Mon Sep 17 00:00:00 2001 From: Thomas Adamcik Date: Mon, 4 May 2015 22:39:36 +0200 Subject: [PATCH] models: Simplify how we add __weakref__ to slots --- mopidy/models/immutable.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/mopidy/models/immutable.py b/mopidy/models/immutable.py index 485480a9..0b6ef2f7 100644 --- a/mopidy/models/immutable.py +++ b/mopidy/models/immutable.py @@ -1,7 +1,6 @@ from __future__ import absolute_import, unicode_literals import copy -import inspect import itertools import weakref @@ -27,12 +26,6 @@ class ImmutableObjectMeta(type): attrs['__slots__'] = list(attrs.get('__slots__', [])) attrs['__slots__'].extend(['_hash'] + fields.values()) - 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__') - return super(ImmutableObjectMeta, cls).__new__(cls, name, bases, attrs) def __call__(cls, *args, **kwargs): # noqa: N805 @@ -56,6 +49,7 @@ class ImmutableObject(object): """ __metaclass__ = ImmutableObjectMeta + __slots__ = ['__weakref__'] def __init__(self, *args, **kwargs): for key, value in kwargs.items():