Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PR #8717/e0a7c0cb backport][3.10] Minor tweaks backported from #8701 #8719

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading