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

Does FastAPI have to pin starlette? #5749

Closed
9 tasks done
dimaqq opened this issue Dec 7, 2022 · 2 comments
Closed
9 tasks done

Does FastAPI have to pin starlette? #5749

dimaqq opened this issue Dec 7, 2022 · 2 comments
Labels
question Question or problem question-migrate

Comments

@dimaqq
Copy link
Contributor

dimaqq commented Dec 7, 2022

First Check

  • I added a very descriptive title to this issue.
  • I used the GitHub search to find a similar issue and didn't find it.
  • I searched the FastAPI documentation, with the integrated search.
  • I already searched in Google "How to X in FastAPI" and didn't find any information.
  • I already read and followed all the tutorial in the docs and didn't find an answer.
  • I already checked if it is not related to FastAPI but to Pydantic.
  • I already checked if it is not related to FastAPI but to Swagger UI.
  • I already checked if it is not related to FastAPI but to ReDoc.

Commit to Help

  • I commit to help with one of those options 👆

Example Code

from fastapi.testclient import TestClient

TestClient(app, headers={...})

Description

FastAPI re-exports starlette TestClient which seems to be an httpx.Client connected to the asgi app under test.

starlette has recently fixed the TestClient.__init__ to follow httpx.Client.__init__ so that the earlier accepts headers=... kwarg, just like the latter.

encode/starlette#1966

starlette has made a release 0.23.0, but the latest FastAPI pins a specific version starlette==0.22.0

Thus, as a dev, I can't use the latest "features" or more like reasonable expectations for the TestClient.

A newcomer would read the docs / source code and would expect TestClient to accept headers kwarg and get confused why that's rejected.

Thus, the question: is there a reason to pin a specific version of starlette?

Operating System

Other

Operating System Details

An issue with any OS.

FastAPI Version

0.88.0

Python Version

3.10, etc.

Additional Context

No response

@dimaqq dimaqq added the question Question or problem label Dec 7, 2022
@jgould22
Copy link

jgould22 commented Dec 7, 2022

FastAPI is integrated quite closely with starlette, and unfortunately starlette doesn't use semantic versioning, so it's easy for a breaking starlette change to break FastAPI. The latest version of starlette does this, for example

#2532

If Starlette released a change that FastAPI did not support and you did not pin the version every install would break and cause everyone to have to pin starlette which is not desirable.

Generally in library(which fastapi is) code you should pin your dependencies, or use a lock file to ensure that the library is getting a version of its dependencies that it is known to support. For a library having known working code for a specific version is more important than features.

@dimaqq
Copy link
Contributor Author

dimaqq commented Dec 7, 2022

I guess as long as both FastAPI and Starlette are in the 0.x.x series, we just have to live with that.

P.S. I kinda wish that FastAPI at least would graduate, because SemVer has a gotcha for 0.x.x that most devs are not aware of. At least I was not and my peers were not.

@dimaqq dimaqq closed this as completed Dec 7, 2022
diegoquintanav added a commit to diegoquintanav/datadis that referenced this issue Jan 9, 2023
fix/upgrade dependencies

upgrades python version to 3.10.5
upgrades dependencies to their latest versions

this is needed because of pinned httpx version is outdated and TestClient breaks starlette and FastAPI

references

encode/starlette#1376
tiangolo/fastapi#5471
tiangolo/fastapi#5749
@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 #6211 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

3 participants