]> git.ipfire.org Git - thirdparty/fastapi/fastapi.git/commitdiff
:bug: Fix mypy route errors after merging #415 (#462)
authorSebastián Ramírez <tiangolo@gmail.com>
Sun, 25 Aug 2019 01:05:44 +0000 (20:05 -0500)
committerGitHub <noreply@github.com>
Sun, 25 Aug 2019 01:05:44 +0000 (20:05 -0500)
fastapi/routing.py

index 33a7d49d10155235d32ca464a6e3a2b93feb0c03..3c6774ceb3d354126669075646b7813b0fe7be55 100644 (file)
@@ -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 = {}