Have id field on ModelItem base class

This commit is contained in:
miruka
2020-05-02 13:03:44 -04:00
parent 5b2c131fd1
commit 592a9fe8e7
2 changed files with 9 additions and 5 deletions

View File

@@ -1,5 +1,6 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
from dataclasses import dataclass, field
from typing import TYPE_CHECKING, Any, Dict
from ..pyotherside_events import ModelItemSet
@@ -10,6 +11,7 @@ if TYPE_CHECKING:
from .model import Model
@dataclass
class ModelItem:
"""Base class for items stored inside a `Model`.
@@ -21,6 +23,9 @@ class ModelItem:
and thus allow a `Model` to keep its data sorted.
"""
id: Any = field()
def __new__(cls, *_args, **_kwargs) -> "ModelItem":
cls.parent_models: Dict[SyncId, Model] = {}
return super().__new__(cls)