From 4c21e1adf0701d82a848258fe71cecfc11826448 Mon Sep 17 00:00:00 2001 From: LordGvozd Date: Sun, 20 Apr 2025 01:38:04 +0600 Subject: [PATCH 1/8] Fix PR #13850 --- stubs/gevent/METADATA.toml | 2 +- stubs/gevent/gevent/_config.pyi | 1 + stubs/gevent/gevent/lock.pyi | 1 + stubs/gevent/gevent/pywsgi.pyi | 1 + stubs/gevent/gevent/queue.pyi | 15 +++++++++------ 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/stubs/gevent/METADATA.toml b/stubs/gevent/METADATA.toml index 960f4c760e7f..456b719c6819 100644 --- a/stubs/gevent/METADATA.toml +++ b/stubs/gevent/METADATA.toml @@ -1,4 +1,4 @@ -version = "24.11.*" +version = "25.4.*" upstream_repository = "https://github.com/gevent/gevent" requires = ["types-greenlet", "types-psutil"] diff --git a/stubs/gevent/gevent/_config.pyi b/stubs/gevent/gevent/_config.pyi index 802f374fea38..757bb59d7571 100644 --- a/stubs/gevent/gevent/_config.pyi +++ b/stubs/gevent/gevent/_config.pyi @@ -72,6 +72,7 @@ class Config: ares_udp_port: _SettingDescriptor[str | int | None] ares_tcp_port: _SettingDescriptor[str | int | None] ares_servers: _SettingDescriptor[Sequence[str] | str | None] + print_blocking_reports: _SettingDescriptor[bool] class ImportableSetting(Generic[_T]): default: str | Sequence[str] diff --git a/stubs/gevent/gevent/lock.pyi b/stubs/gevent/gevent/lock.pyi index ddaf1ab85701..2daa782741fa 100644 --- a/stubs/gevent/gevent/lock.pyi +++ b/stubs/gevent/gevent/lock.pyi @@ -38,3 +38,4 @@ class RLock: def __enter__(self) -> bool: ... def release(self) -> None: ... def __exit__(self, typ: type[BaseException] | None, val: BaseException | None, tb: TracebackType | None) -> None: ... + def locked(self) -> bool: ... diff --git a/stubs/gevent/gevent/pywsgi.pyi b/stubs/gevent/gevent/pywsgi.pyi index 8c25035fd2cb..91400018eabd 100644 --- a/stubs/gevent/gevent/pywsgi.pyi +++ b/stubs/gevent/gevent/pywsgi.pyi @@ -28,6 +28,7 @@ class Input: position: int chunked_input: bool chunk_length: int + send_100_continue_enabled: bool def __init__( self, rfile: BufferedReader, content_length: int | None, socket: _GeventSocket | None = None, chunked_input: bool = False ) -> None: ... diff --git a/stubs/gevent/gevent/queue.pyi b/stubs/gevent/gevent/queue.pyi index 515aae6f5588..685f9d79a2c0 100644 --- a/stubs/gevent/gevent/queue.pyi +++ b/stubs/gevent/gevent/queue.pyi @@ -3,7 +3,7 @@ from collections import deque from collections.abc import Iterable # technically it is using _PySimpleQueue, which has the same interface as SimpleQueue -from queue import Empty as Empty, Full as Full, SimpleQueue as SimpleQueue +from queue import Empty as Empty, Full as Full from typing import Any, Generic, Literal, TypeVar, final, overload from typing_extensions import Self @@ -19,13 +19,14 @@ else: _T = TypeVar("_T") -class Queue(Generic[_T]): +class SimpleQueue(Generic[_T]): @property def hub(self) -> Hub: ... # readonly in Cython @property def queue(self) -> deque[_T]: ... # readonly in Cython maxsize: int | None is_shutdown: bool + @overload def __init__(self, maxsize: int | None = None) -> None: ... @overload @@ -42,7 +43,6 @@ class Queue(Generic[_T]): def put(self, item: _T, block: bool = True, timeout: float | None = None) -> None: ... def put_nowait(self, item: _T) -> None: ... def qsize(self) -> int: ... - def shutdown(self, immediate: bool = False) -> None: ... def __bool__(self) -> bool: ... def __iter__(self) -> Self: ... def __len__(self) -> int: ... @@ -58,10 +58,10 @@ class UnboundQueue(Queue[_T]): @overload def __init__(self, maxsize: None = None, *, items: Iterable[_T]) -> None: ... -class PriorityQueue(Queue[_T]): ... -class LifoQueue(Queue[_T]): ... +class PriorityQueue(SimpleQueue[_T]): ... +class LifoQueue(SimpleQueue[_T]): ... -class JoinableQueue(Queue[_T]): +class Queue(SimpleQueue[_T]): @property def unfinished_tasks(self) -> int: ... # readonly in Cython @overload @@ -72,6 +72,9 @@ class JoinableQueue(Queue[_T]): def __init__(self, maxsize: int | None = None, *, items: Iterable[_T], unfinished_tasks: int | None = None) -> None: ... def join(self, timeout: float | None = None) -> bool: ... def task_done(self) -> None: ... + def shutdown(self, immediate: bool = False) -> None: ... + +JoinableQueue = Queue class Channel(Generic[_T]): @property From 201d635a40f64414a37cb86961db4f2bbcaedbda Mon Sep 17 00:00:00 2001 From: LordGvozd <84399421+LordGvozd@users.noreply.github.com> Date: Sun, 20 Apr 2025 01:58:15 +0600 Subject: [PATCH 2/8] Fix queue.pyi --- stubs/gevent/gevent/queue.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/gevent/gevent/queue.pyi b/stubs/gevent/gevent/queue.pyi index 685f9d79a2c0..9574e51ffebd 100644 --- a/stubs/gevent/gevent/queue.pyi +++ b/stubs/gevent/gevent/queue.pyi @@ -50,7 +50,7 @@ class SimpleQueue(Generic[_T]): next = __next__ @final -class UnboundQueue(Queue[_T]): +class UnboundQueue(SimpleQueue[_T]): @overload def __init__(self, maxsize: None = None) -> None: ... @overload From 09a769028909b195d7edfa0f399dc32330f06729 Mon Sep 17 00:00:00 2001 From: LordGvozd <84399421+LordGvozd@users.noreply.github.com> Date: Mon, 28 Apr 2025 01:34:47 +0600 Subject: [PATCH 3/8] Add __class_getitem__ to queue.SimpleQueue and queue.Channel --- stubs/gevent/gevent/queue.pyi | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/stubs/gevent/gevent/queue.pyi b/stubs/gevent/gevent/queue.pyi index 9574e51ffebd..5aa6e71bc97f 100644 --- a/stubs/gevent/gevent/queue.pyi +++ b/stubs/gevent/gevent/queue.pyi @@ -27,6 +27,9 @@ class SimpleQueue(Generic[_T]): maxsize: int | None is_shutdown: bool + @classmethod + def __class_getitem__(cls, item: Any, /) -> types.GenericAlias: ... + @overload def __init__(self, maxsize: int | None = None) -> None: ... @overload @@ -84,6 +87,8 @@ class Channel(Generic[_T]): @property def hub(self) -> Hub: ... # readonly in Cython def __init__(self, maxsize: Literal[1] = 1) -> None: ... + @classmethod + def __class_getitem__(cls, item: Any, /) -> types.GenericAlias: ... @property def balance(self) -> int: ... def qsize(self) -> Literal[0]: ... From f2c6756593dfafd9ce5f48d461a93686acc01578 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 27 Apr 2025 19:36:18 +0000 Subject: [PATCH 4/8] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stubs/gevent/gevent/queue.pyi | 1 - 1 file changed, 1 deletion(-) diff --git a/stubs/gevent/gevent/queue.pyi b/stubs/gevent/gevent/queue.pyi index 5aa6e71bc97f..267abddb4455 100644 --- a/stubs/gevent/gevent/queue.pyi +++ b/stubs/gevent/gevent/queue.pyi @@ -29,7 +29,6 @@ class SimpleQueue(Generic[_T]): @classmethod def __class_getitem__(cls, item: Any, /) -> types.GenericAlias: ... - @overload def __init__(self, maxsize: int | None = None) -> None: ... @overload From bb7fdf7f7d3e9f9465254a801b905554d09374b5 Mon Sep 17 00:00:00 2001 From: LordGvozd <84399421+LordGvozd@users.noreply.github.com> Date: Mon, 28 Apr 2025 01:37:43 +0600 Subject: [PATCH 5/8] Fix missing import --- stubs/gevent/gevent/queue.pyi | 1 + 1 file changed, 1 insertion(+) diff --git a/stubs/gevent/gevent/queue.pyi b/stubs/gevent/gevent/queue.pyi index 267abddb4455..45cfd213e865 100644 --- a/stubs/gevent/gevent/queue.pyi +++ b/stubs/gevent/gevent/queue.pyi @@ -1,6 +1,7 @@ import sys from collections import deque from collections.abc import Iterable +import types # technically it is using _PySimpleQueue, which has the same interface as SimpleQueue from queue import Empty as Empty, Full as Full From 8008b64c393d095b3dfbe070a5f4c798e1547972 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 27 Apr 2025 19:40:02 +0000 Subject: [PATCH 6/8] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stubs/gevent/gevent/queue.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/gevent/gevent/queue.pyi b/stubs/gevent/gevent/queue.pyi index 45cfd213e865..7c97ea88a1cf 100644 --- a/stubs/gevent/gevent/queue.pyi +++ b/stubs/gevent/gevent/queue.pyi @@ -1,7 +1,7 @@ import sys +import types from collections import deque from collections.abc import Iterable -import types # technically it is using _PySimpleQueue, which has the same interface as SimpleQueue from queue import Empty as Empty, Full as Full From 94f8d28ef43c3374f4ba5e6272e237297a089cb4 Mon Sep 17 00:00:00 2001 From: LordGvozd Date: Tue, 29 Apr 2025 00:50:03 +0600 Subject: [PATCH 7/8] Make the c-ares resolver build on Windows stubs added --- stubs/gevent/gevent/ares.pyi | 3 +- stubs/gevent/gevent/resolver/ares.pyi | 75 ++++++++++----------- stubs/gevent/gevent/resolver/cares.pyi | 91 +++++++++++++------------- stubs/gevent/gevent/resolver_ares.pyi | 5 +- 4 files changed, 82 insertions(+), 92 deletions(-) diff --git a/stubs/gevent/gevent/ares.pyi b/stubs/gevent/gevent/ares.pyi index 8fa5509e5fa6..12707915d68b 100644 --- a/stubs/gevent/gevent/ares.pyi +++ b/stubs/gevent/gevent/ares.pyi @@ -2,5 +2,4 @@ import sys from gevent.resolver.cares import * -if sys.platform != "win32": - __all__ = ["channel"] +__all__ = ["channel"] diff --git a/stubs/gevent/gevent/resolver/ares.pyi b/stubs/gevent/gevent/resolver/ares.pyi index a20e6b99a1e3..29c5ea0cb843 100644 --- a/stubs/gevent/gevent/resolver/ares.pyi +++ b/stubs/gevent/gevent/resolver/ares.pyi @@ -1,43 +1,40 @@ -import sys +from collections.abc import Sequence +from typing import TypedDict -if sys.platform != "win32": - from collections.abc import Sequence - from typing import TypedDict +from gevent._types import _Watcher +from gevent.hub import Hub +from gevent.resolver import AbstractResolver +from gevent.resolver.cares import channel - from gevent._types import _Watcher - from gevent.hub import Hub - from gevent.resolver import AbstractResolver - from gevent.resolver.cares import channel +class _ChannelArgs(TypedDict): + flags: str | int | None + timeout: str | float | None + tries: str | int | None + ndots: str | int | None + udp_port: str | int | None + tcp_port: str | int | None + servers: Sequence[str] | str | None - class _ChannelArgs(TypedDict): - flags: str | int | None - timeout: str | float | None - tries: str | int | None - ndots: str | int | None - udp_port: str | int | None - tcp_port: str | int | None - servers: Sequence[str] | str | None +class Resolver(AbstractResolver): + cares_class: type[channel] + hub: Hub + cares: channel + pid: int + params: _ChannelArgs + fork_watcher: _Watcher + def __init__( + self, + hub: Hub | None = None, + use_environ: bool = True, + *, + flags: str | int | None = None, + timeout: str | float | None = None, + tries: str | int | None = None, + ndots: str | int | None = None, + udp_port: str | int | None = None, + tcp_port: str | int | None = None, + servers: Sequence[str] | str | None = None, + ) -> None: ... + def __del__(self) -> None: ... - class Resolver(AbstractResolver): - cares_class: type[channel] - hub: Hub - cares: channel - pid: int - params: _ChannelArgs - fork_watcher: _Watcher - def __init__( - self, - hub: Hub | None = None, - use_environ: bool = True, - *, - flags: str | int | None = None, - timeout: str | float | None = None, - tries: str | int | None = None, - ndots: str | int | None = None, - udp_port: str | int | None = None, - tcp_port: str | int | None = None, - servers: Sequence[str] | str | None = None, - ) -> None: ... - def __del__(self) -> None: ... - - __all__ = ["Resolver"] +__all__ = ["Resolver"] diff --git a/stubs/gevent/gevent/resolver/cares.pyi b/stubs/gevent/gevent/resolver/cares.pyi index b8f3546bf97e..caa0d36b99e8 100644 --- a/stubs/gevent/gevent/resolver/cares.pyi +++ b/stubs/gevent/gevent/resolver/cares.pyi @@ -1,53 +1,50 @@ -import sys +from collections.abc import Callable, Sequence +from typing import Any, Generic, TypeVar +from typing_extensions import Self -if sys.platform != "win32": - from collections.abc import Callable, Sequence - from typing import Any, Generic, TypeVar - from typing_extensions import Self +from gevent._types import _AddrinfoResult, _Loop, _NameinfoResult, _SockAddr - from gevent._types import _AddrinfoResult, _Loop, _NameinfoResult, _SockAddr +_T = TypeVar("_T") - _T = TypeVar("_T") +class Result(Generic[_T]): + exception: BaseException | None + value: _T | None + def __init__(self, value: _T | None = None, exception: BaseException | None = None) -> None: ... + def get(self) -> Any | None: ... + def successful(self) -> bool: ... - class Result(Generic[_T]): - exception: BaseException | None - value: _T | None - def __init__(self, value: _T | None = None, exception: BaseException | None = None) -> None: ... - def get(self) -> Any | None: ... - def successful(self) -> bool: ... +class ares_host_result(tuple[str, list[str], list[str]]): + family: int + def __new__(cls, family: int, hostname: str, aliases: list[str], addr_list: list[str], /) -> Self: ... - class ares_host_result(tuple[str, list[str], list[str]]): - family: int - def __new__(cls, family: int, hostname: str, aliases: list[str], addr_list: list[str], /) -> Self: ... +class channel: + @property + def loop(self) -> _Loop: ... + def __init__( + self, + loop: _Loop, + flags: str | int | None = None, + timeout: str | float | None = None, + tries: str | int | None = None, + ndots: str | int | None = None, + udp_port: str | int | None = None, + tcp_port: str | int | None = None, + servers: Sequence[str] | str | None = None, + ) -> None: ... + def destroy(self) -> None: ... + def getaddrinfo( + self, + callback: Callable[[Result[_AddrinfoResult]], object], + name: str, + service: str | None, + family: int = 0, + type: int = 0, + proto: int = 0, + flags: int = 0, + ) -> None: ... + def gethostbyaddr(self, callback: Callable[[Result[ares_host_result]], object], addr: str) -> Any: ... + def gethostbyname(self, callback: Callable[[Result[ares_host_result]], object], name: str, family: int = ...) -> None: ... + def getnameinfo(self, callback: Callable[[Result[_NameinfoResult]], object], sockaddr: _SockAddr, flags: int) -> None: ... + def set_servers(self, servers: Sequence[str] | str | None = None) -> None: ... - class channel: - @property - def loop(self) -> _Loop: ... - def __init__( - self, - loop: _Loop, - flags: str | int | None = None, - timeout: str | float | None = None, - tries: str | int | None = None, - ndots: str | int | None = None, - udp_port: str | int | None = None, - tcp_port: str | int | None = None, - servers: Sequence[str] | str | None = None, - ) -> None: ... - def destroy(self) -> None: ... - def getaddrinfo( - self, - callback: Callable[[Result[_AddrinfoResult]], object], - name: str, - service: str | None, - family: int = 0, - type: int = 0, - proto: int = 0, - flags: int = 0, - ) -> None: ... - def gethostbyaddr(self, callback: Callable[[Result[ares_host_result]], object], addr: str) -> Any: ... - def gethostbyname(self, callback: Callable[[Result[ares_host_result]], object], name: str, family: int = ...) -> None: ... - def getnameinfo(self, callback: Callable[[Result[_NameinfoResult]], object], sockaddr: _SockAddr, flags: int) -> None: ... - def set_servers(self, servers: Sequence[str] | str | None = None) -> None: ... - - __all__ = ["channel"] +__all__ = ["channel"] diff --git a/stubs/gevent/gevent/resolver_ares.pyi b/stubs/gevent/gevent/resolver_ares.pyi index 5eb75234139c..4d1fbbaae20e 100644 --- a/stubs/gevent/gevent/resolver_ares.pyi +++ b/stubs/gevent/gevent/resolver_ares.pyi @@ -1,6 +1,3 @@ -import sys - from gevent.resolver.ares import * -if sys.platform != "win32": - __all__ = ["Resolver"] +__all__ = ["Resolver"] From fbad4aa16a3fa29c48a7f5df6ee65e94bc50e78b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 28 Apr 2025 18:50:24 +0000 Subject: [PATCH 8/8] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stubs/gevent/gevent/ares.pyi | 2 -- 1 file changed, 2 deletions(-) diff --git a/stubs/gevent/gevent/ares.pyi b/stubs/gevent/gevent/ares.pyi index 12707915d68b..6104efb65acc 100644 --- a/stubs/gevent/gevent/ares.pyi +++ b/stubs/gevent/gevent/ares.pyi @@ -1,5 +1,3 @@ -import sys - from gevent.resolver.cares import * __all__ = ["channel"]