Replace various Incompletes in stdlib (#11673)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
Sebastian Rittau
2024-04-01 16:20:01 +02:00
committed by GitHub
parent 0cea0bc06e
commit 630b49a291
7 changed files with 49 additions and 23 deletions

View File

@@ -6,8 +6,8 @@ __all__ = ["ensure_running", "register", "unregister"]
class ResourceTracker:
def getfd(self) -> int | None: ...
def ensure_running(self) -> None: ...
def register(self, name: Sized, rtype) -> None: ...
def unregister(self, name: Sized, rtype) -> None: ...
def register(self, name: Sized, rtype: str) -> None: ...
def unregister(self, name: Sized, rtype: str) -> None: ...
_resource_tracker: ResourceTracker
ensure_running = _resource_tracker.ensure_running

View File

@@ -2,7 +2,7 @@ import threading
from _typeshed import ConvertibleToInt, Incomplete, Unused
from collections.abc import Callable, Iterable, Mapping, MutableMapping, Sequence
from logging import Logger, _Level as _LoggingLevel
from typing import Any
from typing import Any, Generic, TypeVar, overload
__all__ = [
"sub_debug",
@@ -22,6 +22,9 @@ __all__ = [
"SUBWARNING",
]
_T = TypeVar("_T")
_R_co = TypeVar("_R_co", default=Any, covariant=True)
NOTSET: int
SUBDEBUG: int
DEBUG: int
@@ -42,13 +45,29 @@ def is_abstract_socket_namespace(address: str | bytes | None) -> bool: ...
abstract_sockets_supported: bool
def get_temp_dir() -> str: ...
def register_after_fork(obj, func: Callable[[Incomplete], object]) -> None: ...
def register_after_fork(obj: _T, func: Callable[[_T], object]) -> None: ...
class Finalize:
class Finalize(Generic[_R_co]):
# "args" and "kwargs" are passed as arguments to "callback".
@overload
def __init__(
self,
obj: Incomplete | None,
callback: Callable[..., Incomplete],
obj: None,
callback: Callable[..., _R_co],
*,
args: Sequence[Any] = (),
kwargs: Mapping[str, Any] | None = None,
exitpriority: int,
) -> None: ...
@overload
def __init__(
self, obj: None, callback: Callable[..., _R_co], args: Sequence[Any], kwargs: Mapping[str, Any] | None, exitpriority: int
) -> None: ...
@overload
def __init__(
self,
obj: Any,
callback: Callable[..., _R_co],
args: Sequence[Any] = (),
kwargs: Mapping[str, Any] | None = None,
exitpriority: int | None = None,
@@ -59,7 +78,7 @@ class Finalize:
_finalizer_registry: MutableMapping[Incomplete, Incomplete] = {},
sub_debug: Callable[..., object] = ...,
getpid: Callable[[], int] = ...,
): ...
) -> _R_co: ...
def cancel(self) -> None: ...
def still_active(self) -> bool: ...