Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Comments

✨ Support Starlette 0.52.0+ genericRequest#14863

Open
ollie-bell wants to merge 1 commit intofastapi:masterfrom
ollie-bell:feat/support-starlettte-request-generic
Open

✨ Support Starlette 0.52.0+ genericRequest#14863
ollie-bell wants to merge 1 commit intofastapi:masterfrom
ollie-bell:feat/support-starlettte-request-generic

Conversation

@ollie-bell
Copy link

@ollie-bellollie-bell commentedFeb 7, 2026
edited
Loading

Starlette 0.52.0 introduced dictionary-style syntax for improve type safety when accessingState. This PR adds support for this pattern when using FastAPI.

More context is given in this discussion:#14695 (comment)

Related:
#13965 - it seems like this draft PR was made prior to Starlette adding this functionality natively. Is there anything from this PR which should be brought into here?

@codspeed-hq
Copy link

codspeed-hqbot commentedFeb 7, 2026
edited
Loading

Merging this PR willnot alter performance

✅ 20 untouched benchmarks


Comparingollie-bell:feat/support-starlettte-request-generic (c940ab7) withmaster (faee822)1

Open in CodSpeed

Footnotes

  1. No successful run was found onmaster (da4135c) during the generation of this report, so faee822 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@ollie-bell
Copy link
Author

ollie-bell commentedFeb 7, 2026
edited
Loading

The test run for python 3.9 which uses lowest-direct resolution picks up starlette 0.45.3, which doesn't have this feature available - should the newly added test be marked asxfail forstarlette < 0.52.0?

@ollie-bellollie-bellforce-pushed thefeat/support-starlettte-request-generic branch from98f2eb5 to44e5a71CompareFebruary 8, 2026 14:08
@YuriiMotovYuriiMotov changed the titlefeat: support starlette 0.52.0+ generic Request✨ Support Starlette 0.52.0+ genericRequestFeb 9, 2026
@YuriiMotov
Copy link
Member

YuriiMotov commentedFeb 9, 2026
edited
Loading

The test run for python 3.9 which uses lowest-direct resolution picks up starlette 0.45.3, which doesn't have this feature available - should the newly added test be marked asxfail forstarlette < 0.52.0?

I think we should just skip it for starlette less than 0.52.0 (@pytest.mark.skipif())

@YuriiMotovYuriiMotov added featureNew feature or request waiting labelsFeb 9, 2026
@ollie-bellollie-bellforce-pushed thefeat/support-starlettte-request-generic branch from44e5a71 to940aa5dCompareFebruary 9, 2026 19:13
@github-actions
Copy link
Contributor

📝 Docs preview

Last commit940aa5d at:https://8b5ff73f.fastapitiangolo.pages.dev

1 similar comment
@github-actions
Copy link
Contributor

📝 Docs preview

Last commit940aa5d at:https://8b5ff73f.fastapitiangolo.pages.dev

@ollie-bell
Copy link
Author

ollie-bell commentedFeb 9, 2026
edited
Loading

I think we should just skip it for starlette less than 0.52.0 (@pytest.mark.skipif())

Thanks, that's done now ✅ I introduced thepackaging dependency into thetests dependency group to do the version comparison in a robust way.

@YuriiMotov
Copy link
Member

I introduced thepackaging dependency into thetests dependency group to do the version comparison in a robust way.

I would actually avoid adding new dependency for this - it's quite easy to parse version number into a tuple and compare with(0, 52, 0).
But we can wait for the feedback from Sebastian and update it if he requests it

Copy link
Member

@YuriiMotovYuriiMotov left a comment
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

LGTM!

Not sure about adding apackaging to test dependencies. (resolved)

Type hints in IDE work:

image
Code example
fromcollections.abcimportAsyncGeneratorfromcontextlibimportasynccontextmanagerfromtypingimportTypedDictfromfastapiimportFastAPI,RequestclassMyState(TypedDict):a:strb:int@asynccontextmanagerasyncdeflifespan(app:FastAPI)->AsyncGenerator[MyState]:yieldMyState(a="hello",b=42)app=FastAPI(lifespan=lifespan)@app.get("/")defmain(request:Request[MyState])->dict[str,str]:_=request.statereturn {"message":"Hello World"}

@ollie-bellollie-bellforce-pushed thefeat/support-starlettte-request-generic branch from940aa5d tobce4d6eCompareFebruary 9, 2026 20:04
@ollie-bell
Copy link
Author

ollie-bell commentedFeb 9, 2026
edited
Loading

I would actually avoid adding new dependency for this

That's understood - I've updated to parsestarlette.__version__ into a tuple for comparison, consistent with an existing pattern used elsewhere

PYDANTIC_VERSION_MINOR_TUPLE=tuple(int(x)forxinPYDANTIC_VERSION.split(".")[:2])

YuriiMotov reacted with thumbs up emoji

@github-actions

This comment was marked as resolved.

@github-actionsgithub-actionsbot added the conflictsAutomatically generated when a PR has a merge conflict labelFeb 11, 2026
@ollie-bellollie-bellforce-pushed thefeat/support-starlettte-request-generic branch frombce4d6e to0fa4abdCompareFebruary 11, 2026 21:20
@github-actionsgithub-actionsbot added conflictsAutomatically generated when a PR has a merge conflict and removed conflictsAutomatically generated when a PR has a merge conflict labelsFeb 11, 2026
@github-actions
Copy link
Contributor

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

@ollie-bellollie-bellforce-pushed thefeat/support-starlettte-request-generic branch from47c4888 toc940ab7CompareFebruary 17, 2026 11:49
@github-actionsgithub-actionsbot removed the conflictsAutomatically generated when a PR has a merge conflict labelFeb 17, 2026
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@YuriiMotovYuriiMotovYuriiMotov approved these changes

Assignees

No one assigned

Labels

featureNew feature or request

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@ollie-bell@YuriiMotov

[8]ページ先頭

©2009-2026 Movatter.jp