Skip to content

Commit

Permalink
Minor tweaks backported from #8701 (#8717)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreamsorcerer authored Aug 16, 2024
1 parent 7cb7189 commit e0a7c0c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion aiohttp/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ def register(
def close(self) -> None:
self._callbacks.clear()

def start(self) -> Optional[asyncio.Handle]:
def start(self) -> Optional[asyncio.TimerHandle]:
timeout = self._timeout
if timeout is not None and timeout > 0:
when = self._loop.time() + timeout
Expand Down
21 changes: 13 additions & 8 deletions aiohttp/multipart.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import binascii
import json
import re
import sys
import uuid
import warnings
import zlib
Expand All @@ -10,7 +11,6 @@
from typing import (
TYPE_CHECKING,
Any,
AsyncIterator,
Deque,
Dict,
Iterator,
Expand Down Expand Up @@ -48,6 +48,13 @@
)
from .streams import StreamReader

if sys.version_info >= (3, 11):
from typing import Self
else:
from typing import TypeVar

Self = TypeVar("Self", bound="BodyPartReader")

__all__ = (
"MultipartReader",
"MultipartWriter",
Expand Down Expand Up @@ -280,8 +287,8 @@ def __init__(
self._content_eof = 0
self._cache: Dict[str, Any] = {}

def __aiter__(self) -> AsyncIterator["BodyPartReader"]:
return self # type: ignore[return-value]
def __aiter__(self: Self) -> Self:
return self

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

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

def __aiter__(
self,
) -> AsyncIterator["BodyPartReader"]:
return self # type: ignore[return-value]
def __aiter__(self: Self) -> Self:
return self

async def __anext__(
self,
Expand Down

0 comments on commit e0a7c0c

Please sign in to comment.