diff options
| author | robot-piglet <[email protected]> | 2026-06-07 12:45:03 +0300 |
|---|---|---|
| committer | robot-piglet <[email protected]> | 2026-06-07 13:07:12 +0300 |
| commit | 62fc40807071963a5e159369fbb27023f135aadb (patch) | |
| tree | 695782546add6b012373d114683adb3bfff83c3a /contrib/python | |
| parent | 7e7a9bdcd5ab83a88fd31c74e70b2347a54ac275 (diff) | |
Intermediate changes
commit_hash:d5cb132b1cc8a7c199d30cecf74c056e04a86377
Diffstat (limited to 'contrib/python')
7 files changed, 53 insertions, 69 deletions
diff --git a/contrib/python/aiohappyeyeballs/.dist-info/METADATA b/contrib/python/aiohappyeyeballs/.dist-info/METADATA index c632040d66b..c8a61b093c8 100644 --- a/contrib/python/aiohappyeyeballs/.dist-info/METADATA +++ b/contrib/python/aiohappyeyeballs/.dist-info/METADATA @@ -1,18 +1,18 @@ -Metadata-Version: 2.3 +Metadata-Version: 2.4 Name: aiohappyeyeballs -Version: 2.6.1 +Version: 2.6.2 Summary: Happy Eyeballs for asyncio License: PSF-2.0 +License-File: LICENSE Author: J. Nick Koston Author-email: [email protected] -Requires-Python: >=3.9 +Requires-Python: >=3.10 Classifier: Development Status :: 5 - Production/Stable Classifier: Intended Audience :: Developers Classifier: Natural Language :: English Classifier: Operating System :: OS Independent Classifier: Topic :: Software Development :: Libraries Classifier: Programming Language :: Python :: 3 -Classifier: Programming Language :: Python :: 3.9 Classifier: Programming Language :: Python :: 3.10 Classifier: Programming Language :: Python :: 3.11 Classifier: Programming Language :: Python :: 3.12 diff --git a/contrib/python/aiohappyeyeballs/aiohappyeyeballs/__init__.py b/contrib/python/aiohappyeyeballs/aiohappyeyeballs/__init__.py index 71c689cc83f..ad6bfb5a073 100644 --- a/contrib/python/aiohappyeyeballs/aiohappyeyeballs/__init__.py +++ b/contrib/python/aiohappyeyeballs/aiohappyeyeballs/__init__.py @@ -1,4 +1,4 @@ -__version__ = "2.6.1" +__version__ = "2.6.2" from .impl import start_connection from .types import AddrInfoType, SocketFactoryType diff --git a/contrib/python/aiohappyeyeballs/aiohappyeyeballs/_staggered.py b/contrib/python/aiohappyeyeballs/aiohappyeyeballs/_staggered.py index 9a4ba7205ed..bb745dc0a81 100644 --- a/contrib/python/aiohappyeyeballs/aiohappyeyeballs/_staggered.py +++ b/contrib/python/aiohappyeyeballs/aiohappyeyeballs/_staggered.py @@ -1,20 +1,10 @@ import asyncio import contextlib - -# PY3.9: Import Callable from typing until we drop Python 3.9 support -# https://github.com/python/cpython/issues/87131 +from collections.abc import Awaitable, Callable, Iterable from typing import ( TYPE_CHECKING, Any, - Awaitable, - Callable, - Iterable, - List, - Optional, - Set, - Tuple, TypeVar, - Union, ) _T = TypeVar("_T") @@ -51,10 +41,10 @@ async def _wait_one( async def staggered_race( coro_fns: Iterable[Callable[[], Awaitable[_T]]], - delay: Optional[float], + delay: float | None, *, - loop: Optional[asyncio.AbstractEventLoop] = None, -) -> Tuple[Optional[_T], Optional[int], List[Optional[BaseException]]]: + loop: asyncio.AbstractEventLoop | None = None, +) -> tuple[_T | None, int | None, list[BaseException | None]]: """ Run coroutines with staggered start times and take the first to finish. @@ -109,14 +99,14 @@ async def staggered_race( """ loop = loop or asyncio.get_running_loop() - exceptions: List[Optional[BaseException]] = [] - tasks: Set[asyncio.Task[Optional[Tuple[_T, int]]]] = set() + exceptions: list[BaseException | None] = [] + tasks: set[asyncio.Task[tuple[_T, int] | None]] = set() async def run_one_coro( coro_fn: Callable[[], Awaitable[_T]], this_index: int, start_next: "asyncio.Future[None]", - ) -> Optional[Tuple[_T, int]]: + ) -> tuple[_T, int] | None: """ Run a single coroutine. @@ -139,10 +129,10 @@ async def staggered_race( return result, this_index - start_next_timer: Optional[asyncio.TimerHandle] = None - start_next: Optional[asyncio.Future[None]] - task: asyncio.Task[Optional[Tuple[_T, int]]] - done: Union[asyncio.Future[None], asyncio.Task[Optional[Tuple[_T, int]]]] + start_next_timer: asyncio.TimerHandle | None = None + start_next: asyncio.Future[None] | None + task: asyncio.Task[tuple[_T, int] | None] + done: asyncio.Future[None] | asyncio.Task[tuple[_T, int] | None] coro_iter = iter(coro_fns) this_index = -1 try: diff --git a/contrib/python/aiohappyeyeballs/aiohappyeyeballs/impl.py b/contrib/python/aiohappyeyeballs/aiohappyeyeballs/impl.py index 8f3919a0c95..4112ab4d1b2 100644 --- a/contrib/python/aiohappyeyeballs/aiohappyeyeballs/impl.py +++ b/contrib/python/aiohappyeyeballs/aiohappyeyeballs/impl.py @@ -6,7 +6,7 @@ import contextlib import functools import itertools import socket -from typing import List, Optional, Sequence, Set, Union +from collections.abc import Sequence from . import _staggered from .types import AddrInfoType, SocketFactoryType @@ -15,11 +15,11 @@ from .types import AddrInfoType, SocketFactoryType async def start_connection( addr_infos: Sequence[AddrInfoType], *, - local_addr_infos: Optional[Sequence[AddrInfoType]] = None, - happy_eyeballs_delay: Optional[float] = None, - interleave: Optional[int] = None, - loop: Optional[asyncio.AbstractEventLoop] = None, - socket_factory: Optional[SocketFactoryType] = None, + local_addr_infos: Sequence[AddrInfoType] | None = None, + happy_eyeballs_delay: float | None = None, + interleave: int | None = None, + loop: asyncio.AbstractEventLoop | None = None, + socket_factory: SocketFactoryType | None = None, ) -> socket.socket: """ Connect to a TCP server. @@ -51,8 +51,10 @@ async def start_connection( transport, protocol = await loop.create_connection( MyProtocol, sock=socket, ...) """ - if not (current_loop := loop): - current_loop = asyncio.get_running_loop() + if not addr_infos: + raise ValueError("addr_infos must not be empty") + + current_loop = loop or asyncio.get_running_loop() single_addr_info = len(addr_infos) == 1 @@ -63,9 +65,9 @@ async def start_connection( if interleave and not single_addr_info: addr_infos = _interleave_addrinfos(addr_infos, interleave) - sock: Optional[socket.socket] = None + sock: socket.socket | None = None # uvloop can raise RuntimeError instead of OSError - exceptions: List[List[Union[OSError, RuntimeError]]] = [] + exceptions: list[list[OSError | RuntimeError]] = [] if happy_eyeballs_delay is None or single_addr_info: # not using happy eyeballs for addrinfo in addr_infos: @@ -82,7 +84,7 @@ async def start_connection( except (RuntimeError, OSError): continue else: # using happy eyeballs - open_sockets: Set[socket.socket] = set() + open_sockets: set[socket.socket] = set() try: sock, _, _ = await _staggered.staggered_race( ( @@ -156,11 +158,11 @@ async def start_connection( async def _connect_sock( loop: asyncio.AbstractEventLoop, - exceptions: List[List[Union[OSError, RuntimeError]]], + exceptions: list[list[OSError | RuntimeError]], addr_info: AddrInfoType, - local_addr_infos: Optional[Sequence[AddrInfoType]] = None, - open_sockets: Optional[Set[socket.socket]] = None, - socket_factory: Optional[SocketFactoryType] = None, + local_addr_infos: Sequence[AddrInfoType] | None = None, + open_sockets: set[socket.socket] | None = None, + socket_factory: SocketFactoryType | None = None, ) -> socket.socket: """ Create, bind and connect one socket. @@ -172,7 +174,7 @@ async def _connect_sock( of all staggered tasks in the result there are runner up sockets aka multiple winners. """ - my_exceptions: List[Union[OSError, RuntimeError]] = [] + my_exceptions: list[OSError | RuntimeError] = [] exceptions.append(my_exceptions) family, type_, proto, _, address = addr_info sock = None @@ -234,10 +236,10 @@ async def _connect_sock( def _interleave_addrinfos( addrinfos: Sequence[AddrInfoType], first_address_family_count: int = 1 -) -> List[AddrInfoType]: +) -> list[AddrInfoType]: """Interleave list of addrinfo tuples by family.""" # Group addresses by family - addrinfos_by_family: collections.OrderedDict[int, List[AddrInfoType]] = ( + addrinfos_by_family: collections.OrderedDict[int, list[AddrInfoType]] = ( collections.OrderedDict() ) for addr in addrinfos: @@ -247,7 +249,7 @@ def _interleave_addrinfos( addrinfos_by_family[family].append(addr) addrinfos_lists = list(addrinfos_by_family.values()) - reordered: List[AddrInfoType] = [] + reordered: list[AddrInfoType] = [] if first_address_family_count > 1: reordered.extend(addrinfos_lists[0][: first_address_family_count - 1]) del addrinfos_lists[0][: first_address_family_count - 1] diff --git a/contrib/python/aiohappyeyeballs/aiohappyeyeballs/types.py b/contrib/python/aiohappyeyeballs/aiohappyeyeballs/types.py index e8c75074e7a..80f09afdd6d 100644 --- a/contrib/python/aiohappyeyeballs/aiohappyeyeballs/types.py +++ b/contrib/python/aiohappyeyeballs/aiohappyeyeballs/types.py @@ -1,17 +1,14 @@ """Types for aiohappyeyeballs.""" import socket +from collections.abc import Callable -# PY3.9: Import Callable from typing until we drop Python 3.9 support -# https://github.com/python/cpython/issues/87131 -from typing import Callable, Tuple, Union - -AddrInfoType = Tuple[ - Union[int, socket.AddressFamily], - Union[int, socket.SocketKind], +AddrInfoType = tuple[ + int | socket.AddressFamily, + int | socket.SocketKind, int, str, - Tuple, # type: ignore[type-arg] + tuple, # type: ignore[type-arg] ] SocketFactoryType = Callable[[AddrInfoType], socket.socket] diff --git a/contrib/python/aiohappyeyeballs/aiohappyeyeballs/utils.py b/contrib/python/aiohappyeyeballs/aiohappyeyeballs/utils.py index ea29adb9be9..5969691ce36 100644 --- a/contrib/python/aiohappyeyeballs/aiohappyeyeballs/utils.py +++ b/contrib/python/aiohappyeyeballs/aiohappyeyeballs/utils.py @@ -2,16 +2,13 @@ import ipaddress import socket -from typing import Dict, List, Optional, Tuple, Union from .types import AddrInfoType def addr_to_addr_infos( - addr: Optional[ - Union[Tuple[str, int, int, int], Tuple[str, int, int], Tuple[str, int]] - ], -) -> Optional[List[AddrInfoType]]: + addr: tuple[str, int, int, int] | tuple[str, int, int] | tuple[str, int] | None, +) -> list[AddrInfoType] | None: """Convert an address tuple to a list of addr_info tuples.""" if addr is None: return None @@ -35,7 +32,7 @@ def addr_to_addr_infos( def pop_addr_infos_interleave( - addr_infos: List[AddrInfoType], interleave: Optional[int] = None + addr_infos: list[AddrInfoType], interleave: int | None = None ) -> None: """ Pop addr_info from the list of addr_infos by family up to interleave times. @@ -43,10 +40,10 @@ def pop_addr_infos_interleave( The interleave parameter is used to know how many addr_infos for each family should be popped of the top of the list. """ - seen: Dict[int, int] = {} + seen: dict[int, int] = {} if interleave is None: interleave = 1 - to_remove: List[AddrInfoType] = [] + to_remove: list[AddrInfoType] = [] for addr_info in addr_infos: family = addr_info[0] if family not in seen: @@ -59,17 +56,15 @@ def pop_addr_infos_interleave( def _addr_tuple_to_ip_address( - addr: Union[Tuple[str, int], Tuple[str, int, int, int]], -) -> Union[ - Tuple[ipaddress.IPv4Address, int], Tuple[ipaddress.IPv6Address, int, int, int] -]: + addr: tuple[str, int] | tuple[str, int, int, int], +) -> tuple[ipaddress.IPv4Address, int] | tuple[ipaddress.IPv6Address, int, int, int]: """Convert an address tuple to an IPv4Address.""" return (ipaddress.ip_address(addr[0]), *addr[1:]) def remove_addr_infos( - addr_infos: List[AddrInfoType], - addr: Union[Tuple[str, int], Tuple[str, int, int, int]], + addr_infos: list[AddrInfoType], + addr: tuple[str, int] | tuple[str, int, int, int], ) -> None: """ Remove an address from the list of addr_infos. @@ -77,7 +72,7 @@ def remove_addr_infos( The addr value is typically the return value of sock.getpeername(). """ - bad_addrs_infos: List[AddrInfoType] = [] + bad_addrs_infos: list[AddrInfoType] = [] for addr_info in addr_infos: if addr_info[-1] == addr: bad_addrs_infos.append(addr_info) diff --git a/contrib/python/aiohappyeyeballs/ya.make b/contrib/python/aiohappyeyeballs/ya.make index 55dc6c9940e..90e2cbfc73d 100644 --- a/contrib/python/aiohappyeyeballs/ya.make +++ b/contrib/python/aiohappyeyeballs/ya.make @@ -2,7 +2,7 @@ PY3_LIBRARY() -VERSION(2.6.1) +VERSION(2.6.2) LICENSE(Python-2.0) |
