Browse Source

perf: instead of creating list of method use iterator

Changes according to [this](https://docs.astral.sh/ruff/rules/unnecessary-iterable-allocation-for-first-element/)
pull/11436/head
JD Solanki 12 months ago
committed by GitHub
parent
commit
aa1a15996c
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 2
      fastapi/utils.py

2
fastapi/utils.py

@ -183,7 +183,7 @@ def generate_unique_id(route: "APIRoute") -> str:
operation_id = f"{route.name}{route.path_format}"
operation_id = re.sub(r"\W", "_", operation_id)
assert route.methods
operation_id = f"{operation_id}_{list(route.methods)[0].lower()}"
operation_id = f"{operation_id}_{next(iter(route.methods)).lower()}"
return operation_id

Loading…
Cancel
Save