Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion tests/integrations/starlette/test_starlette.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,12 @@ async def _render_template(request):
"request": request,
"msg": "Hello Template World!",
}
return templates.TemplateResponse("trace_meta.html", template_context)
if STARLETTE_VERSION >= (1,):
return templates.TemplateResponse(
request, "trace_meta.html", template_context
)
Copy link

Choose a reason for hiding this comment

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

Redundant request in template context for Starlette 1.0

Low Severity

The template_context dict includes "request": request on line 144, which is redundant when using the Starlette 1.0+ API that passes request as a separate parameter on line 149. Starlette automatically injects request into the context when passed as a parameter, and best practice is to avoid including it in the context dict to prevent potential conflicts. The context should only contain {"msg": "Hello Template World!"} for the new API branch.

Fix in Cursor Fix in Web

else:
return templates.TemplateResponse("trace_meta.html", template_context)

all_methods = [
"CONNECT",
Expand Down
Loading