From 7e4af666d16d1fa972df2a8828cfc18730a51048 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 11 Sep 2022 16:52:23 +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/routing.py | 12 +++++++++--- tests/test_tags.py | 4 +++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/fastapi/routing.py b/fastapi/routing.py index a4c25c159..e8e5ba788 100644 --- a/fastapi/routing.py +++ b/fastapi/routing.py @@ -500,7 +500,9 @@ class APIRouter(routing.Router): ), "A path prefix must not end with '/', as the routes will start with '/'" self.prefix = prefix if tags: - assert not isinstance(tags, str), """tags should not be a string: please use ["tag"] instead of "tag".""" + assert not isinstance( + tags, str + ), """tags should not be a string: please use ["tag"] instead of "tag".""" self.tags: List[Union[str, Enum]] = tags or [] self.dependencies = list(dependencies or []) or [] self.deprecated = deprecated @@ -554,7 +556,9 @@ class APIRouter(routing.Router): ) current_tags = self.tags.copy() if tags: - assert not isinstance(tags, str), """tags should not be a string: please use ["tag"] instead of "tag".""" + assert not isinstance( + tags, str + ), """tags should not be a string: please use ["tag"] instead of "tag".""" current_tags.extend(tags) current_dependencies = self.dependencies.copy() if dependencies: @@ -719,7 +723,9 @@ class APIRouter(routing.Router): ) current_tags = [] if tags: - assert not isinstance(tags, str), """tags should not be a string: please use ["tag"] instead of "tag".""" + assert not isinstance( + tags, str + ), """tags should not be a string: please use ["tag"] instead of "tag".""" current_tags.extend(tags) if route.tags: current_tags.extend(route.tags) diff --git a/tests/test_tags.py b/tests/test_tags.py index f38d84223..e115b3e3d 100644 --- a/tests/test_tags.py +++ b/tests/test_tags.py @@ -6,10 +6,12 @@ def test_string_is_invalid_in_router_tags(): with pytest.raises(AssertionError): router = APIRouter(tags="test") + def test_string_is_invalid_in_router_route_tags(): router = APIRouter() with pytest.raises(AssertionError): + @router.get("", tags="test") def test(): ... @@ -24,4 +26,4 @@ def test_string_is_invalid_in_include_router_tags(): ... with pytest.raises(AssertionError): - app.include_router(router, prefix="/test", tags="test") \ No newline at end of file + app.include_router(router, prefix="/test", tags="test")