Skip to content

Commit 0897c0a

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 02cf92d commit 0897c0a

File tree

7 files changed

+21
-23
lines changed

7 files changed

+21
-23
lines changed

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ dependencies = [
8484
# NOTE: 👇
8585
# The versions of `black`, `ruff`, `codespell`, must be consistent with the `.pre-commit-config.yaml`.
8686
# Don't edit them manually, use `pre-commit run ver_sync` instead.
87-
"black==23.12.0",
88-
"ruff==0.1.8",
87+
"black==24.3.0",
88+
"ruff==0.3.4",
8989
"codespell==2.2.6",
9090
# Don't write comments on these lines, because they will be removed by `pre-commit run ver_sync`.
9191
# NOTE: 👆

src/fastapi_proxy_lib/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""fastapi_proxy_lib package."""
22

3-
43
# DO NOT EDIT THE `__version__` MANUALLY.
54
# Use `hatch version {new_version}` instead.
65
# Refer to `CONTRIBUTING.md` for more info.

src/fastapi_proxy_lib/core/_tool.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ def __call__(
8080
*,
8181
msg: object,
8282
exc_info: Union[BaseException, None, bool],
83-
) -> Any:
84-
...
83+
) -> Any: ...
8584

8685

8786
class ErrMsg(TypedDict):
@@ -316,9 +315,9 @@ def return_err_msg_response(
316315
if logger is not None:
317316
# 只要传入了logger,就一定记录日志
318317
logger(
319-
msg=_msg
320-
if _msg is not None
321-
else err_response_json, # 如果没有指定 _msg ,则使用content
318+
msg=(
319+
_msg if _msg is not None else err_response_json
320+
), # 如果没有指定 _msg ,则使用content
322321
exc_info=_exc_info,
323322
)
324323
else:
@@ -395,13 +394,11 @@ def default_proxy_filter(url: httpx.URL) -> Union[None, str]:
395394

396395

397396
@overload
398-
def warn_for_none_filter(proxy_filter: _ProxyFilterTypeVar) -> _ProxyFilterTypeVar:
399-
...
397+
def warn_for_none_filter(proxy_filter: _ProxyFilterTypeVar) -> _ProxyFilterTypeVar: ...
400398

401399

402400
@overload
403-
def warn_for_none_filter(proxy_filter: None) -> ProxyFilterProto:
404-
...
401+
def warn_for_none_filter(proxy_filter: None) -> ProxyFilterProto: ...
405402

406403

407404
def warn_for_none_filter(

src/fastapi_proxy_lib/core/tool.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""User-oriented tool library."""
22

3-
43
from ._tool import ProxyFilterProto, default_proxy_filter
54

65
__all__ = ("default_proxy_filter", "ProxyFilterProto")

src/fastapi_proxy_lib/core/websocket.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,9 @@ async def _close_ws(
368368
"""
369369
logging.warning(msg)
370370

371-
except Exception as e: # pragma: no cover # 这个分支是一个保险分支,通常无法执行,所以只进行记录
371+
except (
372+
Exception
373+
) as e: # pragma: no cover # 这个分支是一个保险分支,通常无法执行,所以只进行记录
372374
logging.error(
373375
f"{e} when close ws connection. client: {client_to_server_task}, server:{server_to_client_task}"
374376
)
@@ -482,9 +484,9 @@ async def send_request_to_target( # pyright: ignore [reportIncompatibleMethodOv
482484
keepalive_ping_interval_seconds = self.keepalive_ping_interval_seconds
483485
keepalive_ping_timeout_seconds = self.keepalive_ping_timeout_seconds
484486

485-
client_request_subprotocols: Union[
486-
List[str], None
487-
] = _get_client_request_subprotocols(websocket.scope)
487+
client_request_subprotocols: Union[List[str], None] = (
488+
_get_client_request_subprotocols(websocket.scope)
489+
)
488490

489491
# httpx.stream()
490492
# refer to: https://www.python-httpx.org/api/#helper-functions
@@ -612,7 +614,9 @@ async def send_request_to_target( # pyright: ignore [reportIncompatibleMethodOv
612614
task_group,
613615
return_when=asyncio.FIRST_COMPLETED,
614616
)
615-
for pending_task in pending: # NOTE: pending 一般为一个未结束任务,或者为空
617+
for (
618+
pending_task
619+
) in pending: # NOTE: pending 一般为一个未结束任务,或者为空
616620
# 开始取消未结束的任务
617621
try:
618622
await asyncio.wait_for(pending_task, timeout=1)

src/fastapi_proxy_lib/fastapi/router.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,9 @@ class RouterHelper:
170170

171171
def __init__(self) -> None:
172172
"""Initialize RouterHelper."""
173-
self._registered_proxy: Set[
174-
Union[_HttpProxyTypes, _WebSocketProxyTypes]
175-
] = set()
173+
self._registered_proxy: Set[Union[_HttpProxyTypes, _WebSocketProxyTypes]] = (
174+
set()
175+
)
176176
self._registered_router_id: Set[int] = set()
177177

178178
@property

tests/conftest.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ class LifeAppDataclass4Test(AppDataclass4Test):
6565
class UvicornServerFixture(Protocol): # noqa: D101
6666
def __call__( # noqa: D102
6767
self, config: uvicorn.Config, contx_exit_timeout: Union[int, float, None] = None
68-
) -> Coroutine[None, None, UvicornServer]:
69-
...
68+
) -> Coroutine[None, None, UvicornServer]: ...
7069

7170

7271
# https://anyio.readthedocs.io/en/stable/testing.html#specifying-the-backends-to-run-on

0 commit comments

Comments
 (0)