Skip to content

Commit

Permalink
Bump gevent to 24.10.* (#12779)
Browse files Browse the repository at this point in the history
  • Loading branch information
Daverball authored Oct 11, 2024
1 parent 03fe755 commit 2d31815
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 6 deletions.
4 changes: 4 additions & 0 deletions stubs/gevent/@tests/stubtest_allowlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -221,3 +221,7 @@ gevent._types
# useful way to use it as a keyword argument; we mark it positional-only.
gevent.pool.GroupMappingMixin.imap
gevent.pool.GroupMappingMixin.imap_unordered

# Importing gevent.monkey.__main__ leads to issues in stubtest, since gevent will
# try to monkeypatch stubtest
gevent.monkey.__main__
2 changes: 1 addition & 1 deletion stubs/gevent/METADATA.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "24.2.*"
version = "24.10.*"
upstream_repository = "https://github.com/gevent/gevent"
requires = ["types-greenlet", "types-psutil"]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from types import ModuleType
from typing import Any

from gevent.monkey.api import get_original as get_original, patch_module as patch_module

class MonkeyPatchWarning(RuntimeWarning): ...

def is_module_patched(mod_name: str) -> bool: ...
def is_object_patched(mod_name: str, item_name: str) -> bool: ...
def get_original(mod_name: str, item_name: str) -> Any: ...
def patch_module(target_module: ModuleType, source_module: ModuleType, items: list[str] | None = None) -> bool: ...
def patch_os() -> None: ...
def patch_queue() -> None: ...
def patch_time() -> None: ...
Expand Down
7 changes: 7 additions & 0 deletions stubs/gevent/gevent/monkey/api.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from types import ModuleType
from typing import Any

def get_original(mod_name: str, item_name: str) -> Any: ...
def patch_item(module: ModuleType, attr: str, newitem: object) -> None: ...
def remove_item(module: ModuleType, attr: str) -> None: ...
def patch_module(target_module: ModuleType, source_module: ModuleType, items: list[str] | None = None) -> bool: ...
10 changes: 9 additions & 1 deletion stubs/gevent/gevent/queue.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import sys
from collections import deque
from collections.abc import Iterable

Expand All @@ -9,7 +10,12 @@ from typing_extensions import Self
from gevent._waiter import Waiter
from gevent.hub import Hub

__all__ = ["Queue", "PriorityQueue", "LifoQueue", "SimpleQueue", "JoinableQueue", "Channel", "Empty", "Full"]
__all__ = ["Queue", "PriorityQueue", "LifoQueue", "SimpleQueue", "JoinableQueue", "Channel", "Empty", "Full", "ShutDown"]

if sys.version_info >= (3, 13):
from queue import ShutDown as ShutDown
else:
class ShutDown(Exception): ...

_T = TypeVar("_T")

Expand All @@ -19,6 +25,7 @@ class Queue(Generic[_T]):
@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
Expand All @@ -35,6 +42,7 @@ 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: ...
Expand Down
7 changes: 6 additions & 1 deletion stubs/gevent/gevent/timeout.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from collections.abc import Callable
from types import TracebackType
from typing import Any, Literal, TypeVar, overload
from typing import Any, Literal, Protocol, TypeVar, overload
from typing_extensions import ParamSpec, Self

from gevent._types import _TimerWatcher
Expand All @@ -11,6 +11,10 @@ _T2 = TypeVar("_T2")
_TimeoutT = TypeVar("_TimeoutT", bound=Timeout)
_P = ParamSpec("_P")

class _HasSeconds(Protocol):
@property
def seconds(self) -> float | int: ...

class Timeout(BaseException):
seconds: float | None
exception: type[BaseException] | BaseException | None
Expand Down Expand Up @@ -39,6 +43,7 @@ class Timeout(BaseException):
def __exit__(
self, typ: type[BaseException] | None, value: BaseException | None, tb: TracebackType | None
) -> Literal[True] | None: ...
def __lt__(self, other: _HasSeconds | float) -> bool: ...

# when timeout_value is provided we unfortunately get no type checking on *args, **kwargs, because
# ParamSpec does not allow mixing in additional keyword arguments
Expand Down

0 comments on commit 2d31815

Please sign in to comment.