From aaf14a86ab676d192dda6c17f0c44ad0f5bf8fc6 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci-lite[bot]" <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Date: Tue, 13 Jan 2026 05:06:06 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Auto=20format?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fastapi/dependencies/utils.py | 6 +++--- fastapi/security/http.py | 4 +--- tests/test_security_http_base.py | 6 +++--- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/fastapi/dependencies/utils.py b/fastapi/dependencies/utils.py index 08c82f173..30522df31 100644 --- a/fastapi/dependencies/utils.py +++ b/fastapi/dependencies/utils.py @@ -5,7 +5,6 @@ from collections.abc import Coroutine, Mapping, Sequence from contextlib import AsyncExitStack, contextmanager from copy import copy, deepcopy from dataclasses import dataclass -from typing import get_type_hints from typing import ( Annotated, Any, @@ -14,6 +13,7 @@ from typing import ( Optional, Union, cast, + get_type_hints, ) import anyio @@ -284,7 +284,7 @@ def get_dependant( for param_name, param in signature_params.items(): annotation = param.annotation - + # Resolve ForwardRef inside Annotated without destroying metadata if get_origin(annotation) is Annotated: args = list(get_args(annotation)) @@ -294,7 +294,7 @@ def get_dependant( args[0] = inner annotation = Annotated[inner, *args[1:]] param = param.replace(annotation=annotation) - + is_path_param = param_name in path_param_names param_details = analyze_param( param_name=param_name, diff --git a/fastapi/security/http.py b/fastapi/security/http.py index 7646e7f44..dc62a2bb1 100644 --- a/fastapi/security/http.py +++ b/fastapi/security/http.py @@ -145,15 +145,13 @@ class HTTPBasic(HTTPBase): scheme_name: Optional[str] = None, description: Optional[str] = None, auto_error: bool = True, -): + ): self.model = HTTPBaseModel(scheme="basic", description=description) self.scheme_name = scheme_name or self.__class__.__name__ self.auto_error = auto_error - def make_authenticate_headers(self) -> dict[str, str]: return {"WWW-Authenticate": "Basic"} - async def __call__( # type: ignore self, request: Request diff --git a/tests/test_security_http_base.py b/tests/test_security_http_base.py index debd97bcc..1e948f218 100644 --- a/tests/test_security_http_base.py +++ b/tests/test_security_http_base.py @@ -1,7 +1,7 @@ -from fastapi import FastAPI, Security, Depends +from fastapi import Depends, FastAPI, Security +from fastapi.security import HTTPBasic from fastapi.security.http import HTTPAuthorizationCredentials, HTTPBase from fastapi.testclient import TestClient -from fastapi.security import HTTPBasic app = FastAPI() @@ -55,6 +55,7 @@ def test_openapi_schema(): }, } + def test_http_basic_includes_realm(): app = FastAPI() security = HTTPBasic(realm="MyRealm") @@ -68,4 +69,3 @@ def test_http_basic_includes_realm(): assert response.status_code == 401 assert response.headers["WWW-Authenticate"] == 'Basic realm="MyRealm"' - \ No newline at end of file