Download valley/lib/python3.10/site-packages/referencing/typing.py from ZTWHHH/envs_2: direct link, hf CLI and curl.
- Browser
- Download file 1.43 kB
-
https://huggingface.co/datasets/ZTWHHH/envs_2/resolve/main/valley/lib/python3.10/site-packages/referencing/typing.py
- Command line
-
hf download hf://datasets/ZTWHHH/envs_2/valley/lib/python3.10/site-packages/referencing/typing.py
-
curl -L -o typing.py https://huggingface.co/datasets/ZTWHHH/envs_2/resolve/main/valley/lib/python3.10/site-packages/referencing/typing.py
1.43 kB
| """ | |
| Type-annotation related support for the referencing library. | |
| """ | |
| from __future__ import annotations | |
| from typing import TYPE_CHECKING, Protocol, TypeVar | |
| try: | |
| from collections.abc import Mapping as Mapping | |
| Mapping[str, str] | |
| except TypeError: # pragma: no cover | |
| from typing import Mapping as Mapping | |
| if TYPE_CHECKING: | |
| from referencing._core import Resolved, Resolver, Resource | |
| #: A URI which identifies a `Resource`. | |
| URI = str | |
| #: The type of documents within a registry. | |
| D = TypeVar("D") | |
| class Retrieve(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. | |
| """ | |
| ... | |
| class Anchor(Protocol[D]): | |
| """ | |
| An anchor within a `Resource`. | |
| Beyond "simple" anchors, some specifications like JSON Schema's 2020 | |
| version have dynamic anchors. | |
| """ | |
| def name(self) -> str: | |
| """ | |
| Return the name of this anchor. | |
| """ | |
| ... | |
| def resolve(self, resolver: Resolver[D]) -> Resolved[D]: | |
| """ | |
| Return the resource for this anchor. | |
| """ | |
| ... | |