diff --git a/fasthtml/core.py b/fasthtml/core.py index ebf03fd2..ff961c3e 100644 --- a/fasthtml/core.py +++ b/fasthtml/core.py @@ -276,7 +276,7 @@ def __init__(self, f, skip=None): self.f,self.skip = f,skip or [] def __repr__(self): return f'Beforeware({self.f}, skip={self.skip})' # %% ../nbs/api/00_core.ipynb #78c3c357 -async def _handle(f, *args, **kwargs): +async def _handle(f, /, *args, **kwargs): return (await f(*args, **kwargs)) if is_async_callable(f) else await run_in_threadpool(f, *args, **kwargs) # %% ../nbs/api/00_core.ipynb #ad0f0e87 diff --git a/nbs/api/00_core.ipynb b/nbs/api/00_core.ipynb index 33df5c20..9866bb59 100644 --- a/nbs/api/00_core.ipynb +++ b/nbs/api/00_core.ipynb @@ -132,7 +132,7 @@ { "data": { "text/plain": [ - "datetime.datetime(2026, 6, 27, 14, 0)" + "datetime.datetime(2026, 6, 29, 14, 0)" ] }, "execution_count": null, @@ -1132,10 +1132,21 @@ "outputs": [], "source": [ "#| export\n", - "async def _handle(f, *args, **kwargs):\n", + "async def _handle(f, /, *args, **kwargs):\n", " return (await f(*args, **kwargs)) if is_async_callable(f) else await run_in_threadpool(f, *args, **kwargs)" ] }, + { + "cell_type": "code", + "execution_count": null, + "id": "c995850c", + "metadata": {}, + "outputs": [], + "source": [ + "async def _f(f): return f\"got {f}\"\n", + "test_eq(await _handle(_f, f='hello'), 'got hello')" + ] + }, { "cell_type": "markdown", "id": "079a3215", @@ -3371,13 +3382,13 @@ "name": "stdout", "output_type": "stream", "text": [ - "Set to 2026-06-27 12:38:48.010675\n" + "Set to 2026-06-29 21:09:52.332526\n" ] }, { "data": { "text/plain": [ - "'Session time: 2026-06-27 12:38:48.010675'" + "'Session time: 2026-06-29 21:09:52.332526'" ] }, "execution_count": null, @@ -4127,7 +4138,7 @@ { "data": { "text/plain": [ - "'Cookie was set at time 12:38:49.482843'" + "'Cookie was set at time 21:09:55.336114'" ] }, "execution_count": null,