Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

starlette >v0.18 requires status_code on Response init #4800

Closed
syldman opened this issue Apr 15, 2022 · 6 comments
Closed

starlette >v0.18 requires status_code on Response init #4800

syldman opened this issue Apr 15, 2022 · 6 comments
Labels
question Question or problem question-migrate

Comments

@syldman
Copy link

syldman commented Apr 15, 2022

Example 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

@syldman syldman added the question Question or problem label Apr 15, 2022
@jgould22
Copy link

jgould22 commented Apr 15, 2022

Yes, this is one of the reasons FastAPI's current code base uses Starlette 17.

This fix is applied for the update merge request.
https://github.com/tiangolo/fastapi/pull/4483/files#diff-aef3dac481b68359f4edd6974fa3a047cfde595254a4567a560cebc9ccb0673f

@deJagerF
Copy link

Greetings

Can I suggest that you state on the the home page that you use Starlette 17 and that users must be carefull when doing an upgrade to their python packages

I upgraged my environment, then everything broke till I reinstalled fastapi[all] and I noticed that Starlette is being downgraded to 17

@jgould22
Copy link

jgould22 commented Apr 22, 2022

The projects dependencies are listed in the pyproject.toml.

Are you not using a vituralenv ? or perhaps listing Starlette along with FastAPI as a dependency?

@deJagerF
Copy link

deJagerF commented Apr 22, 2022 via email

@Kludex
Copy link
Sponsor Collaborator

Kludex commented Apr 24, 2022

@raphaelauv
Copy link
Contributor

@syldman can you close the issue -> https://github.com/tiangolo/fastapi/releases/tag/0.76.0

@syldman syldman closed this as completed May 6, 2022
@tiangolo tiangolo reopened this Feb 27, 2023
Repository owner locked and limited conversation to collaborators Feb 27, 2023
@tiangolo tiangolo converted this issue into discussion #6375 Feb 27, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
question Question or problem question-migrate
Projects
None yet
Development

No branches or pull requests

6 participants