Spaces:
Runtime error
Runtime error
Download cmsgpt/lib/python3.8/site-packages/fastapi/datastructures.py from AnshulKapoor/ChatCMS: direct link, hf CLI and curl.
- Browser
- Download file 1.91 kB
-
https://huggingface.co/spaces/AnshulKapoor/ChatCMS/resolve/main/cmsgpt/lib/python3.8/site-packages/fastapi/datastructures.py
- Command line
-
hf download hf://spaces/AnshulKapoor/ChatCMS/cmsgpt/lib/python3.8/site-packages/fastapi/datastructures.py
-
curl -L -o datastructures.py https://huggingface.co/spaces/AnshulKapoor/ChatCMS/resolve/main/cmsgpt/lib/python3.8/site-packages/fastapi/datastructures.py
1.91 kB
| from typing import Any, Callable, Dict, Iterable, Type, TypeVar | |
| from starlette.datastructures import URL as URL # noqa: F401 | |
| from starlette.datastructures import Address as Address # noqa: F401 | |
| from starlette.datastructures import FormData as FormData # noqa: F401 | |
| from starlette.datastructures import Headers as Headers # noqa: F401 | |
| from starlette.datastructures import QueryParams as QueryParams # noqa: F401 | |
| from starlette.datastructures import State as State # noqa: F401 | |
| from starlette.datastructures import UploadFile as StarletteUploadFile | |
| class UploadFile(StarletteUploadFile): | |
| def __get_validators__(cls: Type["UploadFile"]) -> Iterable[Callable[..., Any]]: | |
| yield cls.validate | |
| def validate(cls: Type["UploadFile"], v: Any) -> Any: | |
| if not isinstance(v, StarletteUploadFile): | |
| raise ValueError(f"Expected UploadFile, received: {type(v)}") | |
| return v | |
| def __modify_schema__(cls, field_schema: Dict[str, Any]) -> None: | |
| field_schema.update({"type": "string", "format": "binary"}) | |
| class DefaultPlaceholder: | |
| """ | |
| You shouldn't use this class directly. | |
| It's used internally to recognize when a default value has been overwritten, even | |
| if the overridden default value was truthy. | |
| """ | |
| def __init__(self, value: Any): | |
| self.value = value | |
| def __bool__(self) -> bool: | |
| return bool(self.value) | |
| def __eq__(self, o: object) -> bool: | |
| return isinstance(o, DefaultPlaceholder) and o.value == self.value | |
| DefaultType = TypeVar("DefaultType") | |
| def Default(value: DefaultType) -> DefaultType: | |
| """ | |
| You shouldn't use this function directly. | |
| It's used internally to recognize when a default value has been overwritten, even | |
| if the overridden default value was truthy. | |
| """ | |
| return DefaultPlaceholder(value) # type: ignore | |