|
6 | 6 | from collections import ChainMap, defaultdict |
7 | 7 | from collections.abc import Coroutine |
8 | 8 | from contextlib import AsyncExitStack, AbstractAsyncContextManager, asynccontextmanager, contextmanager |
| 9 | +from functools import cached_property |
9 | 10 | from types import FunctionType |
10 | | -from typing import List, Union, Any, Callable, Type, Optional, Dict, Sequence |
| 11 | +from typing import List, Union, Any, Callable, Type, Optional, Dict, Sequence, Literal |
11 | 12 |
|
12 | 13 | import pydantic |
13 | 14 | from fastapi.dependencies.utils import _should_embed_body_fields # noqa |
14 | 15 | from fastapi.openapi.constants import REF_PREFIX |
15 | 16 |
|
16 | | -try: |
17 | | - from typing import Literal |
18 | | -except ImportError: |
19 | | - from typing_extensions import Literal |
20 | 17 |
|
21 | 18 | from fastapi._compat import ModelField, Undefined # noqa |
22 | 19 | from fastapi.dependencies.models import Dependant |
|
38 | 35 |
|
39 | 36 | logger = logging.getLogger(__name__) |
40 | 37 |
|
41 | | -try: |
42 | | - from functools import cached_property |
43 | | -except ImportError: |
44 | | - class cached_property: # noqa |
45 | | - def __init__(self, func): |
46 | | - self.__doc__ = getattr(func, "__doc__") |
47 | | - self.func = func |
48 | | - |
49 | | - def __get__(self, obj, cls): |
50 | | - if obj is None: |
51 | | - return self |
52 | | - value = obj.__dict__[self.func.__name__] = self.func(obj) |
53 | | - return value |
54 | 38 |
|
55 | 39 | try: |
56 | 40 | import sentry_sdk |
|
0 commit comments