volfpeter / fasthx

FastAPI server-side rendering with built-in HTMX support.
https://volfpeter.github.io/fasthx/
MIT License
458 stars 9 forks source link

Fixed request context bug, silenced Ruff warnings #7

Closed shawnsw closed 10 months ago

shawnsw commented 10 months ago

Fixing the following error:

    return self.templates.TemplateResponse(name=template_name, request=request, context=result)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Jinja2Templates.TemplateResponse() got an unexpected keyword argument 'request'

The error is due to how the TemplateResponse is being constructed in the render function within the Jinja class. Specifically, the error arises because the TemplateResponse method is being called with an incorrect argument: request=request. The request should be part of the context dictionary, not passed as a separate argument.

Also fixed some obvious Ruff warnings and silenced the rest non-critical comment related warnings.

volfpeter commented 10 months ago

Closed following this comment.