FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

⬆️ Bump Starlette to <`0.53.0` by musicinmybrain · Pull Request #14695 · fastapi/fastapi · GitHub

Repository navigation

⬆️ Bump Starlette to <0.53.0 - #14695

Closed
musicinmybrain wants to merge 1 commit into
fastapi:masterfrom
musicinmybrain:starlette-0.51
Closed

musicinmybrain wants to merge 1 commit into
fastapi:masterfrom
musicinmybrain:starlette-0.51

Conversation

Copy link
Copy Markdown
Contributor

In Starlette 0.51, the warning stacklevel on DeprecationWarning for the wsgi module was increased. There is no impact to FastAPI; all tests still pass.

codspeed Bot commented Jan 11, 2026 •
edited
Loading

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 20 untouched benchmarks


Comparing musicinmybrain:starlette-0.51 (cd01810) with master (79406a4)

github-actions Bot commented Jan 11, 2026 •
edited
Loading

Copy link
Copy Markdown
Contributor

📝 Docs preview

Last commit cd01810 at: https://992b0e89.fastapitiangolo.pages.dev

jkugler commented Jan 19, 2026

Copy link
Copy Markdown

Could we get this bumped to <0.53 as 0.52.1 is out. https://github.com/Kludex/starlette/releases/tag/0.52.1

Copy link
Copy Markdown
Contributor Author

Could we get this bumped to <0.53 as 0.52.1 is out. https://github.com/Kludex/starlette/releases/tag/0.52.1

