1111
1212import inspect
1313import logging
14- from collections .abc import Iterator , Mapping
15- from typing import Any , Union
14+ from collections .abc import Iterator , MutableMapping
15+ from typing import Any
1616
1717from linkml_runtime import SchemaView
1818from linkml_runtime .utils import eval_utils
@@ -56,9 +56,9 @@ def __init__(self, obj: YAMLRoot, schemaview: SchemaView):
5656 self ._root_object = obj
5757 self ._schemaview = schemaview
5858 self ._class_map = schemaview .class_name_mappings ()
59- self ._source_object_cache : Mapping [str , Any ] = {}
60- self ._proxy_object_cache : Mapping [str , ProxyObject ] = {}
61- self ._child_to_parent : Mapping [str , list [tuple [str , str ]]] = {}
59+ self ._source_object_cache : MutableMapping [str , Any ] = {}
60+ self ._proxy_object_cache : MutableMapping [str , ProxyObject ] = {}
61+ self ._child_to_parent : MutableMapping [str , list [tuple [str , str ]]] = {}
6262 self ._index (obj )
6363
6464 def _index (self , obj : Any , parent_key = None , parent = None ):
@@ -70,16 +70,11 @@ def _index(self, obj: Any, parent_key=None, parent=None):
7070 return {k : self ._index (v , parent_key , parent ) for k , v in obj .items ()}
7171 cls_name = type (obj ).__name__
7272 if cls_name in self ._class_map :
73- cls = self ._class_map [cls_name ]
7473 pk_val = self ._key (obj )
7574 self ._source_object_cache [pk_val ] = obj
7675 if pk_val not in self ._child_to_parent :
7776 self ._child_to_parent [pk_val ] = []
7877 self ._child_to_parent [pk_val ].append ((parent_key , parent ))
79- # id_slot = self._schemaview.get_identifier_slot(cls.name)
80- # if id_slot:
81- # id_val = getattr(obj, id_slot.name)
82- # self._source_object_cache[(cls.name, id_val)] = obj
8378 for k , v in vars (obj ).items ():
8479 self ._index (v , k , obj )
8580 else :
@@ -115,7 +110,7 @@ def bless(self, obj: Any) -> "ProxyObject":
115110 else :
116111 return ProxyObject (obj , _db = self )
117112
118- def _key (self , obj : Any ) -> tuple [Union [ str , YAMLRoot ] , str ]:
113+ def _key (self , obj : Any ) -> tuple [str , str ]:
119114 """
120115 Returns primary key value for this object.
121116
0 commit comments