From: Sebastián Ramírez Date: Sun, 25 Aug 2019 01:05:44 +0000 (-0500) Subject: :bug: Fix mypy route errors after merging #415 (#462) X-Git-Tag: 0.36.0~6 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e71636e381a297d1825b37f71362ecd36f2fb3fb;p=thirdparty%2Ffastapi%2Ffastapi.git :bug: Fix mypy route errors after merging #415 (#462) --- diff --git a/fastapi/routing.py b/fastapi/routing.py index 33a7d49d10..3c6774ceb3 100644 --- a/fastapi/routing.py +++ b/fastapi/routing.py @@ -449,9 +449,11 @@ class APIRouter(routing.Router): ), "A path prefix must not end with '/', as the routes will start with '/'" else: for r in router.routes: - if not r.path: + path = getattr(r, "path") + name = getattr(r, "name", "unknown") + if path is not None and not path: raise Exception( - f"Prefix and path cannot be both empty (operation: {r.name})" + f"Prefix and path cannot be both empty (path operation: {name})" ) if responses is None: responses = {}