[AutoSlots] deduplicate slots entries
This commit is contained in:
parent
a0d7d0ed26
commit
0f63acbad0
1 changed files with 4 additions and 3 deletions
|
|
@ -17,11 +17,12 @@ class AutoSlots(ABCMeta):
|
||||||
for base in bases:
|
for base in bases:
|
||||||
parents |= set(base.mro())
|
parents |= set(base.mro())
|
||||||
|
|
||||||
slots = tuple(dctn.get('__slots__', ()))
|
slots = list(dctn.get('__slots__', ()))
|
||||||
for parent in parents:
|
for parent in parents:
|
||||||
if not hasattr(parent, '__annotations__'):
|
if not hasattr(parent, '__annotations__'):
|
||||||
continue
|
continue
|
||||||
slots += tuple(parent.__annotations__.keys())
|
slots.extend(parent.__annotations__.keys())
|
||||||
|
|
||||||
dctn['__slots__'] = slots
|
# Deduplicate (dict to preserve order)
|
||||||
|
dctn['__slots__'] = tuple(dict.fromkeys(slots))
|
||||||
return super().__new__(cls, name, bases, dctn)
|
return super().__new__(cls, name, bases, dctn)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue