Skip to content

Add __all__ part 2 #13719

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

Merged
merged 9 commits into from
Mar 31, 2025
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
3 changes: 0 additions & 3 deletions stubs/WTForms/@tests/stubtest_allowlist.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# TODO: missing from stub
wtforms.form.__all__

# Error: is not present at runtime
# =============================
# This is hack to get around Field.__new__ not being able to return
Expand Down
2 changes: 2 additions & 0 deletions stubs/WTForms/wtforms/form.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,5 @@ class Form(BaseForm, metaclass=FormMeta):
def __setitem__(self, name: str, value: None) -> None: ... # type: ignore[override]
def __delitem__(self, name: str) -> None: ...
def __delattr__(self, name: str) -> None: ...

__all__ = ("BaseForm", "Form")
3 changes: 0 additions & 3 deletions stubs/editdistance/@tests/stubtest_allowlist.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
# TODO: missing from stub
editdistance.__all__

# Not public API -- the submodule is an implementation detail due to it being a cythonized package
editdistance.bycython
2 changes: 2 additions & 0 deletions stubs/editdistance/editdistance/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ def eval(a: Iterable[Hashable], b: Iterable[Hashable]) -> int: ...
def distance(a: Iterable[Hashable], b: Iterable[Hashable]) -> int: ...
def eval_criterion(a: Iterable[Hashable], b: Iterable[Hashable], thr: int) -> bool: ...
def distance_le_than(a: Iterable[Hashable], b: Iterable[Hashable], thr: int) -> bool: ...

__all__ = ("eval", "distance", "eval_criterion", "distance_le_than")
35 changes: 0 additions & 35 deletions stubs/gevent/@tests/stubtest_allowlist.txt
Original file line number Diff line number Diff line change
@@ -1,40 +1,8 @@
# TODO: missing from stub
gevent._abstract_linkable.__all__
gevent._ffi.loop.__all__
gevent._ffi.watcher.__all__
gevent._greenlet_primitives.__all__
gevent._ident.__all__
gevent._imap.__all__
gevent.backdoor.__all__
gevent.baseserver.__all__
gevent.event.__all__
gevent.events.__all__
gevent.exceptions.__all__
gevent.fileobject.__all__
gevent.greenlet.__all__
gevent.hub.__all__
gevent.libev.__all__
gevent.libev.corecext.__all__
gevent.libuv.__all__
gevent.libuv.loop.__all__
gevent.libuv.watcher.__all__
gevent.local.__all__
gevent.monkey.__all__
gevent.os.__all__
gevent.resolver.__all__
gevent.resolver.blocking.__all__
gevent.resolver.dnspython.__all__
gevent.resolver.thread.__all__
gevent.resolver_thread.__all__
gevent.server.__all__
gevent.signal.__all__
gevent.socket.__all__
gevent.ssl.__all__
gevent.subprocess.__all__
gevent.threadpool.__all__
gevent.timeout.__all__
gevent.util.__all__
gevent.win32util.__all__

# Error: failed to find stubs
# =============================
Expand Down Expand Up @@ -66,7 +34,6 @@ gevent._ffi.ERROR
gevent._ffi.GEVENT_DEBUG_LEVEL
gevent._ffi.TRACE
gevent._ffi.loop.AbstractLoop.async
gevent._ffi.loop.assign_standard_callbacks
gevent._fileobjectcommon.UniversalNewlineBytesWrapper
gevent._waiter.Waiter.switch_args

Expand All @@ -79,8 +46,6 @@ gevent.libuv.watcher.watcher.feed
# unnecessary python 2 compatibility stuff
gevent._config.Config.trace_malloc
gevent._imap.IMapUnordered.next
gevent.monkey.patch_builtins
gevent.monkey.patch_sys
gevent.pywsgi.Environ.iteritems

# weird method that doesn't work with this being generic, so we removed it
Expand Down
6 changes: 0 additions & 6 deletions stubs/gevent/@tests/stubtest_allowlist_darwin.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
# TODO: missing from stub
gevent.ares.__all__
gevent.libev.corecffi.__all__
gevent.resolver.ares.__all__
gevent.resolver_ares.__all__

# Error: is not present in stub
# =============================
# internal API stuff we dropped because it wasn't necessary
Expand Down
6 changes: 0 additions & 6 deletions stubs/gevent/@tests/stubtest_allowlist_linux.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
# TODO: missing from stub
gevent.ares.__all__
gevent.libev.corecffi.__all__
gevent.resolver.ares.__all__
gevent.resolver_ares.__all__

