Skip to content

Commit

Permalink
♻ Simplify internal RegEx in fastapi/utils.py (#5057)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
pylounge and pre-commit-ci[bot] committed Aug 26, 2022
1 parent 1f2070a commit dc10b81
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fastapi/utils.py
Expand Up @@ -140,14 +140,14 @@ def generate_operation_id_for_path(
stacklevel=2,
)
operation_id = name + path
operation_id = re.sub("[^0-9a-zA-Z_]", "_", operation_id)
operation_id = re.sub(r"\W", "_", operation_id)
operation_id = operation_id + "_" + method.lower()
return operation_id


def generate_unique_id(route: "APIRoute") -> str:
operation_id = route.name + route.path_format
operation_id = re.sub("[^0-9a-zA-Z_]", "_", operation_id)
operation_id = re.sub(r"\W", "_", operation_id)
assert route.methods
operation_id = operation_id + "_" + list(route.methods)[0].lower()
return operation_id
Expand Down

0 comments on commit dc10b81

Please sign in to comment.