From 220190fb38369d7f1a184364a5eeb627f58e2ffb Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 21 Apr 2025 17:17:50 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20[pre-commit.ci]=20Auto=20format?= =?UTF-8?q?=20from=20pre-commit.com=20hooks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fastapi/applications.py | 4 ++-- tests/test_ws_router.py | 38 +++++++++++++++++++++++++------------- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/fastapi/applications.py b/fastapi/applications.py index 5c2d31a5d..8d5325a68 100644 --- a/fastapi/applications.py +++ b/fastapi/applications.py @@ -1226,8 +1226,8 @@ class FastAPI(Starlette): """ A list of tags to be applied to this WebSocket. """ - ) - ] = None + ), + ] = None, ) -> Callable[[DecoratedCallable], DecoratedCallable]: """ Decorate a WebSocket function. diff --git a/tests/test_ws_router.py b/tests/test_ws_router.py index 740a3ccae..c917dc17b 100644 --- a/tests/test_ws_router.py +++ b/tests/test_ws_router.py @@ -13,9 +13,9 @@ from fastapi import ( from fastapi.middleware import Middleware from fastapi.testclient import TestClient -router = APIRouter(tags=['base']) -prefix_router = APIRouter(tags=['prefix']) -native_prefix_router = APIRouter(prefix="/native", tags=['native']) +router = APIRouter(tags=["base"]) +prefix_router = APIRouter(tags=["prefix"]) +native_prefix_router = APIRouter(prefix="/native", tags=["native"]) app = FastAPI() @@ -105,17 +105,23 @@ async def router_ws_custom_error(websocket: WebSocket): @app.websocket("/test_tags", name="test-app-tags", tags=["test-app-tags"]) - @router.websocket("/test_tags/", name="test-router-tags", tags=["test-router-tags"]) async def router_ws_test_tags(websocket: WebSocket): pass # pragma: no cover -@prefix_router.websocket("/test_tags/", name="test-prefix-router-tags", tags=["test-prefix-router-tags"]) + +@prefix_router.websocket( + "/test_tags/", name="test-prefix-router-tags", tags=["test-prefix-router-tags"] +) async def prefix_router_ws_test_tags(websocket: WebSocket): pass # pragma: no cover -@native_prefix_router.websocket("/test_tags/", name="test-native-prefix-router-tags", - tags=["test-native-prefix-router-tags"]) + +@native_prefix_router.websocket( + "/test_tags/", + name="test-native-prefix-router-tags", + tags=["test-native-prefix-router-tags"], +) async def native_prefix_router_ws_test_tags(websocket: WebSocket): pass # pragma: no cover @@ -287,12 +293,18 @@ def test_depend_err_handler(): assert "foo" in e.value.reason -@pytest.mark.parametrize("route_name,route_tags", [ - ("test-app-tags", ["test-app-tags"]), - ("test-router-tags", ["base", "test-router-tags"]), - ("test-prefix-router-tags", ["prefix", "test-prefix-router-tags"]), - ("test-native-prefix-router-tags", ["native", "test-native-prefix-router-tags"]), -]) +@pytest.mark.parametrize( + "route_name,route_tags", + [ + ("test-app-tags", ["test-app-tags"]), + ("test-router-tags", ["base", "test-router-tags"]), + ("test-prefix-router-tags", ["prefix", "test-prefix-router-tags"]), + ( + "test-native-prefix-router-tags", + ["native", "test-native-prefix-router-tags"], + ), + ], +) def test_websocket_tags(route_name, route_tags): """ Verify that it is possible to add tags to websocket routes