Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit de0126d

Browse files
eukubtiangolo
andauthored
♻️ Simplify string format with f-strings in fastapi/utils.py (#10576)
Co-authored-by: Sebastián Ramírez <[email protected]>
1 parent cca6203 commit de0126d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

fastapi/utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,17 +173,17 @@ def generate_operation_id_for_path(
173173
DeprecationWarning,
174174
stacklevel=2,
175175
)
176-
operation_id = name + path
176+
operation_id = f"{name}{path}"
177177
operation_id = re.sub(r"\W", "_", operation_id)
178-
operation_id = operation_id + "_" + method.lower()
178+
operation_id = f"{operation_id}_{method.lower()}"
179179
return operation_id
180180

181181

182182
def generate_unique_id(route: "APIRoute") -> str:
183-
operation_id = route.name + route.path_format
183+
operation_id = f"{route.name}{route.path_format}"
184184
operation_id = re.sub(r"\W", "_", operation_id)
185185
assert route.methods
186-
operation_id = operation_id + "_" + list(route.methods)[0].lower()
186+
operation_id = f"{operation_id}_{list(route.methods)[0].lower()}"
187187
return operation_id
188188

189189

0 commit comments

Comments
 (0)