Have id field on ModelItem base class
This commit is contained in:
@@ -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)
|
||||
|
Reference in New Issue
Block a user