PeterDing / BaiduPCS-Py

BaiduPCS API & App 百度网盘客户端 和 API
MIT License
667 stars 108 forks source link

(v0.7.6) System ERROR: Cannot specify `Depends` for type #121

Open qiurigao opened 9 months ago

qiurigao commented 9 months ago

root@localhost:~# LOG_LEVEL=DEBUG BaiduPCS-Py server Server running on http://localhost:8000/ 2023-10-08 19:34:33,704 | DEBUG | app: app: System Error: Traceback (most recent call last): File "/usr/local/lib/python3.10/dist-packages/baidupcs_py/app/app.py", line 118, in wrap return func(*args, *kwargs) File "/usr/local/lib/python3.10/dist-packages/baidupcs_py/app/app.py", line 177, in wrap return func(args, **kwargs) File "/usr/local/lib/python3.10/dist-packages/baidupcs_py/app/app.py", line 1766, in server start_server( File "/usr/local/lib/python3.10/dist-packages/baidupcs_py/commands/server.py", line 203, in start_server make_http_server(path) File "/usr/local/lib/python3.10/dist-packages/baidupcs_py/commands/server.py", line 157, in make_http_server async def http_server(response: Response = Depends(handle_request)): File "/usr/local/lib/python3.10/dist-packages/fastapi/routing.py", line 704, in decorator self.add_api_route( File "/usr/local/lib/python3.10/dist-packages/fastapi/routing.py", line 643, in add_api_route route = route_class( File "/usr/local/lib/python3.10/dist-packages/fastapi/routing.py", line 489, in init self.dependant = get_dependant(path=self.path_format, call=self.endpoint) File "/usr/local/lib/python3.10/dist-packages/fastapi/dependencies/utils.py", line 261, in get_dependant type_annotation, depends, param_field = analyze_param( File "/usr/local/lib/python3.10/dist-packages/fastapi/dependencies/utils.py", line 387, in analyze_param assert depends is None, f"Cannot specify Depends for type {type_annotation!r}" AssertionError: Cannot specify Depends for type <class 'starlette.responses.Response'>

(v0.7.6) System ERROR: Cannot specify Depends for type <class 'starlette.responses.Response'> ╭──────────── Traceback (most recent call last) ─────────────╮ │ /usr/local/lib/python3.10/dist-packages/baidupcs_py/app/ap │ │ p.py:118 in wrap │ │ │ │ 115 │ @wraps(func) │ │ 116 │ def wrap(*args, kwargs): │ │ 117 │ │ try: │ │ ❱ 118 │ │ │ return func(*args, *kwargs) │ │ 119 │ │ except BaiduPCSError as err: │ │ 120 │ │ │ _exit_progress_bar() │ │ 121 │ │ │ │ /usr/local/lib/python3.10/dist-packages/baidupcs_py/app/ap │ │ p.py:177 in wrap │ │ │ │ 174 │ │ ctx = args[0] │ │ 175 │ │ user_ids = _user_ids(ctx) │ │ 176 │ │ if not user_ids: │ │ ❱ 177 │ │ │ return func(args, kwargs) │ │ 178 │ │ │ │ 179 │ │ am = ctx.obj.account_manager │ │ 180 │ │ for user_id in user_ids: │ │ │ │ /usr/local/lib/python3.10/dist-packages/baidupcs_py/app/ap │ │ p.py:1766 in server │ │ │ │ 1763 │ if username: │ │ 1764 │ │ assert password, "Must set password" │ │ 1765 │ │ │ ❱ 1766 │ start_server( │ │ 1767 │ │ api, │ │ 1768 │ │ root_dir=root_dir, │ │ 1769 │ │ path=path, │ │ │ │ /usr/local/lib/python3.10/dist-packages/baidupcs_py/comman │ │ ds/server.py:203 in start_server │ │ │ │ 200 │ if _username and _password: │ │ 201 │ │ make_auth_http_server(path) │ │ 202 │ else: │ │ ❱ 203 │ │ make_http_server(path) │ │ 204 │ │ │ 205 │ log_config = copy.deepcopy(uvicorn.config.LOGGIN │ │ 206 │ log_config["formatters"]["access"][ │ │ │ │ /usr/local/lib/python3.10/dist-packages/baidupcs_py/comman │ │ ds/server.py:157 in make_http_server │ │ │ │ 154 │ │ 155 def make_http_server(path: str = ""): │ │ 156 │ @app.get("%s/{remotepath:path}" % path) │ │ ❱ 157 │ async def http_server(response: Response = Depen │ │ 158 │ │ return response │ │ 159 │ │ 160 │ │ │ │ /usr/local/lib/python3.10/dist-packages/fastapi/routing.py │ │ :704 in decorator │ │ │ │ 701 │ │ ), │ │ 702 │ ) -> Callable[[DecoratedCallable], DecoratedCal │ │ 703 │ │ def decorator(func: DecoratedCallable) -> D │ │ ❱ 704 │ │ │ self.add_api_route( │ │ 705 │ │ │ │ path, │ │ 706 │ │ │ │ func, │ │ 707 │ │ │ │ response_model=response_model, │ │ │ │ /usr/local/lib/python3.10/dist-packages/fastapi/routing.py │ │ :643 in add_api_route │ │ │ │ 640 │ │ current_generate_unique_id = get_value_or_d │ │ 641 │ │ │ generate_unique_id_function, self.gener │ │ 642 │ │ ) │ │ ❱ 643 │ │ route = route_class( │ │ 644 │ │ │ self.prefix + path, │ │ 645 │ │ │ endpoint=endpoint, │ │ 646 │ │ │ response_model=response_model, │ │ │ │ /usr/local/lib/python3.10/dist-packages/fastapi/routing.py │ │ :489 in init │ │ │ │ 486 │ │ │ self.response_fields = {} │ │ 487 │ │ │ │ 488 │ │ assert callable(endpoint), "An endpoint mus │ │ ❱ 489 │ │ self.dependant = get_dependant(path=self.pa │ │ 490 │ │ for depends in self.dependencies[::-1]: │ │ 491 │ │ │ self.dependant.dependencies.insert( │ │ 492 │ │ │ │ 0, │ │ │ │ /usr/local/lib/python3.10/dist-packages/fastapi/dependenci │ │ es/utils.py:261 in get_dependant │ │ │ │ 258 │ ) │ │ 259 │ for param_name, param in signature_params.items( │ │ 260 │ │ is_path_param = param_name in path_param_nam │ │ ❱ 261 │ │ type_annotation, depends, param_field = anal │ │ 262 │ │ │ param_name=param_name, │ │ 263 │ │ │ annotation=param.annotation, │ │ 264 │ │ │ value=param.default, │ │ │ │ /usr/local/lib/python3.10/dist-packages/fastapi/dependenci │ │ es/utils.py:387 in analyze_param │ │ │ │ 384 │ │ type_annotation, │ │ 385 │ │ (Request, WebSocket, HTTPConnection, Respons │ │ 386 │ ): │ │ ❱ 387 │ │ assert depends is None, f"Cannot specify De │ │ 388 │ │ assert ( │ │ 389 │ │ │ field_info is None │ │ 390 │ │ ), f"Cannot specify FastAPI annotation for t │ ╰────────────────────────────────────────────────────────────╯ AssertionError: Cannot specifyDependsfor type <class 'starlette.responses.Response'> 2023-10-08 19:34:34,404 | DEBUG | app:app: _teardown: start 2023-10-08 19:34:34,404 | DEBUG | app:app`: _teardown: end root@localhost:~#