"""Type-annotation related support for the referencing library."""from__future__importannotationsfromcollections.abcimportMappingasMappingfromtypingimportTYPE_CHECKING,Any,Protocoltry:fromtyping_extensionsimportTypeVarexceptImportError:# pragma: no coverfromtypingimportTypeVarifTYPE_CHECKING:fromreferencing._coreimportResolved,Resolver,Resource#: A URI which identifies a `Resource`.URI=str#: The type of documents within a registry.D=TypeVar("D",default=Any)
[docs]classRetrieve(Protocol[D]):""" A retrieval callable, usable within a `Registry` for resource retrieval. Does not make assumptions about where the resource might be coming from. """def__call__(self,uri:URI)->Resource[D]:""" Retrieve the resource with the given URI. Raise `referencing.exceptions.NoSuchResource` if you wish to indicate the retriever cannot lookup the given URI. """...
[docs]classAnchor(Protocol[D]):""" An anchor within a `Resource`. Beyond "simple" anchors, some specifications like JSON Schema's 2020 version have dynamic anchors. """@propertydefname(self)->str:""" Return the name of this anchor. """...
[docs]defresolve(self,resolver:Resolver[D])->Resolved[D]:""" Return the resource for this anchor. """...