import abc from typing import TypeVar from rainbowadn.core.hashpoint import HashPoint from rainbowadn.core.hashresolver import HashResolver from rainbowadn.core.resolvermetaorigin import ResolverMetaOrigin Mentioned = TypeVar('Mentioned') class ExtendableResolver(HashResolver, abc.ABC): async def extend(self, hash_point: HashPoint[Mentioned]) -> 'ExtendableResolver': raise NotImplementedError async def migrate(self, hash_point: HashPoint[Mentioned]) -> HashPoint[Mentioned]: assert isinstance(hash_point, HashPoint) return ResolverMetaOrigin(await self.extend(hash_point)).hash_point(hash_point.factory, hash_point.point) async def migrate_resolved(self, mentioned: Mentioned) -> Mentioned: return await (await self.migrate(HashPoint.of(mentioned))).resolve()