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
⬆ Upgrade Starlette from 0.18.0 to 0.19.0 #4488
Changes from 17 commits
e5c9343
8d10fca
7331e08
fb2fdf5
c096ac6
a96de7f
cc64170
03b0d4c
facb6d8
a659c2b
4305a0c
b19e848
1b3342b
09c70c4
880dd0d
c48a399
7b519b8
d382aa5
42f5e32
b6003a7
fd46adb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,20 +1,8 @@ | ||||||
from typing import Any, Dict, Optional, Sequence, Type | ||||||
from typing import Any, Sequence, Type | ||||||
|
||||||
from pydantic import BaseModel, ValidationError, create_model | ||||||
from pydantic.error_wrappers import ErrorList | ||||||
from starlette.exceptions import HTTPException as StarletteHTTPException | ||||||
|
||||||
|
||||||
class HTTPException(StarletteHTTPException): | ||||||
def __init__( | ||||||
self, | ||||||
status_code: int, | ||||||
detail: Any = None, | ||||||
headers: Optional[Dict[str, Any]] = None, | ||||||
) -> None: | ||||||
super().__init__(status_code=status_code, detail=detail) | ||||||
self.headers = headers | ||||||
|
||||||
from starlette.exceptions import HTTPException as HTTPException # noqa | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the renaming of import, i.e., There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I suppose there's not reason for |
||||||
|
||||||
RequestErrorModel: Type[BaseModel] = create_model("Request") | ||||||
WebSocketErrorModel: Type[BaseModel] = create_model("WebSocket") | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -126,7 +126,7 @@ async def serialize_response( | |
if is_coroutine: | ||
value, errors_ = field.validate(response_content, {}, loc=("response",)) | ||
else: | ||
value, errors_ = await run_in_threadpool( | ||
value, errors_ = await run_in_threadpool( # type: ignore[misc] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about adding proper type hints for these names? |
||
field.validate, response_content, {}, loc=("response",) | ||
) | ||
if isinstance(errors_, ErrorWrapper): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are several examples and places in the code base that expect
detail
to be any JSON-able data, not only a string (as is with Starlette).So, only for this little type hint we still need the custom
HTTPException
class in FastAPI.