mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-07-31 21:20:23 +08:00
Mark stub-only private symbols as @type_check_only in third-party stubs (#14545)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
from collections.abc import Callable, Sequence
|
||||
from typing import Any, Generic, NoReturn, Protocol, TypeVar, overload
|
||||
from typing import Any, Generic, NoReturn, Protocol, TypeVar, overload, type_check_only
|
||||
|
||||
from gevent._types import _Loop, _Resolver
|
||||
from gevent.fileobject import _FileObjectType
|
||||
@@ -9,6 +9,7 @@ __all__ = ["config"]
|
||||
|
||||
_T = TypeVar("_T")
|
||||
|
||||
@type_check_only
|
||||
class _SettingDescriptor(Protocol[_T]):
|
||||
@overload
|
||||
def __get__(self, obj: None, owner: type[Config]) -> property: ...
|
||||
|
||||
@@ -2,7 +2,7 @@ import sys
|
||||
from _typeshed import FileDescriptor
|
||||
from collections.abc import Callable, Sequence
|
||||
from types import TracebackType
|
||||
from typing import Protocol
|
||||
from typing import Protocol, type_check_only
|
||||
from typing_extensions import TypeAlias, TypeVarTuple, Unpack
|
||||
|
||||
from gevent._types import _AsyncWatcher, _Callback, _ChildWatcher, _IoWatcher, _StatWatcher, _TimerWatcher, _Watcher
|
||||
@@ -12,6 +12,7 @@ _ErrorHandlerFunc: TypeAlias = Callable[
|
||||
[object | None, type[BaseException] | None, BaseException | None, TracebackType | None], object
|
||||
]
|
||||
|
||||
@type_check_only
|
||||
class _SupportsHandleError(Protocol):
|
||||
handle_error: _ErrorHandlerFunc
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from _typeshed import FileDescriptor
|
||||
from collections.abc import Callable, Collection, Iterable
|
||||
from types import TracebackType
|
||||
from typing import Any, Generic, Protocol, TypeVar, overload
|
||||
from typing import Any, Generic, Protocol, TypeVar, overload, type_check_only
|
||||
from typing_extensions import Self, TypeVarTuple, Unpack
|
||||
|
||||
from gevent._greenlet_primitives import SwitchOutGreenletWithLoop
|
||||
@@ -15,6 +15,7 @@ _T = TypeVar("_T")
|
||||
_Ts = TypeVarTuple("_Ts")
|
||||
_WaitableT = TypeVar("_WaitableT", bound=_Waitable)
|
||||
|
||||
@type_check_only
|
||||
class _Waitable(Protocol):
|
||||
def rawlink(self, callback: Callable[[Any], object], /) -> object: ...
|
||||
def unlink(self, callback: Callable[[Any], object], /) -> object: ...
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from collections.abc import Callable, Container
|
||||
from types import TracebackType
|
||||
from typing import Any, Generic, Literal, Protocol
|
||||
from typing import Any, Generic, Literal, Protocol, type_check_only
|
||||
from typing_extensions import ParamSpec, Self, TypeAlias
|
||||
|
||||
from gevent._types import _Loop
|
||||
@@ -10,6 +10,7 @@ from greenlet import greenlet
|
||||
|
||||
_P = ParamSpec("_P")
|
||||
|
||||
@type_check_only
|
||||
class _SpawnFunc(Protocol):
|
||||
def __call__(self, func: Callable[_P, object], /, *args: _P.args, **kwargs: _P.kwargs) -> greenlet: ...
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from types import TracebackType
|
||||
from typing import Generic, Literal, Protocol, TypeVar, overload
|
||||
from typing import Generic, Literal, Protocol, TypeVar, overload, type_check_only
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
from gevent._abstract_linkable import AbstractLinkable
|
||||
@@ -11,6 +11,7 @@ _T_co = TypeVar("_T_co", covariant=True)
|
||||
_ExcInfo: TypeAlias = tuple[type[BaseException], BaseException, TracebackType | None]
|
||||
_OptExcInfo: TypeAlias = _ExcInfo | tuple[None, None, None]
|
||||
|
||||
@type_check_only
|
||||
class _ValueSource(Protocol[_T_co]):
|
||||
def successful(self) -> bool: ...
|
||||
@property
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import sys
|
||||
from collections.abc import Callable, Mapping, Sequence
|
||||
from types import ModuleType
|
||||
from typing import Any, Protocol, TypeVar
|
||||
from typing import Any, Protocol, TypeVar, type_check_only
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
from gevent.hub import Hub
|
||||
@@ -30,6 +30,7 @@ else:
|
||||
|
||||
subscribers: list[Callable[[Any], object]]
|
||||
|
||||
@type_check_only
|
||||
class _PeriodicMonitorThread(Protocol):
|
||||
def add_monitoring_function(self, function: Callable[[Hub], object], period: float | None) -> object: ...
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from collections.abc import Callable
|
||||
from types import TracebackType
|
||||
from typing import Any, Generic, Protocol, TextIO, TypeVar, overload
|
||||
from typing import Any, Generic, Protocol, TextIO, TypeVar, overload, type_check_only
|
||||
from typing_extensions import ParamSpec
|
||||
|
||||
import gevent._hub_local
|
||||
@@ -23,6 +23,7 @@ getcurrent = greenlet.getcurrent
|
||||
get_hub = gevent._hub_local.get_hub
|
||||
Waiter = gevent._waiter.Waiter
|
||||
|
||||
@type_check_only
|
||||
class _DefaultReturnProperty(Protocol[_T]):
|
||||
@overload
|
||||
def __get__(self, obj: None, owner: type[object] | None = None) -> property: ...
|
||||
|
||||
@@ -5,7 +5,7 @@ from http.client import HTTPMessage
|
||||
from io import BufferedIOBase, BufferedReader
|
||||
from logging import Logger
|
||||
from types import TracebackType
|
||||
from typing import Any, ClassVar, Literal, Protocol, TypeVar, overload
|
||||
from typing import Any, ClassVar, Literal, Protocol, TypeVar, overload, type_check_only
|
||||
from typing_extensions import Self
|
||||
|
||||
from gevent.baseserver import _Spawner
|
||||
@@ -17,6 +17,7 @@ __all__ = ["WSGIServer", "WSGIHandler", "LoggingLogAdapter", "Environ", "SecureE
|
||||
|
||||
_T = TypeVar("_T")
|
||||
|
||||
@type_check_only
|
||||
class _LogOutputStream(SupportsWrite[str], Protocol):
|
||||
def writelines(self, lines: Iterable[str], /) -> None: ...
|
||||
def flush(self) -> None: ...
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
from collections.abc import Sequence
|
||||
from typing import TypedDict
|
||||
from typing import TypedDict, type_check_only
|
||||
|
||||
from gevent._types import _Watcher
|
||||
from gevent.hub import Hub
|
||||
from gevent.resolver import AbstractResolver
|
||||
from gevent.resolver.cares import channel
|
||||
|
||||
@type_check_only
|
||||
class _ChannelArgs(TypedDict):
|
||||
flags: str | int | None
|
||||
timeout: str | float | None
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from _socket import _Address as _StrictAddress
|
||||
from _typeshed import ReadableBuffer, StrOrBytesPath
|
||||
from collections.abc import Callable
|
||||
from typing import Any, ClassVar, TypedDict, overload
|
||||
from typing import Any, ClassVar, TypedDict, overload, type_check_only
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
from gevent.baseserver import BaseServer, _Spawner
|
||||
@@ -12,6 +12,7 @@ from gevent.ssl import SSLContext, wrap_socket as ssl_wrap_socket
|
||||
# from the stdlib _socket.pyi. But that would exclude some potentially valid handlers.
|
||||
_Address: TypeAlias = Any
|
||||
|
||||
@type_check_only
|
||||
class _SSLArguments(TypedDict, total=False):
|
||||
keyfile: StrOrBytesPath
|
||||
certfile: StrOrBytesPath
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from collections.abc import Callable
|
||||
from types import TracebackType
|
||||
from typing import Any, Literal, Protocol, TypeVar, overload
|
||||
from typing import Any, Literal, Protocol, TypeVar, overload, type_check_only
|
||||
from typing_extensions import ParamSpec, Self
|
||||
|
||||
from gevent._types import _TimerWatcher
|
||||
@@ -11,6 +11,7 @@ _T2 = TypeVar("_T2")
|
||||
_TimeoutT = TypeVar("_TimeoutT", bound=Timeout)
|
||||
_P = ParamSpec("_P")
|
||||
|
||||
@type_check_only
|
||||
class _HasSeconds(Protocol):
|
||||
@property
|
||||
def seconds(self) -> float | int: ...
|
||||
|
||||
Reference in New Issue
Block a user