Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 3 additions & 0 deletions stubs/pycurl/@tests/stubtest_allowlist.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# The runtime computes __all__ dynamically (dir(_pycurl) + AsyncCurlMulti), so
# its exact contents depend on the libcurl feature set pycurl was built against.
pycurl.__all__
2 changes: 1 addition & 1 deletion stubs/pycurl/METADATA.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "7.46.0"
version = "7.47.0"
upstream-repository = "https://github.com/pycurl/pycurl"

[tool.stubtest]
Expand Down
2 changes: 2 additions & 0 deletions stubs/pycurl/pycurl/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from pycurl._pycurl import *
from pycurl.async_multi import AsyncCurlMulti as AsyncCurlMulti
21 changes: 19 additions & 2 deletions stubs/pycurl/pycurl.pyi → stubs/pycurl/pycurl/_pycurl.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Stub for the pycurl C extension (imported at runtime as `pycurl._pycurl`).
import sys
from _typeshed import ReadableBuffer, WriteableBuffer
from collections.abc import Callable
Expand All @@ -13,6 +14,10 @@ def global_cleanup() -> None: ...
def version_info(
stamp: int = ...,
) -> tuple[int, str, int, str, int, str, int, str, tuple[str, ...], str | None, int, str | None]: ...
def easy_strerror(errornum: int) -> str: ...
def multi_strerror(errornum: int) -> str: ...
def share_strerror(errornum: int) -> str: ...
def url_strerror(errornum: int) -> str: ...

class error(Exception):
# libcurl protocol errors raise (code, message); arg-parse errors raise (message,).
Expand All @@ -31,7 +36,7 @@ class HstsEntry(NamedTuple):
include_subdomains: bool

class HstsIndex(NamedTuple):
index: int # type: ignore[assignment]
idx: int
total: int

class KhKey(NamedTuple):
Expand All @@ -48,10 +53,11 @@ class CurlSockAddr(NamedTuple):
class Curl:
USERPWD: int
def close(self) -> None: ...
@property
def closed(self) -> bool: ...
# For `setopt()` the exact `value` type depends on the passed `option`; `None` used to unassign:
# http://pycurl.io/docs/latest/curlobject.html#pycurl.Curl.setopt
def setopt(self, option: int, value: Any | None) -> None: ...
def setopt(self, option: int, value: Any | None, *, use_memoryview: bool = False) -> None: ...
def setopt_string(self, option: int, value: str) -> None: ...
def perform(self) -> None: ...
def perform_rb(self) -> bytes: ...
Expand Down Expand Up @@ -89,6 +95,7 @@ class Curl:
@disjoint_base
class CurlMulti:
def close(self) -> None: ...
@property
def closed(self) -> bool: ...
def add_handle(self, obj: Curl) -> None: ...
def remove_handle(self, obj: Curl) -> None: ...
Expand All @@ -102,6 +109,7 @@ class CurlMulti:
| tuple[str | bytes, ...]
| Callable[[int], Literal[-1, 0] | None]
| Callable[[int, int, Self, Any | None], Literal[-1, 0] | None] # See `assign()` below for `Any | None`
| Callable[[int, Curl | None], object] # `M_NOTIFYFUNCTION` (notify) callback; return value ignored
| None
),
) -> None: ...
Expand All @@ -113,6 +121,8 @@ class CurlMulti:
# `assign()` accepts literally any object, it's only passed to callbacks and not processed; `None` used to unassign
def assign(self, sockfd: int, obj: Any | None, /) -> None: ...
def unassign(self, sock_fd: int, /) -> None: ...
def notify_enable(self, *notifications: int) -> None: ...
def notify_disable(self, *notifications: int) -> None: ...
def socket_all(self) -> tuple[int, int]: ...
def timeout(self) -> int: ...
def __contains__(self, key: Curl, /) -> bool: ...
Expand All @@ -124,10 +134,13 @@ class CurlMulti:
@disjoint_base
class CurlShare:
def close(self) -> None: ...
@property
def closed(self) -> bool: ...
# Currently this `setopt()` is very limited; `None` to unset is also not accepted:
# http://pycurl.io/docs/latest/curlshareobject.html#pycurl.CurlShare.setopt
def setopt(self, option: int, value: int) -> None: ...
def share(self, *lock_data: int) -> None: ...
def unshare(self, *lock_data: int) -> None: ...
def __enter__(self) -> Self: ...
def __exit__(
self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None, /
Expand Down Expand Up @@ -166,6 +179,7 @@ class CurlMime:
def add_multipart(self, name: str | bytes | None = None, subtype: str | bytes | None = None) -> CurlMime: ...
def addpart(self) -> CurlMimePart: ...
def close(self) -> None: ...
@property
def closed(self) -> bool: ...
def __enter__(self) -> Self: ...
def __exit__(
Expand Down Expand Up @@ -577,6 +591,9 @@ M_MAX_CONCURRENT_STREAMS: Final = 16
M_MAX_HOST_CONNECTIONS: Final = 7
M_MAX_PIPELINE_LENGTH: Final = 8
M_MAX_TOTAL_CONNECTIONS: Final = 13
M_NOTIFYFUNCTION: Final[int]
M_NOTIFY_EASY_DONE: Final[int]
M_NOTIFY_INFO_READ: Final[int]
M_PIPELINING: Final = 3
M_PIPELINING_SERVER_BL: Final = 10012
M_PIPELINING_SITE_BL: Final = 10011
Expand Down
22 changes: 22 additions & 0 deletions stubs/pycurl/pycurl/async_multi.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import asyncio
from collections.abc import Iterable
from types import TracebackType
from typing import Any
from typing_extensions import Self

from pycurl._pycurl import Curl

class AsyncCurlMulti:
def __init__(self, close_handles: bool = False) -> None: ...
def setopt(self, option: int, value: Any) -> None: ...
Comment thread
aeroyorch marked this conversation as resolved.
Outdated
def add_handle(self, curl: Curl) -> asyncio.Future[Curl]: ...
def remove_handle(self, curl: Curl) -> None: ...
async def perform(self, curl: Curl) -> Curl: ...
def futures(self, curls: Iterable[Curl] | None = None) -> tuple[asyncio.Future[Curl], ...]: ...
@property
def closed(self) -> bool: ...
async def aclose(self) -> None: ...
async def __aenter__(self) -> Self: ...
async def __aexit__(
self, exc_type: type[BaseException] | None, exc: BaseException | None, tb: TracebackType | None
) -> None: ...
Loading