Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 3 additions & 2 deletions fasthx/jinja.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,11 @@ def unpack_object(cls, obj: Any) -> dict[str, Any]:
if hasattr(obj, "__dict__"):
# Covers Pydantic models and standard classes.
object_keys = obj.__dict__.keys()
if hasattr(type(obj), "model_computed_fields"): # Pydantic computed fields support.
cls = type(obj)
if hasattr(cls, "model_computed_fields"): # Pydantic computed fields support.
object_keys = [
*(() if object_keys is None else object_keys),
*type(obj).model_computed_fields,
*cls.model_computed_fields,
]
elif hasattr(obj, "__slots__"):
# Covers classes with with __slots__.
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "fasthx"
version = "2.3.1"
version = "2.3.2"
description = "FastAPI server-side rendering with built-in HTMX support."
authors = ["Peter Volf <[email protected]>"]
readme = "README.md"
Expand Down
6 changes: 4 additions & 2 deletions tests/test_jinja.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,9 @@ class Model(BaseModel):
def random_number(self) -> int:
return 4

with warnings.catch_warnings():
warnings.simplefilter("error")
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
context = JinjaContext.unpack_object(Model(name="Eric"))
assert len(w) == 0

assert context == {"name": "Eric", "random_number": 4}