Skip to content

Commit

Permalink
♻️ Simplify string format with f-strings in fastapi/utils.py (#10576)
Browse files Browse the repository at this point in the history
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
  • Loading branch information
eukub and tiangolo committed Jan 13, 2024
1 parent cca6203 commit de0126d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions fastapi/utils.py
Expand Up @@ -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


Expand Down

0 comments on commit de0126d

Please sign in to comment.