mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-07 04:34:28 +08:00
Replace various Incompletes in stdlib (#11673)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import abc
|
||||
import sys
|
||||
from _typeshed import Incomplete, OpenBinaryMode, OpenTextMode, Unused
|
||||
from collections.abc import Iterator
|
||||
from io import TextIOWrapper
|
||||
from typing import IO, Any, BinaryIO, Literal, NoReturn, overload
|
||||
@@ -28,11 +27,19 @@ if sys.version_info >= (3, 11):
|
||||
def is_file(self) -> Literal[True]: ...
|
||||
def is_dir(self) -> Literal[False]: ...
|
||||
@overload
|
||||
def open(self, mode: OpenTextMode = "r", *args, **kwargs) -> TextIOWrapper: ...
|
||||
def open(
|
||||
self,
|
||||
mode: Literal["r"] = "r",
|
||||
encoding: str | None = None,
|
||||
errors: str | None = None,
|
||||
newline: str | None = None,
|
||||
line_buffering: bool = False,
|
||||
write_through: bool = False,
|
||||
) -> TextIOWrapper: ...
|
||||
@overload
|
||||
def open(self, mode: OpenBinaryMode, *args: Unused, **kwargs: Unused) -> BinaryIO: ...
|
||||
def open(self, mode: Literal["rb"]) -> BinaryIO: ...
|
||||
@overload
|
||||
def open(self, mode: str, *args: Incomplete, **kwargs) -> IO[Any]: ...
|
||||
def open(self, mode: str) -> IO[Any]: ...
|
||||
def joinpath(self, name: Never) -> NoReturn: ... # type: ignore[override]
|
||||
|
||||
class ResourceContainer(Traversable, metaclass=abc.ABCMeta):
|
||||
|
||||
@@ -179,11 +179,11 @@ class TextIOWrapper(TextIOBase, TextIO): # type: ignore[misc] # incompatible d
|
||||
def __init__(
|
||||
self,
|
||||
buffer: _WrappedBuffer,
|
||||
encoding: str | None = ...,
|
||||
errors: str | None = ...,
|
||||
newline: str | None = ...,
|
||||
line_buffering: bool = ...,
|
||||
write_through: bool = ...,
|
||||
encoding: str | None = None,
|
||||
errors: str | None = None,
|
||||
newline: str | None = None,
|
||||
line_buffering: bool = False,
|
||||
write_through: bool = False,
|
||||
) -> None: ...
|
||||
# Equals the "buffer" argument passed in to the constructor.
|
||||
@property
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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: ...
|
||||
|
||||
|
||||
@@ -170,7 +170,7 @@ class TypeVar:
|
||||
def __or__(self, right: Any) -> _SpecialForm: ...
|
||||
def __ror__(self, left: Any) -> _SpecialForm: ...
|
||||
if sys.version_info >= (3, 11):
|
||||
def __typing_subst__(self, arg): ...
|
||||
def __typing_subst__(self, arg: Any) -> Any: ...
|
||||
|
||||
# Used for an undocumented mypy feature. Does not exist at runtime.
|
||||
_promote = object()
|
||||
@@ -221,7 +221,7 @@ if sys.version_info >= (3, 11):
|
||||
def __init__(self, name: str) -> None: ...
|
||||
def __iter__(self) -> Any: ...
|
||||
def __typing_subst__(self, arg: Never) -> Never: ...
|
||||
def __typing_prepare_subst__(self, alias, args): ...
|
||||
def __typing_prepare_subst__(self, alias: Any, args: Any) -> tuple[Any, ...]: ...
|
||||
|
||||
if sys.version_info >= (3, 10):
|
||||
@final
|
||||
@@ -270,8 +270,8 @@ if sys.version_info >= (3, 10):
|
||||
@property
|
||||
def kwargs(self) -> ParamSpecKwargs: ...
|
||||
if sys.version_info >= (3, 11):
|
||||
def __typing_subst__(self, arg): ...
|
||||
def __typing_prepare_subst__(self, alias, args): ...
|
||||
def __typing_subst__(self, arg: Any) -> Any: ...
|
||||
def __typing_prepare_subst__(self, alias: Any, args: Any) -> tuple[Any, ...]: ...
|
||||
|
||||
def __or__(self, right: Any) -> _SpecialForm: ...
|
||||
def __ror__(self, left: Any) -> _SpecialForm: ...
|
||||
|
||||
@@ -413,7 +413,7 @@ class TypeVar:
|
||||
def __or__(self, right: Any) -> _SpecialForm: ...
|
||||
def __ror__(self, left: Any) -> _SpecialForm: ...
|
||||
if sys.version_info >= (3, 11):
|
||||
def __typing_subst__(self, arg): ...
|
||||
def __typing_subst__(self, arg: Any) -> Any: ...
|
||||
|
||||
@final
|
||||
class ParamSpec:
|
||||
|
||||
@@ -60,7 +60,7 @@ class DOMBuilder:
|
||||
def supportsFeature(self, name: str) -> bool: ...
|
||||
def canSetFeature(self, name: str, state: int) -> bool: ...
|
||||
# getFeature could return any attribute from an instance of `Options`
|
||||
def getFeature(self, name: str): ...
|
||||
def getFeature(self, name: str) -> Any: ...
|
||||
def parseURI(self, uri: str) -> ExpatBuilder | ExpatBuilderNS: ...
|
||||
def parse(self, input: DOMInputSource) -> ExpatBuilder | ExpatBuilderNS: ...
|
||||
# `input` and `cnode` argtypes for `parseWithContext` are unknowable
|
||||
|
||||
Reference in New Issue
Block a user