Sure. It looks like 0.52.0 should be compatible, and just adds a new feature: “In this release, State can be accessed using dictionary-style syntax for improved type safety (https://github.com/Kludex/starlette/pull/3036).”

musicinmybrain changed the title ⬆️ Bump Starlette to <0.52.0 ⬆️ Bump Starlette to <0.53.0 Jan 20, 2026

Copy link
Copy Markdown
Contributor Author

Updated to allow Starlette 0.52. All tests still pass.

Copy link
Copy Markdown
Member

Failing CI should be resolved by #14756

github-actions Bot commented Feb 4, 2026

Copy link
Copy Markdown
Contributor

This pull request has a merge conflict that needs to be resolved.

github-actions Bot removed the conflicts Automatically generated when a PR has a merge conflict label Feb 4, 2026

galah92 commented Feb 4, 2026

Copy link
Copy Markdown

Will this allow using strict types for app.state?

Copy link
Copy Markdown
Contributor Author

Will this allow using strict types for app.state?

I have no idea. I suppose you must be talking about the changes in https://github.com/Kludex/starlette/releases/tag/0.52.0.

ollie-bell commented Feb 4, 2026 •
edited
Loading

Copy link
Copy Markdown

Will this allow using strict types for app.state?

It does not seem to work... I took the Starlette docs example, converted it to use FastAPI and forced an installation of starlette==0.52.1. Have pasted the stack trace below.

from collections.abc import AsyncIterator
from contextlib import asynccontextmanager
from typing import TypedDict

import httpx
from fastapi import FastAPI, Request
from fastapi.responses import PlainTextResponse


class State(TypedDict):
    http_client: httpx.AsyncClient


@asynccontextmanager
async def lifespan(app: FastAPI) -> AsyncIterator[State]:
    async with httpx.AsyncClient() as client:
        yield {"http_client": client}


app = FastAPI(lifespan=lifespan)


@app.get("/")
async def homepage(request: Request[State]) -> PlainTextResponse:
    client = request.state["http_client"]

    reveal_type(client)  # Revealed type is 'httpx.AsyncClient'

    response = await client.get("https://www.example.com")
    return PlainTextResponse(response.text)


if __name__ == "__main__":
    import uvicorn

    uvicorn.run(app=app)
Traceback (most recent call last):
  File "/Users/ollie/Documents/fastapi-lifespan-state-attribute-style.py", line 24, in <module>
    @app.get("/")
     ~~~~~~~^^^^^
  File "/Users/ollie/Documents/.venv/lib/python3.13/site-packages/fastapi/routing.py", line 1063, in decorator
    self.add_api_route(
    ~~~~~~~~~~~~~~~~~~^
        path,
        ^^^^^
    ...<23 lines>...
        generate_unique_id_function=generate_unique_id_function,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/Users/ollie/Documents/.venv/lib/python3.13/site-packages/fastapi/routing.py", line 1002, in add_api_route
    route = route_class(
        self.prefix + path,
    ...<24 lines>...
        generate_unique_id_function=current_generate_unique_id,
    )
  File "/Users/ollie/Documents/.venv/lib/python3.13/site-packages/fastapi/routing.py", line 621, in __init__
    self.dependant = get_dependant(
                     ~~~~~~~~~~~~~^
        path=self.path_format, call=self.endpoint, scope="function"
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/Users/ollie/Documents/.venv/lib/python3.13/site-packages/fastapi/dependencies/utils.py", line 281, in get_dependant
    param_details = analyze_param(
        param_name=param_name,
    ...<2 lines>...
        is_path_param=is_path_param,
    )
  File "/Users/ollie/Documents/.venv/lib/python3.13/site-packages/fastapi/dependencies/utils.py", line 506, in analyze_param
    field = create_model_field(
        name=param_name,
    ...<4 lines>...
        field_info=field_info,
    )
  File "/Users/ollie/Documents/.venv/lib/python3.13/site-packages/fastapi/utils.py", line 95, in create_model_field
    raise fastapi.exceptions.FastAPIError(
        _invalid_args_message.format(type_=type_)
    ) from None
fastapi.exceptions.FastAPIError: Invalid args for response field! Hint: check that starlette.requests.Request[__main__.State] is a valid Pydantic field type. If you are using a return type annotation that is not a valid Pydantic field (e.g. Union[Response, dict, None]) you can disable generating the response model from the type annotation with the path operation decorator parameter response_model=None. Read more: https://fastapi.tiangolo.com/tutorial/response-model/

Kludex commented Feb 5, 2026

Copy link
Copy Markdown
Member

The above implies more changes are needed than just the bump. 😢

galah92 commented Feb 5, 2026

Copy link
Copy Markdown

Will this allow using strict types for app.state?

It does not seem to work... I took the Starlette docs example, converted it to use FastAPI and forced an installation of starlette==0.52.1. Have pasted the stack trace below.

Thanks. Does this imply we need FastAPI changes to make it work, or further Starlette?

Kludex commented Feb 5, 2026

Copy link
Copy Markdown
Member

FastAPI.

galah92 commented Feb 5, 2026

Copy link
Copy Markdown

FastAPI.

Thank you, I'll be happy to contribute this change once this PR is merged, if needed.

Copy link
Copy Markdown

With #14756 in and CI all green, is there anything else blocking this PR @YuriiMotov?

antbz commented Feb 6, 2026

Copy link
Copy Markdown

Hi! Bumping this too, we need the updates to CORSMiddleware introduced in Starlette 0.51.0 and current constraints are blocking us from this.

github-actions Bot commented Feb 6, 2026

Copy link
Copy Markdown
Contributor

This pull request has a merge conflict that needs to be resolved.

github-actions Bot added the conflicts Automatically generated when a PR has a merge conflict label Feb 6, 2026

Copy link
Copy Markdown

I guess this is now superseded by #14853

tiangolo commented Feb 6, 2026

Copy link
Copy Markdown
Member

This was superseded by #14853, released in FastAPI 0.128.3 🎉


I fixed what is needed to support the latest Starlette version, and what is in git in the main branch in another PR. 🤓

tiangolo closed this Feb 6, 2026

ollie-bell commented Feb 6, 2026 •
edited
Loading

Copy link
Copy Markdown

I fixed what is needed to support the latest Starlette version, and what is in git in the main branch in another PR. 🤓

@tiangolo Can I clarify if here you were referring to starlette 0.52.0+ Request with generic state type? I just tried 0.128.3 and the example shown above still errors in the same way.

Copy link
Copy Markdown
Contributor Author

This was superseded by #14853, released in FastAPI 0.128.3 🎉

Thank you! The broader version range will be quite helpful for downstream packaging.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

conflicts Automatically generated when a PR has a merge conflict upgrade

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants


Back | FazBrowse Home | New Git URL