Skip to content

Commit 5ef8cba

Browse files
[PR #8717/e0a7c0cb backport][3.10] Minor tweaks backported from #8701 (#8719)
**This is a backport of PR #8717 as merged into 3.11 (e0a7c0c).** Co-authored-by: Sam Bull <[email protected]>
1 parent 677f6af commit 5ef8cba

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

aiohttp/helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ def register(
629629
def close(self) -> None:
630630
self._callbacks.clear()
631631

632-
def start(self) -> Optional[asyncio.Handle]:
632+
def start(self) -> Optional[asyncio.TimerHandle]:
633633
timeout = self._timeout
634634
if timeout is not None and timeout > 0:
635635
when = self._loop.time() + timeout

aiohttp/multipart.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import binascii
33
import json
44
import re
5+
import sys
56
import uuid
67
import warnings
78
import zlib
@@ -10,7 +11,6 @@
1011
from typing import (
1112
TYPE_CHECKING,
1213
Any,
13-
AsyncIterator,
1414
Deque,
1515
Dict,
1616
Iterator,
@@ -48,6 +48,13 @@
4848
)
4949
from .streams import StreamReader
5050

51+
if sys.version_info >= (3, 11):
52+
from typing import Self
53+
else:
54+
from typing import TypeVar
55+
56+
Self = TypeVar("Self", bound="BodyPartReader")
57+
5158
__all__ = (
5259
"MultipartReader",
5360
"MultipartWriter",
@@ -280,8 +287,8 @@ def __init__(
280287
self._content_eof = 0
281288
self._cache: Dict[str, Any] = {}
282289

283-
def __aiter__(self) -> AsyncIterator["BodyPartReader"]:
284-
return self # type: ignore[return-value]
290+
def __aiter__(self: Self) -> Self:
291+
return self
285292

286293
async def __anext__(self) -> bytes:
287294
part = await self.next()
@@ -581,7 +588,7 @@ class MultipartReader:
581588
response_wrapper_cls = MultipartResponseWrapper
582589
#: Multipart reader class, used to handle multipart/* body parts.
583590
#: None points to type(self)
584-
multipart_reader_cls = None
591+
multipart_reader_cls: Optional[Type["MultipartReader"]] = None
585592
#: Body part reader class for non multipart/* content types.
586593
part_reader_cls = BodyPartReader
587594

@@ -602,10 +609,8 @@ def __init__(self, headers: Mapping[str, str], content: StreamReader) -> None:
602609
self._at_bof = True
603610
self._unread: List[bytes] = []
604611

605-
def __aiter__(
606-
self,
607-
) -> AsyncIterator["BodyPartReader"]:
608-
return self # type: ignore[return-value]
612+
def __aiter__(self: Self) -> Self:
613+
return self
609614

610615
async def __anext__(
611616
self,

0 commit comments

Comments
 (0)