Skip to content

Commit 99794a3

Browse files
committed
Type the arguments passed in util.http_request
1 parent ff38a9a commit 99794a3

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

tptools/tpsrv/util.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import json
33
import logging
44
from dataclasses import dataclass
5-
from typing import Annotated, Any, Callable, cast
5+
from typing import Annotated, Any, Callable, TypedDict, cast
66

77
import click
88
from click_async_plugins import CliContext as _CliContext
@@ -103,6 +103,13 @@ class PostData[T: BaseModel](BaseModel):
103103
data: T
104104

105105

106+
class RequestArgs(TypedDict):
107+
method: str
108+
url: URL
109+
content: str | None
110+
headers: dict[str, str]
111+
112+
106113
async def http_request(
107114
method: str,
108115
url: URL,
@@ -112,7 +119,7 @@ async def http_request(
112119
sleep: float = 1,
113120
to_json_fn: Callable[..., str] | None = None,
114121
) -> dict[str, Any] | None:
115-
request_args = {"method": method, "url": url, "content": None, "headers": {}}
122+
request_args = RequestArgs(method=method, url=url, content=None, headers={})
116123
if data is not None:
117124
to_json_fn = to_json_fn or (
118125
type(data).model_dump_json if data is not None else json.dumps

0 commit comments

Comments
 (0)