# Error: is not present in stub
# =============================
# internal API stuff we dropped because it wasn't necessary
Expand Down
1 change: 1 addition & 0 deletions stubs/gevent/@tests/stubtest_allowlist_win32.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Error: is not present in stub
# =============================
# these get exported but don't actually work on win32 so we ignore them
gevent.signal.__all__
gevent.signal.getsignal
gevent.signal.signal

Expand Down
2 changes: 2 additions & 0 deletions stubs/gevent/gevent/_abstract_linkable.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ class AbstractLinkable:
def rawlink(self, callback: Callable[[Self], object], /) -> None: ...
def ready(self) -> bool: ...
def unlink(self, callback: Callable[[Self], object], /) -> None: ...

__all__ = ["AbstractLinkable"]
8 changes: 7 additions & 1 deletion stubs/gevent/gevent/_ffi/loop.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sys
from _typeshed import FileDescriptor
from collections.abc import Callable
from collections.abc import Callable, Sequence
from types import TracebackType
from typing import Protocol
from typing_extensions import TypeAlias, TypeVarTuple, Unpack
Expand All @@ -17,6 +17,10 @@ class _SupportsHandleError(Protocol):

_ErrorHandler: TypeAlias = _ErrorHandlerFunc | _SupportsHandleError

def assign_standard_callbacks(
ffi: object, lib: object, callbacks_class: Callable[[object], object], extras: Sequence[tuple[object, object]] = ...
) -> object: ...

class AbstractLoop:
CALLBACK_CHECK_COUNT: int
error_handler: _ErrorHandler | None
Expand Down Expand Up @@ -78,3 +82,5 @@ class AbstractLoop:
def run_callback_threadsafe(self, func: Callable[[Unpack[_Ts]], object], *args: Unpack[_Ts]) -> _Callback: ...
def callback(self, priority: float | None = ...) -> _Callback: ...
def fileno(self) -> FileDescriptor | None: ...

__all__ = ["AbstractLoop", "assign_standard_callbacks"]
2 changes: 2 additions & 0 deletions stubs/gevent/gevent/_ffi/watcher.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,5 @@ class StatMixin:
def prev(self) -> _StatResult | None: ...
@property
def interval(self) -> float: ...

__all__: list[str] = []
2 changes: 2 additions & 0 deletions stubs/gevent/gevent/_greenlet_primitives.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ class SwitchOutGreenletWithLoop(TrackedRawGreenlet):
def loop(self, value: _Loop) -> None: ...
def switch(self) -> Any: ...
def switch_out(self) -> NoReturn: ...

__all__ = ["TrackedRawGreenlet", "SwitchOutGreenletWithLoop"]
2 changes: 2 additions & 0 deletions stubs/gevent/gevent/_ident.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ class IdentRegistry:
def __init__(self) -> None: ...
def get_ident(self, obj: object) -> int: ...
def __len__(self) -> int: ...

__all__ = ["IdentRegistry"]
2 changes: 2 additions & 0 deletions stubs/gevent/gevent/_imap.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ class IMapUnordered(Greenlet[_P, _T]):

class IMap(IMapUnordered[_P, _T]):
index: int

__all__ = ["IMapUnordered", "IMap"]
5 changes: 5 additions & 0 deletions stubs/gevent/gevent/ares.pyi
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
import sys

from gevent.resolver.cares import *

if sys.platform != "win32":
__all__ = ["channel"]
2 changes: 2 additions & 0 deletions stubs/gevent/gevent/backdoor.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,5 @@ class BackdoorServer(StreamServer):
ciphers: str = ...,
) -> None: ...
def handle(self, conn: _GeventSocket, _address: _Address) -> None: ...

__all__ = ["BackdoorServer"]
2 changes: 2 additions & 0 deletions stubs/gevent/gevent/baseserver.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,5 @@ class BaseServer(Generic[_P]):
def stop(self, timeout: float | None = None) -> None: ...
def serve_forever(self, stop_timeout: float | None = None) -> None: ...
def is_fatal_error(self, ex: BaseException) -> bool: ...

__all__ = ["BaseServer"]
2 changes: 2 additions & 0 deletions stubs/gevent/gevent/event.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,5 @@ class AsyncResult(AbstractLinkable, Generic[_T]):
def done(self) -> bool: ...
def cancel(self) -> Literal[False]: ...
def cancelled(self) -> Literal[False]: ...

__all__ = ["Event", "AsyncResult"]
32 changes: 32 additions & 0 deletions stubs/gevent/gevent/events.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,35 @@ class IGeventDidPatchAllEvent(IGeventDidPatchEvent): ...
@implementer(IGeventDidPatchAllEvent)
class GeventDidPatchAllEvent(_PatchAllMixin, GeventDidPatchEvent):
ENTRY_POINT_NAME: str

__all__ = [
"subscribers",
# monitor thread
"IEventLoopBlocked",
"EventLoopBlocked",
"IMemoryUsageThresholdExceeded",
"MemoryUsageThresholdExceeded",
"IMemoryUsageUnderThreshold",
"MemoryUsageUnderThreshold",
# Hub
"IPeriodicMonitorThread",
"IPeriodicMonitorThreadStartedEvent",
"PeriodicMonitorThreadStartedEvent",
# monkey
"IGeventPatchEvent",
"GeventPatchEvent",
"IGeventWillPatchEvent",
"DoNotPatch",
"GeventWillPatchEvent",
"IGeventDidPatchEvent",
"IGeventWillPatchModuleEvent",
"GeventWillPatchModuleEvent",
"IGeventDidPatchModuleEvent",
"GeventDidPatchModuleEvent",
"IGeventWillPatchAllEvent",
"GeventWillPatchAllEvent",
"IGeventDidPatchBuiltinModulesEvent",
"GeventDidPatchBuiltinModulesEvent",
"IGeventDidPatchAllEvent",
"GeventDidPatchAllEvent",
]
2 changes: 2 additions & 0 deletions stubs/gevent/gevent/exceptions.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ class InvalidThreadUseError(RuntimeError): ...
class HubDestroyed(GreenletExit):
destroy_loop: bool
def __init__(self, destroy_loop: bool) -> None: ...

__all__ = ["LoopExit"]
2 changes: 2 additions & 0 deletions stubs/gevent/gevent/fileobject.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ if sys.platform != "win32":
) -> None: ...

_FileObjectType: TypeAlias = type[FileObjectPosix[Any, Any] | FileObjectBlock[Any, Any] | FileObjectThread[Any, Any]]
__all__ = ["FileObjectPosix", "FileObjectThread", "FileObjectBlock", "FileObject"]
else:
_FileObjectType: TypeAlias = type[FileObjectBlock[Any, Any] | FileObjectThread[Any, Any]]
__all__ = ["FileObjectThread", "FileObjectBlock", "FileObject"]

FileObject: _FileObjectType
2 changes: 2 additions & 0 deletions stubs/gevent/gevent/greenlet.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,5 @@ def killall(
block: bool = True,
timeout: float | None = None,
) -> None: ...

__all__ = ["Greenlet", "joinall", "killall"]
2 changes: 2 additions & 0 deletions stubs/gevent/gevent/hub.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,5 @@ class linkproxy:
obj: object
def __init__(self, callback: Callable[[_T], object], obj: _T) -> None: ...
def __call__(self, *args: object) -> None: ...

__all__ = ["getcurrent", "GreenletExit", "spawn_raw", "sleep", "kill", "signal", "reinit", "get_hub", "Hub", "Waiter"]
1 change: 1 addition & 0 deletions stubs/gevent/gevent/libev/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__all__: list[str] = []
10 changes: 10 additions & 0 deletions stubs/gevent/gevent/libev/corecext.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,13 @@ if sys.platform != "win32":
def origflags_int(self) -> int: ...
@property
def sigfd(self) -> FileDescriptor: ...

__all__ = [
"get_version",
"get_header_version",
"supported_backends",
"recommended_backends",
"embeddable_backends",
"time",
"loop",
]
10 changes: 10 additions & 0 deletions stubs/gevent/gevent/libev/corecffi.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,13 @@ class loop(AbstractLoop):
def reset_sigchld(self) -> None: ...

def stat(self, path: str, interval: float = 0.0, ref: bool = True, priority: bool | None = None) -> watcher.stat: ...

__all__ = [
"get_version",
"get_header_version",
"supported_backends",
"recommended_backends",
"embeddable_backends",
"time",
"loop",
]
1 change: 1 addition & 0 deletions stubs/gevent/gevent/libuv/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__all__: list[str] = []
2 changes: 2 additions & 0 deletions stubs/gevent/gevent/libuv/loop.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,5 @@ class loop(AbstractLoop):
def fork(self, ref: bool = True, priority: int | None = None) -> watcher.fork: ...
def child(self, pid: int, trace: int = 0, ref: bool = True) -> watcher.child: ...
# prepare is not supported on libuv yet, but we need type_error to annotate that

