Skip to content

Commit 680d4f5

Browse files
committed
Add overloads
1 parent db1b912 commit 680d4f5

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

aiohttp/client.py

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
TypeVar,
3333
Union,
3434
final,
35+
TypedDict,
36+
overload,
3537
)
3638

3739
from multidict import CIMultiDict, MultiDict, MultiDictProxy, istr
@@ -150,6 +152,34 @@
150152
SSLContext = None
151153

152154

155+
class _RequestOptions(TypedDict, total=False):
156+
params: Union[Mapping[str, str], None]
157+
data: Any
158+
json: Any
159+
cookies: Union[LooseCookies, None]
160+
headers: Union[LooseHeaders, None]
161+
skip_auto_headers: Union[Iterable[str], None]
162+
auth: Union[BasicAuth, None]
163+
allow_redirects: bool
164+
max_redirects: int
165+
compress: Union[str, None]
166+
chunked: Union[bool, None]
167+
expect100: bool
168+
raise_for_status: Union[None, bool, Callable[[ClientResponse], Awaitable[None]]]
169+
read_until_eof: bool
170+
proxy: Union[StrOrURL, None]
171+
proxy_auth: Union[BasicAuth, None]
172+
timeout: "Union[ClientTimeout, _SENTINEL, None]"
173+
ssl: Union[SSLContext, bool, Fingerprint]
174+
server_hostname: Union[str, None]
175+
proxy_headers: Union[LooseHeaders, None]
176+
trace_request_ctx: Union[SimpleNamespace, None]
177+
read_bufsize: Union[int, None]
178+
auto_decompress: Union[bool, None]
179+
max_line_size: Union[int, None]
180+
max_field_size: Union[int, None]
181+
182+
153183
@dataclasses.dataclass(frozen=True)
154184
class ClientTimeout:
155185
total: Optional[float] = None
@@ -187,6 +217,44 @@ class ClientTimeout:
187217
class ClientSession:
188218
"""First-class interface for making HTTP requests."""
189219

220+
if sys.version_info >= (3, 11):
221+
from typing import Unpack
222+
223+
@overload
224+
def get(
225+
self,
226+
url: StrOrURL,
227+
**kwargs: Unpack["_RequestOptions"],
228+
) -> "_RequestContextManager": ...
229+
230+
@overload
231+
def put(
232+
self,
233+
url: StrOrURL,
234+
**kwargs: Unpack["_RequestOptions"],
235+
) -> "_RequestContextManager": ...
236+
237+
@overload
238+
def post(
239+
self,
240+
url: StrOrURL,
241+
**kwargs: Unpack["_RequestOptions"],
242+
) -> "_RequestContextManager": ...
243+
244+
@overload
245+
def delete(
246+
self,
247+
url: StrOrURL,
248+
**kwargs: Unpack["_RequestOptions"],
249+
) -> "_RequestContextManager": ...
250+
251+
@overload
252+
def head(
253+
self,
254+
url: StrOrURL,
255+
**kwargs: Unpack["_RequestOptions"],
256+
) -> "_RequestContextManager": ...
257+
190258
__slots__ = (
191259
"_base_url",
192260
"_source_traceback",

0 commit comments

Comments
 (0)