Why do I have to specify the type of a path parameter in the path? #2683
-
If I have a router handler like this, why do I have to specify the type of name twice? Why isn't it enough to only specify the type of the function parameter? @get("/{name:str}")
async def greeter(name: str) -> str:
return "Hello, " + name |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
My thoughts are that the function signature is for typing (mypy, pyright, etc) validation and user documentation and the route handler is for routing validation to be consumed by But Peter had a better answer 😅:
|
Beta Was this translation helpful? Give feedback.
My thoughts are that the function signature is for typing (mypy, pyright, etc) validation and user documentation and the route handler is for routing validation to be consumed by
msgspec
to validate the incoming data.But Peter had a better answer 😅: