🎨 [pre-commit.ci] Auto format from pre-commit.com hooks

This commit is contained in:
pre-commit-ci[bot] 2022-09-11 16:52:23 +00:00
parent 12e31d2e55
commit 7e4af666d1
2 changed files with 12 additions and 4 deletions

View File

@ -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)

View File

@ -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")
app.include_router(router, prefix="/test", tags="test")