mirror of https://github.com/tiangolo/fastapi.git
♻️ Simplify string format with f-strings in `fastapi/utils.py` (#10576)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
This commit is contained in:
parent
cca6203c18
commit
de0126d145
|
|
@ -173,17 +173,17 @@ def generate_operation_id_for_path(
|
||||||
DeprecationWarning,
|
DeprecationWarning,
|
||||||
stacklevel=2,
|
stacklevel=2,
|
||||||
)
|
)
|
||||||
operation_id = name + path
|
operation_id = f"{name}{path}"
|
||||||
operation_id = re.sub(r"\W", "_", operation_id)
|
operation_id = re.sub(r"\W", "_", operation_id)
|
||||||
operation_id = operation_id + "_" + method.lower()
|
operation_id = f"{operation_id}_{method.lower()}"
|
||||||
return operation_id
|
return operation_id
|
||||||
|
|
||||||
|
|
||||||
def generate_unique_id(route: "APIRoute") -> str:
|
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)
|
operation_id = re.sub(r"\W", "_", operation_id)
|
||||||
assert route.methods
|
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
|
return operation_id
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue