-
First Check
Commit to Help
Example Codefrom pprint import pprint
import fastapi
response = fastapi.Response()
response.delete_cookie("cookie1")
response.delete_cookie("cookie2")
pprint(list(response.headers.items()))
# [('content-length', '0'),
# ('set-cookie',
# 'cookie1=""; expires=Thu, 07 Nov 2024 08:26:12 GMT; Max-Age=0; Path=/; '
# 'SameSite=lax'),
# ('set-cookie',
# 'cookie2=""; expires=Thu, 07 Nov 2024 08:26:12 GMT; Max-Age=0; Path=/; '
# 'SameSite=lax')]
headers = fastapi.datastructures.Headers(
raw=[(b"set-cookie", x.encode()) for x in response.headers.getlist("set-cookie")]
)
exc = fastapi.HTTPException(400, headers=headers)
# Argument of type "Headers" cannot be assigned to parameter "headers" of type "Dict[str, str] | None" in function "__init__"
# Type "Headers" is not assignable to type "Dict[str, str] | None"
# "Headers" is not assignable to "Dict[str, str]"
# "Headers" is not assignable to "None"PylancereportArgumentTypeDescriptionHTTP Headers cannot be represented by a As such type of In the example I tried assigning
Operating SystemLinux Operating System DetailsNo response FastAPI Version0.111.1 Pydantic Version2.8.2 Python VersionPython 3.12.4 Additional ContextNo response |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
|
This will probably require a similar change in starlette, as EDIT: Kludex/starlette#2749. |
Beta Was this translation helpful? Give feedback.
-
|
PR #12997 opened. |
Beta Was this translation helpful? Give feedback.
PR #12997 opened.