Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove return statement that is never reached on get_trusted_client_host() method #1349

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions uvicorn/middleware/proxy_headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,16 @@ def __init__(
self.trusted_hosts = set(trusted_hosts)
self.always_trust = "*" in self.trusted_hosts

def get_trusted_client_host(
def get_trusted_client_host( # type: ignore[return]
self, x_forwarded_for_hosts: List[str]
) -> Optional[str]:
) -> str:
if self.always_trust:
return x_forwarded_for_hosts[0]

for host in reversed(x_forwarded_for_hosts):
if host not in self.trusted_hosts:
return host

return None

async def __call__(
self, scope: Scope, receive: ASGIReceiveCallable, send: ASGISendCallable
) -> None:
Expand Down