Fix Deprecation Warnings for TemplateResponse and Jinja2Templates#575
Merged
jowilf merged 4 commits intojowilf:mainfrom Aug 31, 2024
Merged
Fix Deprecation Warnings for TemplateResponse and Jinja2Templates#575jowilf merged 4 commits intojowilf:mainfrom
jowilf merged 4 commits intojowilf:mainfrom
Conversation
Addresses jowilf#574 DeprecationWarning: The `name` is not the first parameter anymore. The first parameter should be the `Request` instance. Replace `TemplateResponse(name, {"request": request})` by `TemplateResponse(request, name)`. warnings.warn( Before Starlette 0.29.0, the name was the first parameter. Also, before that, in previous versions, the request object was passed as part of the key-value pairs in the context for Jinja2. See: - https://www.starlette.io/release-notes/#0290 - Kludex/starlette#2191 - https://github.com/encode/starlette/blob/c78c9aac17a4d68e0647252310044502f1b7da71/starlette/templating.py#L166-L178 - https://fastapi.tiangolo.com/reference/templating/#fastapi.templating.Jinja2Templates.TemplateResponse - https://fastapi.tiangolo.com/advanced/templates/#using-jinja2templates
Resolves jowilf#574 According to the Starlette 0.28.0 release notes, the **env_options parameter in Jinja2Templates has been deprecated in favor of the new env parameter. The relevant pull request #2159 explains this change. See: - Kludex/starlette#2159 - https://www.starlette.io/release-notes/#0280
for more information, see https://pre-commit.ci
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #575 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 75 76 +1
Lines 5817 5897 +80
=========================================
+ Hits 5817 5897 +80 ☔ View full report in Codecov by Sentry. |
jowilf
approved these changes
Aug 31, 2024
Merged
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #574
These warnings should no longer appear:
See:
requestargument toTemplateResponseKludex/starlette#2191