]> git.ipfire.org Git - thirdparty/fastapi/fastapi.git/commitdiff
♻️ Simplify string format with f-strings in `fastapi/utils.py` (#10576)
authorEvgenii <ekublin@gmail.com>
Sat, 13 Jan 2024 14:31:38 +0000 (17:31 +0300)
committerGitHub <noreply@github.com>
Sat, 13 Jan 2024 14:31:38 +0000 (15:31 +0100)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
fastapi/utils.py

index f8463dda24675aa31e0928ad6ed7e2c79c20b411..0019c21532b48f7368e2c184027bd8a6fc3194d1 100644 (file)
@@ -173,17 +173,17 @@ def generate_operation_id_for_path(
         DeprecationWarning,
         stacklevel=2,
     )
-    operation_id = name + path
+    operation_id = f"{name}{path}"
     operation_id = re.sub(r"\W", "_", operation_id)
-    operation_id = operation_id + "_" + method.lower()
+    operation_id = f"{operation_id}_{method.lower()}"
     return operation_id
 
 
 def generate_unique_id(route: "APIRoute") -> str:
-    operation_id = route.name + route.path_format
+    operation_id = f"{route.name}{route.path_format}"
     operation_id = re.sub(r"\W", "_", operation_id)
     assert route.methods
-    operation_id = operation_id + "_" + list(route.methods)[0].lower()
+    operation_id = f"{operation_id}_{list(route.methods)[0].lower()}"
     return operation_id