Skip to content

fix: make _handle param f positional-only to avoid kwarg conflict#840

Closed
weiguangli-io wants to merge 1 commit intoAnswerDotAI:mainfrom
weiguangli-io:codex/fasthtml-838-to-xml-indent
Closed

fix: make _handle param f positional-only to avoid kwarg conflict#840
weiguangli-io wants to merge 1 commit intoAnswerDotAI:mainfrom
weiguangli-io:codex/fasthtml-838-to-xml-indent

Conversation

@weiguangli-io
Copy link

Closes #834

Summary

When a POST route handler takes f as a form-data parameter, _handle(f, **wreq) raises:

TypeError: _handle() got multiple values for argument 'f'

because wreq contains f from the form data while f is also passed positionally as the handler function.

Fix

Add / after f in _handle's signature to make it positional-only:

async def _handle(f, /, *args, **kwargs):

This is the standard Python pattern for functions that forward **kwargs (see functools.partial, functools.reduce, etc.). The f parameter can only be passed positionally, so f=<value> in **kwargs no longer conflicts.

Updated both the notebook source (nbs/api/00_core.ipynb) and generated files (core.py, core.pyi).

AI-assisted testing, AI-assisted review

…lict

When a route handler has a parameter named `f`, calling
`_handle(f, **wreq)` raises "got multiple values for argument f"
because `wreq` also contains `f` from the form data.

Adding `/` after `f` makes it positional-only, so `f` in `**kwargs`
no longer conflicts with the function's first parameter.

Closes AnswerDotAI#834

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gitnotebooks
Copy link

gitnotebooks bot commented Mar 3, 2026

Found 1 changed notebook. Review the changes at https://app.gitnotebooks.com/AnswerDotAI/fasthtml/pull/840

@weiguangli-io
Copy link
Author

Closing — shifting focus to AI Agent core projects. Thank you for your time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] "_handle got multiple values for argument f" when a POST route takes f as an argument

1 participant