fasthx 2.3.0__tar.gz → 2.3.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: fasthx
3
- Version: 2.3.0
3
+ Version: 2.3.2
4
4
  Summary: FastAPI server-side rendering with built-in HTMX support.
5
5
  License: MIT
6
6
  Author: Peter Volf
@@ -218,6 +218,7 @@ See the full working example [here](https://github.com/volfpeter/fasthx/tree/mai
218
218
 
219
219
  ### External examples
220
220
 
221
+ - [lipsum-chat](https://github.com/volfpeter/lipsum-chat): A simple chat application using `htmy` for server-side rendering, and HTMX, TailwindCSS v4 and DaisyUI v5 for the frontend.
221
222
  - [FastAPI-HTMX-Tailwind example](https://github.com/volfpeter/fastapi-htmx-tailwind-example): A complex `Jinja2` example with features like active search, lazy-loading, server-sent events, custom server-side HTMX triggers, dialogs, and TailwindCSS and DaisyUI integration.
222
223
 
223
224
  ## Dependencies
@@ -197,6 +197,7 @@ See the full working example [here](https://github.com/volfpeter/fasthx/tree/mai
197
197
 
198
198
  ### External examples
199
199
 
200
+ - [lipsum-chat](https://github.com/volfpeter/lipsum-chat): A simple chat application using `htmy` for server-side rendering, and HTMX, TailwindCSS v4 and DaisyUI v5 for the frontend.
200
201
  - [FastAPI-HTMX-Tailwind example](https://github.com/volfpeter/fastapi-htmx-tailwind-example): A complex `Jinja2` example with features like active search, lazy-loading, server-sent events, custom server-side HTMX triggers, dialogs, and TailwindCSS and DaisyUI integration.
201
202
 
202
203
  ## Dependencies
@@ -47,10 +47,11 @@ class JinjaContext:
47
47
  Conversion rules:
48
48
 
49
49
  - `dict`: returned as is.
50
- - `Collection`: returned as `{"items": route_context}`, available in templates as `items`.
50
+ - `Collection`: returned as `{"items": obj}`, available in templates as `items`.
51
51
  - Objects with `__dict__` or `__slots__`: known keys are taken from `__dict__` or `__slots__`
52
52
  and the context will be created as `{key: getattr(route_result, key) for key in keys}`,
53
- omitting property names starting with an underscore.
53
+ omitting property names starting with an underscore. For Pydantic models, computed
54
+ fields will also be included.
54
55
  - `None` is converted into an empty context.
55
56
 
56
57
  Raises:
@@ -69,6 +70,12 @@ class JinjaContext:
69
70
  if hasattr(obj, "__dict__"):
70
71
  # Covers Pydantic models and standard classes.
71
72
  object_keys = obj.__dict__.keys()
73
+ cls = type(obj)
74
+ if hasattr(cls, "model_computed_fields"): # Pydantic computed fields support.
75
+ object_keys = [
76
+ *(() if object_keys is None else object_keys),
77
+ *cls.model_computed_fields,
78
+ ]
72
79
  elif hasattr(obj, "__slots__"):
73
80
  # Covers classes with with __slots__.
74
81
  object_keys = obj.__slots__
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "fasthx"
3
- version = "2.3.0"
3
+ version = "2.3.2"
4
4
  description = "FastAPI server-side rendering with built-in HTMX support."
5
5
  authors = ["Peter Volf <do.volfp@gmail.com>"]
6
6
  readme = "README.md"
@@ -9,8 +9,8 @@ license = "MIT"
9
9
  [tool.poetry.dependencies]
10
10
  python = "^3.10"
11
11
  fastapi = ">=0.100.0"
12
- htmy = {version = ">=0.5.0", optional = true}
13
- jinja2 = {version = "^3.0.0", optional = true}
12
+ htmy = { version = ">=0.5.0", optional = true }
13
+ jinja2 = { version = "^3.0.0", optional = true }
14
14
 
15
15
  [tool.poetry.extras]
16
16
  htmy = ["htmy"]
@@ -21,12 +21,12 @@ htmy = ">=0.5.0"
21
21
  httpx = "^0.26.0"
22
22
  jinja2 = "^3.0.0"
23
23
  mkdocs-material = "^9.5.32"
24
- mkdocstrings = {extras = ["python"], version = "^0.25.2"}
24
+ mkdocstrings = { extras = ["python"], version = "^0.25.2" }
25
25
  mypy = "^1.15.0"
26
26
  poethepoet = "^0.30.0"
27
27
  pytest = "^8.3.3"
28
28
  pytest-random-order = "^1.1.1"
29
- ruff = "^0.9.0"
29
+ ruff = "^0.11.2"
30
30
  typing-extensions = ">=4.5.0"
31
31
  uvicorn = "^0.32.0"
32
32
 
@@ -50,17 +50,17 @@ exclude = [
50
50
  "docs",
51
51
  ]
52
52
  lint.select = [
53
- "E", # pycodestyle errors
54
- "W", # pycodestyle warnings
55
- "F", # pyflakes
56
- "I", # isort
57
- "S", # flake8-bandit - we must ignore these rules in tests
58
- "C", # flake8-comprehensions
59
- "B", # flake8-bugbear
53
+ "E", # pycodestyle errors
54
+ "W", # pycodestyle warnings
55
+ "F", # pyflakes
56
+ "I", # isort
57
+ "S", # flake8-bandit - we must ignore these rules in tests
58
+ "C", # flake8-comprehensions
59
+ "B", # flake8-bugbear
60
60
  ]
61
61
 
62
62
  [tool.ruff.lint.per-file-ignores]
63
- "tests/**/*" = ["S101"] # S101: use of assert detected
63
+ "tests/**/*" = ["S101"] # S101: use of assert detected
64
64
 
65
65
  [tool.poe.tasks]
66
66
  check-format = "ruff format --check ."
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes