Use PEP 570 syntax in third party stubs (#11554)

This commit is contained in:
Shantanu
2024-03-10 06:11:43 -07:00
committed by GitHub
parent f94bbfbcc4
commit 88fa182253
97 changed files with 625 additions and 632 deletions
+2 -2
View File
@@ -8,6 +8,6 @@ class AbstractLinkable:
def hub(self) -> Hub | None: ...
def __init__(self, hub: Hub | None = None) -> None: ...
def linkcount(self) -> int: ...
def rawlink(self, __callback: Callable[[Self], object]) -> None: ...
def rawlink(self, callback: Callable[[Self], object], /) -> None: ...
def ready(self) -> bool: ...
def unlink(self, __callback: Callable[[Self], object]) -> None: ...
def unlink(self, callback: Callable[[Self], object], /) -> None: ...
+3 -3
View File
@@ -26,12 +26,12 @@ class FileObjectClosed(IOError):
class FlushingBufferedWriter(io.BufferedWriter): ...
class WriteallMixin:
def writeall(self, __b: ReadableBuffer) -> int: ...
def writeall(self, b: ReadableBuffer, /) -> int: ...
class FileIO(io.FileIO): ...
class WriteIsWriteallMixin(WriteallMixin):
def write(self, __b: ReadableBuffer) -> int: ...
def write(self, b: ReadableBuffer, /) -> int: ...
class WriteallFileIO(WriteIsWriteallMixin, io.FileIO): ... # type: ignore[misc]
@@ -87,7 +87,7 @@ class FileObjectBase(Generic[_IOT, AnyStr]):
def close(self) -> None: ...
def __getattr__(self, name: str) -> Any: ...
def __enter__(self) -> Self: ...
def __exit__(self, __typ: type[BaseException] | None, __value: BaseException | None, __tb: TracebackType | None) -> None: ...
def __exit__(self, typ: type[BaseException] | None, value: BaseException | None, tb: TracebackType | None, /) -> None: ...
def __iter__(self) -> Self: ...
def __next__(self) -> AnyStr: ...
def __bool__(self) -> bool: ...
+2 -2
View File
@@ -16,8 +16,8 @@ _Ts = TypeVarTuple("_Ts")
_WaitableT = TypeVar("_WaitableT", bound=_Waitable)
class _Waitable(Protocol):
def rawlink(self, __callback: Callable[[Any], object]) -> object: ...
def unlink(self, __callback: Callable[[Any], object]) -> object: ...
def rawlink(self, callback: Callable[[Any], object], /) -> object: ...
def unlink(self, callback: Callable[[Any], object], /) -> object: ...
class WaitOperationsGreenlet(SwitchOutGreenletWithLoop):
loop: _Loop
+1 -1
View File
@@ -14,7 +14,7 @@ _T = TypeVar("_T")
# sorts of issues to reference a module that is not stubbed in typeshed, so
# for now we punt and just define an alias for Interface and implementer we
# can get rid of later
def implementer(__interface: Any) -> Callable[[_T], _T]: ...
def implementer(interface: Any, /) -> Callable[[_T], _T]: ...
class MonitorWarning(RuntimeWarning): ...
+1 -1
View File
@@ -107,7 +107,7 @@ class _ChildWatcher(_Watcher, Protocol):
# this matches Intersection[_Watcher, AsyncMixin]
class _AsyncWatcher(_Watcher, Protocol):
def send(self) -> None: ...
def send_ignoring_arg(self, __ignored: object) -> None: ...
def send_ignoring_arg(self, ignored: object, /) -> None: ...
@property
def pending(self) -> bool: ...
+2 -4
View File
@@ -35,11 +35,9 @@ class Waiter(Generic[_T]):
def exc_info(self) -> _ThrowArgs | None: ...
def switch(self, value: _T) -> None: ...
@overload
def throw(
self, __typ: type[BaseException], __val: BaseException | object = None, __tb: TracebackType | None = None
) -> None: ...
def throw(self, typ: type[BaseException], val: BaseException | object = None, tb: TracebackType | None = None, /) -> None: ...
@overload
def throw(self, __typ: BaseException = ..., __val: None = None, __tb: TracebackType | None = None) -> None: ...
def throw(self, typ: BaseException = ..., val: None = None, tb: TracebackType | None = None, /) -> None: ...
def get(self) -> _T: ...
def __call__(self, source: _ValueSource[_T]) -> None: ...
+2 -2
View File
@@ -11,7 +11,7 @@ from greenlet import greenlet
_P = ParamSpec("_P")
class _SpawnFunc(Protocol):
def __call__(self, __func: Callable[_P, object], *args: _P.args, **kwargs: _P.kwargs) -> greenlet: ...
def __call__(self, func: Callable[_P, object], /, *args: _P.args, **kwargs: _P.kwargs) -> greenlet: ...
_Spawner: TypeAlias = Pool | _SpawnFunc | int | Literal["default"] | None
@@ -35,7 +35,7 @@ class BaseServer(Generic[_P]):
spawn: _Spawner = "default",
) -> None: ...
def __enter__(self) -> Self: ...
def __exit__(self, __typ: type[BaseException] | None, __value: BaseException | None, __tb: TracebackType | None) -> None: ...
def __exit__(self, typ: type[BaseException] | None, value: BaseException | None, tb: TracebackType | None, /) -> None: ...
def set_listener(self, listener: _GeventSocket | tuple[str, int] | str) -> None: ...
def set_spawn(self, spawn: _Spawner) -> None: ...
def set_handle(self, handle: Callable[_P, object]) -> None: ...
+1 -1
View File
@@ -15,7 +15,7 @@ _T = TypeVar("_T")
# can get rid of later
Interface: TypeAlias = Any
def implementer(__interface: Interface) -> Callable[[_T], _T]: ...
def implementer(interface: Interface, /) -> Callable[[_T], _T]: ...
# this is copied from types-psutil, it would be nice if we could just import this
# but it doesn't seem like we can...
+1 -1
View File
@@ -56,7 +56,7 @@ class Greenlet(greenlet.greenlet, Generic[_P, _T]):
def run(self) -> Any: ...
@overload
@classmethod
def spawn(cls, __run: Callable[_P, _T], *args: _P.args, **kwargs: _P.kwargs) -> Self: ...
def spawn(cls, run: Callable[_P, _T], /, *args: _P.args, **kwargs: _P.kwargs) -> Self: ...
@overload
@classmethod
def spawn(cls) -> Greenlet[[], None]: ...
+1 -1
View File
@@ -165,7 +165,7 @@ class Group(GroupMappingMixin):
@overload
def __init__(self) -> None: ...
@overload
def __init__(self, __grenlets: Collection[Greenlet[..., object]]) -> None: ...
def __init__(self, grenlets: Collection[Greenlet[..., object]], /) -> None: ...
def __len__(self) -> int: ...
def __contains__(self, item: Greenlet[..., object]) -> bool: ...
def __iter__(self) -> Iterator[Greenlet[..., object]]: ...
+1 -1
View File
@@ -18,7 +18,7 @@ __all__ = ["WSGIServer", "WSGIHandler", "LoggingLogAdapter", "Environ", "SecureE
_T = TypeVar("_T")
class _LogOutputStream(SupportsWrite[str], Protocol):
def writelines(self, __lines: Iterable[str]) -> None: ...
def writelines(self, lines: Iterable[str], /) -> None: ...
def flush(self) -> None: ...
class Input:
+2 -2
View File
@@ -79,6 +79,6 @@ class DatagramServer(BaseServer[[_GeventSocket, _Address]]):
def get_listener(cls, address: _StrictAddress, family: int | None = None) -> _GeventSocket: ...
def do_read(self) -> tuple[_GeventSocket, _Address]: ...
@overload
def sendto(self, __data: ReadableBuffer, __address: _StrictAddress) -> int: ...
def sendto(self, data: ReadableBuffer, address: _StrictAddress, /) -> int: ...
@overload
def sendto(self, __data: ReadableBuffer, __flags: int, __address: _StrictAddress) -> int: ...
def sendto(self, data: ReadableBuffer, flags: int, address: _StrictAddress, /) -> int: ...