starlette >v0.18 requires status_code on Response init
See original GitHub issueExample Code
https://github.com/tiangolo/fastapi/blob/master/fastapi/dependencies/utils.py
line 465
response = response or Response(
content=None,
status_code=None, # type: ignore
headers=None, # type: ignore # in Starlette
media_type=None, # type: ignore # in Starlette
background=None, # type: ignore # in Starlette
)
the above fails as https://github.com/encode/starlette/blob/master/starlette/responses.py requires status_code to be INT
line 74
if (
body is not None
and populate_content_length
and not (self.status_code < 200 or self.status_code in (204, 304))
):
FastAPI Version
0.75.1
Issue Analytics
- State:
- Created a year ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Responses
Responses. Starlette includes a few response classes that handle sending back the appropriate ASGI messages on the send channel.
Read more >starlette
Starlette is a small library for working with ASGI. It gives you Request and Response classes, websocket support, routing, static files support, ...
Read more >Response Status Code - FastAPI
You could also use from starlette import status . FastAPI provides the same starlette.status as fastapi.status just as a convenience for you, the...
Read more >python - FastAPI middleware peeking into responses
from starlette.middleware.base import BaseHTTPMiddleware from ... logger.info(f'Status code: {response.status_code}') body = b"" async for ...
Read more >init(url:statusCode:httpVersion:headerFields:)
Initializes an HTTP URL response object with a status code, protocol version, and response headers.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Greetings
I used pip to install FastAPI, (with all optional dependencies) then later I did an update to all packages. That is when I noticed that my application was failing. I then did a reinstall of FastAPI and that is when I noticed the downgrade. I checked the home page but did not see the requirement, it was only when I searched git that I saw the post and the reply with the requirement
That is why I made the suggestion that it be listed on the homepage
Hope this helps
Regards
On Fri, 22 Apr 2022, 15:56 Jordan Gould, @.***> wrote:
– This message and attachments are subject to a disclaimer.
Please refer to http://upnet.up.ac.za/services/it/documentation/docs/004167.pdf http://upnet.up.ac.za/services/it/documentation/docs/004167.pdf for full details.
@syldman can you close the issue -> https://github.com/tiangolo/fastapi/releases/tag/0.76.0