|
1 | 1 | import inspect |
2 | | -import warnings |
3 | | -from contextlib import contextmanager |
4 | 2 | from contextvars import ContextVar |
5 | | -from typing import ( |
6 | | - Any, |
7 | | - Awaitable, |
8 | | - Callable, |
9 | | - ContextManager, |
10 | | - Iterator, |
11 | | - Optional, |
12 | | - Sequence, |
13 | | - Type, |
14 | | - TypeVar, |
15 | | - cast, |
16 | | -) |
| 3 | +from typing import Awaitable, Callable, Optional, Sequence, Type, TypeVar, cast |
17 | 4 |
|
18 | 5 | from fastapi import Depends, FastAPI, Request, Response |
19 | 6 | from fastapi.dependencies.utils import ( |
|
23 | 10 | from fastapi.routing import APIRoute, APIRouter |
24 | 11 |
|
25 | 12 | from .bases import AbstractPage, AbstractParams |
26 | | -from .default import Page, Params |
27 | | -from .utils import deprecated |
| 13 | +from .default import Page |
28 | 14 |
|
29 | 15 | T = TypeVar("T") |
30 | 16 | TAbstractParams = TypeVar("TAbstractParams", covariant=True, bound=AbstractParams) |
@@ -133,61 +119,11 @@ def add_pagination(parent: ParentT) -> ParentT: |
133 | 119 | return parent |
134 | 120 |
|
135 | 121 |
|
136 | | -@deprecated |
137 | | -def using_params( |
138 | | - params_type: Type[TAbstractParams], |
139 | | -) -> Callable[[TAbstractParams], Awaitable[TAbstractParams]]: # pragma: no cover |
140 | | - async def _pagination_params(*args, **kwargs) -> params_type: # type: ignore |
141 | | - params = params_type(*args, **kwargs) # type: ignore |
142 | | - params_value.set(params) |
143 | | - return params |
144 | | - |
145 | | - _pagination_params.__signature__ = inspect.signature(params_type) # type: ignore |
146 | | - |
147 | | - return _pagination_params |
148 | | - |
149 | | - |
150 | | -with warnings.catch_warnings(): |
151 | | - warnings.simplefilter("ignore") |
152 | | - pagination_params = using_params(Params) |
153 | | - |
154 | | - |
155 | | -@deprecated |
156 | | -def using_page(page: Type[AbstractPage]) -> ContextManager[None]: # pragma: no cover |
157 | | - token = page_type.set(page) |
158 | | - |
159 | | - @contextmanager |
160 | | - def _reset() -> Iterator[None]: |
161 | | - try: |
162 | | - yield |
163 | | - finally: |
164 | | - page_type.reset(token) |
165 | | - |
166 | | - return _reset() |
167 | | - |
168 | | - |
169 | | -@deprecated |
170 | | -def use_as_page(page: Any) -> Any: # pragma: no cover |
171 | | - using_page(page) |
172 | | - return page |
173 | | - |
174 | | - |
175 | | -@deprecated |
176 | | -async def using_response(res: Response) -> None: # pragma: no cover |
177 | | - response_value.set(res) |
178 | | - |
179 | | - |
180 | 122 | __all__ = [ |
181 | 123 | "add_pagination", |
182 | 124 | "create_page", |
183 | 125 | "resolve_params", |
184 | 126 | "response", |
185 | 127 | "request", |
186 | 128 | "set_page", |
187 | | - # deprecated api |
188 | | - "using_response", |
189 | | - "using_params", |
190 | | - "using_page", |
191 | | - "use_as_page", |
192 | | - "pagination_params", |
193 | 129 | ] |
0 commit comments