mirror of https://github.com/tiangolo/fastapi.git
🎨 [pre-commit.ci] Auto format from pre-commit.com hooks
This commit is contained in:
parent
12e31d2e55
commit
7e4af666d1
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
Loading…
Reference in New Issue