__all__: list[str] = []
2 changes: 2 additions & 0 deletions stubs/gevent/gevent/libuv/watcher.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ class signal(_base.SignalMixin, watcher): ...
class idle(_base.IdleMixin, watcher): ...
class check(_base.CheckMixin, watcher): ...
class prepare(_base.PrepareMixin, watcher): ...

__all__: list[str] = []
2 changes: 2 additions & 0 deletions stubs/gevent/gevent/local.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ class local:
def __getattribute__(self, name: str) -> Any: ...
def __delattr__(self, name: str) -> None: ...
def __setattr__(self, name: str, value: Any) -> None: ...

__all__ = ["local"]
28 changes: 28 additions & 0 deletions stubs/gevent/gevent/monkey/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ def patch_thread(
threading: bool = True, _threading_local: bool = True, Event: bool = True, logging: bool = True, existing_locks: bool = True
) -> None: ...
def patch_socket(dns: bool = True, aggressive: bool = True) -> None: ...
def patch_builtins() -> None: ...
def patch_dns() -> None: ...
def patch_ssl() -> None: ...
def patch_select(aggressive: bool = True) -> None: ...
def patch_selectors(aggressive: bool = True) -> None: ...
def patch_subprocess() -> None: ...
def patch_sys(stdin: bool = True, stdout: bool = True, stderr: bool = True) -> None: ...
def patch_signal() -> None: ...
def patch_all(
socket: bool = True,
Expand All @@ -38,3 +40,29 @@ def patch_all(
**kwargs: object,
) -> bool | None: ...
def main() -> dict[str, Any]: ...

__all__ = [
"patch_all",
"patch_builtins",
"patch_dns",
"patch_os",
"patch_queue",
"patch_select",
"patch_signal",
"patch_socket",
"patch_ssl",
"patch_subprocess",
"patch_sys",
"patch_thread",
"patch_time",
# query functions
"get_original",
"is_module_patched",
"is_object_patched",
# plugin API
"patch_module",
# module functions
"main",
# Errors and warnings
"MonkeyPatchWarning",
]
2 changes: 2 additions & 0 deletions stubs/gevent/gevent/resolver/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ class AbstractResolver:
) -> _AddrinfoResult: ...
def gethostbyaddr(self, ip_address: str) -> tuple[str, list[str], list[str]]: ...
def getnameinfo(self, sockaddr: _SockAddr, flags: int) -> _NameinfoResult: ...

__all__ = ()
2 changes: 2 additions & 0 deletions stubs/gevent/gevent/resolver/ares.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,5 @@ if sys.platform != "win32":
servers: Sequence[str] | str | None = None,
) -> None: ...
def __del__(self) -> None: ...

__all__ = ["Resolver"]
2 changes: 2 additions & 0 deletions stubs/gevent/gevent/resolver/blocking.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ class Resolver:
) -> _AddrinfoResult: ...
def gethostbyaddr(self, ip_address: str) -> tuple[str, list[str], list[str]]: ...
def getnameinfo(self, sockaddr: _SockAddr, flags: int) -> _NameinfoResult: ...

__all__ = ["Resolver"]
2 changes: 2 additions & 0 deletions stubs/gevent/gevent/resolver/dnspython.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ class Resolver(AbstractResolver):
def __init__(self, hub: Hub | None = ...) -> None: ...
@property
def resolver(self) -> Any: ... # this is a custom dnspython Resolver

__all__ = ["Resolver"]
2 changes: 2 additions & 0 deletions stubs/gevent/gevent/resolver/thread.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ class Resolver:
) -> _AddrinfoResult: ...
def gethostbyaddr(self, ip_address: str) -> tuple[str, list[str], list[str]]: ...
def getnameinfo(self, sockaddr: _SockAddr, flags: int) -> _NameinfoResult: ...

__all__ = ["Resolver"]
5 changes: 5 additions & 0 deletions stubs/gevent/gevent/resolver_ares.pyi
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
import sys

from gevent.resolver.ares import *

if sys.platform != "win32":
__all__ = ["Resolver"]
1 change: 1 addition & 0 deletions stubs/gevent/gevent/resolver_thread.pyi
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from gevent.resolver.thread import *
from gevent.resolver.thread import __all__ as __all__
2 changes: 2 additions & 0 deletions stubs/gevent/gevent/server.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,5 @@ class DatagramServer(BaseServer[[_GeventSocket, _Address]]):
def sendto(self, data: ReadableBuffer, address: _StrictAddress, /) -> int: ...
@overload
def sendto(self, data: ReadableBuffer, flags: int, address: _StrictAddress, /) -> int: ...

__all__ = ["StreamServer", "DatagramServer"]
Loading