Correct JSON return type and use immutable route method default

Commit cb7592b · patx · 2026-10-15T20:59:14-04:00

Changeset
cb7592b55bde231776bc22761aa8ceadba6e2077
Parents
75d663079faf29c5c5126491796a4c6d113aa531

View source at this commit

Comments

No comments yet.

Log in to comment

Diff

diff --git a/wred.py b/wred.py
index 8d35faa..5ee7431 100644
--- a/wred.py
+++ b/wred.py
@@ -54,7 +54,7 @@ class Request:
             self._body = b''.join(chunks)
         return self._body
 
-    async def json(self) -> dict[str, Any]:
+    async def json(self) -> Any:
         """Parse the request body as JSON."""
         body = await self.body()
         return orjson.loads(body) if body else {}
@@ -154,7 +154,7 @@ class App:
 
         return await to_thread(read)
 
-    def route(self, path: str, methods: list[str] = ['GET']) -> Callable:
+    def route(self, path: str, methods: list[str] | tuple[str, ...] = ('GET',)) -> Callable:
         """Decorator to register routes with specific HTTP methods."""
         def decorator(handler: Callable) -> Callable:
             routes = self.pattern_routes if '{' in path and '}' in path else self.routes