Skip to content

Commit 335ee9d

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 56bb01e commit 335ee9d

File tree

5 files changed

+13
-26
lines changed

5 files changed

+13
-26
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==25.1.0",
88-
"ruff==0.11.2",
87+
"black==26.1.0",
88+
"ruff==0.15.0",
8989
"codespell==2.4.1",
9090
# Don't write comments on these lines, because they will be removed by `pre-commit run ver_sync`.
9191
# NOTE: 👆

scripts/pre_commit_scripts/ver_sync.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
"""Maintain lint tools version consistency between `.pre-commit-config.yaml` and `pyproject.toml`."""
44

5-
65
# https://packaging.pypa.io/en/stable/requirements.html
76
# https://yaml.readthedocs.io/en/latest/example/
87
# https://tomlkit.readthedocs.io/en/latest/quickstart/

src/fastapi_proxy_lib/core/_tool.py

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -204,39 +204,31 @@ def check_base_url(base_url: Union[httpx.URL, str], /) -> httpx.URL:
204204
)
205205

206206
if not base_url.scheme or not base_url.netloc:
207-
raise BaseURLError(
208-
dedent(
209-
f"""\
207+
raise BaseURLError(dedent(f"""\
210208
`base_url` must contain scheme and netloc,
211209
e.g. {example_url}
212210
got: {base_url}\
213-
"""
214-
)
215-
)
211+
"""))
216212

217213
# NOTE: 尽量用 URL.copy_with() 来修改URL,而不是 URL.join(),因为后者性能较差
218214

219215
if base_url.query or base_url.fragment:
220216
base_url = base_url.copy_with(query=None, fragment=None)
221217
warnings.warn(
222-
dedent(
223-
f"""\
218+
dedent(f"""\
224219
`base_url` should not contain `query` or `fragment`, which will be ignored.
225220
The `base_url` will be treated as: {base_url}\
226-
"""
227-
),
221+
"""),
228222
stacklevel=2,
229223
)
230224
# 我们在这里强制要求 base_url 以"/"结尾是有原因的:
231225
# 因为 RouterHelper 生成的路由是以"/"结尾的,在反向代理时
232226
# "/" 之后后路径参数将会被拼接到这个 base_url 后面
233227
if not str(base_url).endswith("/"):
234-
msg = dedent(
235-
f"""\
228+
msg = dedent(f"""\
236229
`base_url` must ends with "/", may be you mean:
237230
{base_url}/\
238-
"""
239-
)
231+
""")
240232
raise BaseURLError(msg)
241233

242234
return base_url
@@ -424,17 +416,15 @@ def warn_for_none_filter(
424416
Else will just return the original argument `proxy_filter`.
425417
"""
426418
if proxy_filter is None:
427-
msg = dedent(
428-
"""\
419+
msg = dedent("""\
429420
The `proxy_filter` is None, which means no filter will be used.
430421
It is not recommended, because it may cause security issues.
431422
432423
A default proxy filter will be used, which will reject the proxy request:
433424
- if the host of url is ip address, and is not global ip address.
434425
435426
More info: https://wsh032.github.io/fastapi-proxy-lib/Usage/Security/
436-
"""
437-
)
427+
""")
438428
warnings.warn(msg, stacklevel=3)
439429
return default_proxy_filter
440430
else:

src/fastapi_proxy_lib/fastapi/__init__.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@
99
from textwrap import dedent
1010

1111
if find_spec("fastapi") is None: # pragma: no cover # 无法测试
12-
msg: str = dedent(
13-
"""\
12+
msg: str = dedent("""\
1413
`fastapi` is not installed.
1514
`fastapi_proxy_lib.fastapi` module requires installing `fastapi` first:
1615
pip install fastapi-proxy-lib[standard]
17-
"""
18-
)
16+
""")
1917
raise RuntimeError(msg)

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# ruff: noqa: ANN201, ANN001
1+
# ruff: noqa: ANN201
22

33
# pyright: reportMissingParameterType=false
44
# 返回值标注太麻烦,让pyright自己推断

0 commit comments

Comments
 (0)