mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-15 00:07:09 +08:00
stdlib: audit more callback annotations (#8209)
This commit is contained in:
@@ -7,7 +7,7 @@ __all__ = ["error", "start_new_thread", "exit", "get_ident", "allocate_lock", "i
|
||||
TIMEOUT_MAX: int
|
||||
error = RuntimeError
|
||||
|
||||
def start_new_thread(function: Callable[..., Any], args: tuple[Any, ...], kwargs: dict[str, Any] = ...) -> None: ...
|
||||
def start_new_thread(function: Callable[..., object], args: tuple[Any, ...], kwargs: dict[str, Any] = ...) -> None: ...
|
||||
def exit() -> NoReturn: ...
|
||||
def get_ident() -> int: ...
|
||||
def allocate_lock() -> LockType: ...
|
||||
|
||||
@@ -60,7 +60,7 @@ class Thread:
|
||||
def __init__(
|
||||
self,
|
||||
group: None = ...,
|
||||
target: Callable[..., Any] | None = ...,
|
||||
target: Callable[..., object] | None = ...,
|
||||
name: str | None = ...,
|
||||
args: Iterable[Any] = ...,
|
||||
kwargs: Mapping[str, Any] | None = ...,
|
||||
@@ -151,7 +151,7 @@ class Timer(Thread):
|
||||
def __init__(
|
||||
self,
|
||||
interval: float,
|
||||
function: Callable[..., Any],
|
||||
function: Callable[..., object],
|
||||
args: Iterable[Any] | None = ...,
|
||||
kwargs: Mapping[str, Any] | None = ...,
|
||||
) -> None: ...
|
||||
|
||||
@@ -19,7 +19,7 @@ class LockType:
|
||||
self, type: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None
|
||||
) -> None: ...
|
||||
|
||||
def start_new_thread(function: Callable[..., Any], args: tuple[Any, ...], kwargs: dict[str, Any] = ...) -> int: ...
|
||||
def start_new_thread(function: Callable[..., object], args: tuple[Any, ...], kwargs: dict[str, Any] = ...) -> int: ...
|
||||
def interrupt_main() -> None: ...
|
||||
def exit() -> NoReturn: ...
|
||||
def allocate_lock() -> LockType: ...
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from collections.abc import Callable
|
||||
from typing import Any, TypeVar
|
||||
from typing import TypeVar
|
||||
from typing_extensions import ParamSpec
|
||||
|
||||
_T = TypeVar("_T")
|
||||
@@ -9,4 +9,4 @@ def _clear() -> None: ...
|
||||
def _ncallbacks() -> int: ...
|
||||
def _run_exitfuncs() -> None: ...
|
||||
def register(func: Callable[_P, _T], *args: _P.args, **kwargs: _P.kwargs) -> Callable[_P, _T]: ...
|
||||
def unregister(func: Callable[..., Any]) -> None: ...
|
||||
def unregister(func: Callable[..., object]) -> None: ...
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
import sys
|
||||
from _typeshed import ExcInfo
|
||||
from _typeshed import ExcInfo, TraceFunction
|
||||
from collections.abc import Callable, Iterable, Mapping
|
||||
from types import CodeType, FrameType, TracebackType
|
||||
from typing import IO, Any, SupportsInt, TypeVar
|
||||
from typing_extensions import Literal, ParamSpec, TypeAlias
|
||||
from typing_extensions import Literal, ParamSpec
|
||||
|
||||
__all__ = ["BdbQuit", "Bdb", "Breakpoint"]
|
||||
|
||||
_T = TypeVar("_T")
|
||||
_P = ParamSpec("_P")
|
||||
_TraceDispatch: TypeAlias = Callable[[FrameType, str, Any], Any] # TODO: Recursive type
|
||||
|
||||
GENERATOR_AND_COROUTINE_FLAGS: Literal[672]
|
||||
|
||||
@@ -28,11 +27,11 @@ class Bdb:
|
||||
def __init__(self, skip: Iterable[str] | None = ...) -> None: ...
|
||||
def canonic(self, filename: str) -> str: ...
|
||||
def reset(self) -> None: ...
|
||||
def trace_dispatch(self, frame: FrameType, event: str, arg: Any) -> _TraceDispatch: ...
|
||||
def dispatch_line(self, frame: FrameType) -> _TraceDispatch: ...
|
||||
def dispatch_call(self, frame: FrameType, arg: None) -> _TraceDispatch: ...
|
||||
def dispatch_return(self, frame: FrameType, arg: Any) -> _TraceDispatch: ...
|
||||
def dispatch_exception(self, frame: FrameType, arg: ExcInfo) -> _TraceDispatch: ...
|
||||
def trace_dispatch(self, frame: FrameType, event: str, arg: Any) -> TraceFunction: ...
|
||||
def dispatch_line(self, frame: FrameType) -> TraceFunction: ...
|
||||
def dispatch_call(self, frame: FrameType, arg: None) -> TraceFunction: ...
|
||||
def dispatch_return(self, frame: FrameType, arg: Any) -> TraceFunction: ...
|
||||
def dispatch_exception(self, frame: FrameType, arg: ExcInfo) -> TraceFunction: ...
|
||||
def is_skipped_module(self, module_name: str) -> bool: ...
|
||||
def stop_here(self, frame: FrameType) -> bool: ...
|
||||
def break_here(self, frame: FrameType) -> bool: ...
|
||||
|
||||
@@ -49,7 +49,7 @@ class Future(Generic[_T]):
|
||||
def cancelled(self) -> bool: ...
|
||||
def running(self) -> bool: ...
|
||||
def done(self) -> bool: ...
|
||||
def add_done_callback(self, fn: Callable[[Future[_T]], Any]) -> None: ...
|
||||
def add_done_callback(self, fn: Callable[[Future[_T]], object]) -> None: ...
|
||||
def result(self, timeout: float | None = ...) -> _T: ...
|
||||
def set_running_or_notify_cancel(self) -> bool: ...
|
||||
def set_result(self, result: _T) -> None: ...
|
||||
|
||||
@@ -10,6 +10,8 @@ from weakref import ref
|
||||
|
||||
from ._base import BrokenExecutor, Executor, Future
|
||||
|
||||
_T = TypeVar("_T")
|
||||
|
||||
_threads_wakeups: MutableMapping[Any, Any]
|
||||
_global_shutdown: bool
|
||||
|
||||
@@ -40,14 +42,12 @@ class _ExceptionWithTraceback:
|
||||
|
||||
def _rebuild_exc(exc: Exception, tb: str) -> Exception: ...
|
||||
|
||||
_S = TypeVar("_S")
|
||||
|
||||
class _WorkItem(Generic[_S]):
|
||||
future: Future[_S]
|
||||
fn: Callable[..., _S]
|
||||
class _WorkItem(Generic[_T]):
|
||||
future: Future[_T]
|
||||
fn: Callable[..., _T]
|
||||
args: Iterable[Any]
|
||||
kwargs: Mapping[str, Any]
|
||||
def __init__(self, future: Future[_S], fn: Callable[..., _S], args: Iterable[Any], kwargs: Mapping[str, Any]) -> None: ...
|
||||
def __init__(self, future: Future[_T], fn: Callable[..., _T], args: Iterable[Any], kwargs: Mapping[str, Any]) -> None: ...
|
||||
|
||||
class _ResultItem:
|
||||
work_id: int
|
||||
@@ -90,7 +90,7 @@ class _SafeQueue(Queue[Future[Any]]):
|
||||
def _on_queue_feeder_error(self, e: Exception, obj: _CallItem) -> None: ...
|
||||
|
||||
def _get_chunks(*iterables: Any, chunksize: int) -> Generator[tuple[Any, ...], None, None]: ...
|
||||
def _process_chunk(fn: Callable[..., Any], chunk: tuple[Any, None, None]) -> Generator[Any, None, None]: ...
|
||||
def _process_chunk(fn: Callable[..., _T], chunk: Iterable[tuple[Any, ...]]) -> list[_T]: ...
|
||||
|
||||
if sys.version_info >= (3, 11):
|
||||
def _sendback_result(
|
||||
|
||||
@@ -25,7 +25,7 @@ class Command:
|
||||
def run_command(self, command: str) -> None: ...
|
||||
def get_sub_commands(self) -> list[str]: ...
|
||||
def warn(self, msg: str) -> None: ...
|
||||
def execute(self, func: Callable[..., Any], args: Iterable[Any], msg: str | None = ..., level: int = ...) -> None: ...
|
||||
def execute(self, func: Callable[..., object], args: Iterable[Any], msg: str | None = ..., level: int = ...) -> None: ...
|
||||
def mkpath(self, name: str, mode: int = ...) -> None: ...
|
||||
def copy_file(
|
||||
self,
|
||||
@@ -60,7 +60,7 @@ class Command:
|
||||
self,
|
||||
infiles: str | list[str] | tuple[str, ...],
|
||||
outfile: str,
|
||||
func: Callable[..., Any],
|
||||
func: Callable[..., object],
|
||||
args: list[Any],
|
||||
exec_msg: str | None = ...,
|
||||
skip_msg: str | None = ...,
|
||||
|
||||
@@ -126,7 +126,7 @@ class DocTestFinder:
|
||||
extraglobs: dict[str, Any] | None = ...,
|
||||
) -> list[DocTest]: ...
|
||||
|
||||
_Out: TypeAlias = Callable[[str], Any]
|
||||
_Out: TypeAlias = Callable[[str], object]
|
||||
|
||||
class DocTestRunner:
|
||||
DIVIDER: str
|
||||
@@ -201,8 +201,8 @@ class DocTestCase(unittest.TestCase):
|
||||
self,
|
||||
test: DocTest,
|
||||
optionflags: int = ...,
|
||||
setUp: Callable[[DocTest], Any] | None = ...,
|
||||
tearDown: Callable[[DocTest], Any] | None = ...,
|
||||
setUp: Callable[[DocTest], object] | None = ...,
|
||||
tearDown: Callable[[DocTest], object] | None = ...,
|
||||
checker: OutputChecker | None = ...,
|
||||
) -> None: ...
|
||||
def setUp(self) -> None: ...
|
||||
|
||||
@@ -90,22 +90,22 @@ class FTP:
|
||||
def ntransfercmd(self, cmd: str, rest: int | str | None = ...) -> tuple[socket, int]: ...
|
||||
def transfercmd(self, cmd: str, rest: int | str | None = ...) -> socket: ...
|
||||
def retrbinary(
|
||||
self, cmd: str, callback: Callable[[bytes], Any], blocksize: int = ..., rest: int | str | None = ...
|
||||
self, cmd: str, callback: Callable[[bytes], object], blocksize: int = ..., rest: int | str | None = ...
|
||||
) -> str: ...
|
||||
def storbinary(
|
||||
self,
|
||||
cmd: str,
|
||||
fp: SupportsRead[bytes],
|
||||
blocksize: int = ...,
|
||||
callback: Callable[[bytes], Any] | None = ...,
|
||||
callback: Callable[[bytes], object] | None = ...,
|
||||
rest: int | str | None = ...,
|
||||
) -> str: ...
|
||||
def retrlines(self, cmd: str, callback: Callable[[str], Any] | None = ...) -> str: ...
|
||||
def storlines(self, cmd: str, fp: SupportsReadline[bytes], callback: Callable[[bytes], Any] | None = ...) -> str: ...
|
||||
def retrlines(self, cmd: str, callback: Callable[[str], object] | None = ...) -> str: ...
|
||||
def storlines(self, cmd: str, fp: SupportsReadline[bytes], callback: Callable[[bytes], object] | None = ...) -> str: ...
|
||||
def acct(self, password: str) -> str: ...
|
||||
def nlst(self, *args: str) -> list[str]: ...
|
||||
# Technically only the last arg can be a Callable but ...
|
||||
def dir(self, *args: str | Callable[[str], None]) -> None: ...
|
||||
def dir(self, *args: str | Callable[[str], object]) -> None: ...
|
||||
def mlsd(self, path: str = ..., facts: Iterable[str] = ...) -> Iterator[tuple[str, dict[str, str]]]: ...
|
||||
def rename(self, fromname: str, toname: str) -> str: ...
|
||||
def delete(self, filename: str) -> str: ...
|
||||
|
||||
@@ -28,7 +28,7 @@ if sys.version_info >= (3, 8):
|
||||
if sys.version_info >= (3, 9):
|
||||
__all__ += ["cache"]
|
||||
|
||||
_AnyCallable: TypeAlias = Callable[..., Any]
|
||||
_AnyCallable: TypeAlias = Callable[..., object]
|
||||
|
||||
_T = TypeVar("_T")
|
||||
_S = TypeVar("_S")
|
||||
|
||||
@@ -9,7 +9,9 @@ _S = TypeVar("_S")
|
||||
|
||||
__about__: str
|
||||
|
||||
def merge(*iterables: Iterable[_S], key: Callable[[_S], Any] | None = ..., reverse: bool = ...) -> Iterable[_S]: ...
|
||||
def merge(
|
||||
*iterables: Iterable[_S], key: Callable[[_S], SupportsRichComparison] | None = ..., reverse: bool = ...
|
||||
) -> Iterable[_S]: ...
|
||||
def nlargest(n: int, iterable: Iterable[_S], key: Callable[[_S], SupportsRichComparison] | None = ...) -> list[_S]: ...
|
||||
def nsmallest(n: int, iterable: Iterable[_S], key: Callable[[_S], SupportsRichComparison] | None = ...) -> list[_S]: ...
|
||||
def _heapify_max(__x: list[Any]) -> None: ... # undocumented
|
||||
|
||||
@@ -8,6 +8,8 @@ _NL: TypeAlias = Node | Leaf
|
||||
_Context: TypeAlias = tuple[str, int, int]
|
||||
_Results: TypeAlias = dict[str, _NL]
|
||||
_RawNode: TypeAlias = tuple[int, str, _Context, list[_NL] | None]
|
||||
# This alias isn't used in this file,
|
||||
# but is imported in other lib2to3 submodules
|
||||
_Convert: TypeAlias = Callable[[Grammar, _RawNode], Any]
|
||||
|
||||
HUGE: int
|
||||
|
||||
@@ -754,7 +754,7 @@ def utime(
|
||||
follow_symlinks: bool = ...,
|
||||
) -> None: ...
|
||||
|
||||
_OnError: TypeAlias = Callable[[OSError], Any]
|
||||
_OnError: TypeAlias = Callable[[OSError], object]
|
||||
|
||||
def walk(
|
||||
top: GenericPath[AnyStr], topdown: bool = ..., onerror: _OnError | None = ..., followlinks: bool = ...
|
||||
@@ -974,7 +974,7 @@ if sys.version_info >= (3, 8):
|
||||
if sys.platform == "win32":
|
||||
class _AddedDllDirectory:
|
||||
path: str | None
|
||||
def __init__(self, path: str | None, cookie: _T, remove_dll_directory: Callable[[_T], Any]) -> None: ...
|
||||
def __init__(self, path: str | None, cookie: _T, remove_dll_directory: Callable[[_T], object]) -> None: ...
|
||||
def close(self) -> None: ...
|
||||
def __enter__(self: Self) -> Self: ...
|
||||
def __exit__(self, *args: object) -> None: ...
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
import sys
|
||||
from collections.abc import Callable
|
||||
from typing import Any, NamedTuple
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
__all__ = ["scheduler"]
|
||||
|
||||
_ActionCallback: TypeAlias = Callable[..., Any]
|
||||
|
||||
if sys.version_info >= (3, 10):
|
||||
class Event(NamedTuple):
|
||||
time: float
|
||||
priority: Any
|
||||
sequence: int
|
||||
action: Callable[..., Any]
|
||||
action: _ActionCallback
|
||||
argument: tuple[Any, ...]
|
||||
kwargs: dict[str, Any]
|
||||
|
||||
@@ -17,7 +20,7 @@ else:
|
||||
class Event(NamedTuple):
|
||||
time: float
|
||||
priority: Any
|
||||
action: Callable[..., Any]
|
||||
action: _ActionCallback
|
||||
argument: tuple[Any, ...]
|
||||
kwargs: dict[str, Any]
|
||||
|
||||
@@ -27,20 +30,10 @@ class scheduler:
|
||||
|
||||
def __init__(self, timefunc: Callable[[], float] = ..., delayfunc: Callable[[float], object] = ...) -> None: ...
|
||||
def enterabs(
|
||||
self,
|
||||
time: float,
|
||||
priority: Any,
|
||||
action: Callable[..., Any],
|
||||
argument: tuple[Any, ...] = ...,
|
||||
kwargs: dict[str, Any] = ...,
|
||||
self, time: float, priority: Any, action: _ActionCallback, argument: tuple[Any, ...] = ..., kwargs: dict[str, Any] = ...
|
||||
) -> Event: ...
|
||||
def enter(
|
||||
self,
|
||||
delay: float,
|
||||
priority: Any,
|
||||
action: Callable[..., Any],
|
||||
argument: tuple[Any, ...] = ...,
|
||||
kwargs: dict[str, Any] = ...,
|
||||
self, delay: float, priority: Any, action: _ActionCallback, argument: tuple[Any, ...] = ..., kwargs: dict[str, Any] = ...
|
||||
) -> Event: ...
|
||||
def run(self, blocking: bool = ...) -> float | None: ...
|
||||
def cancel(self, event: Event) -> None: ...
|
||||
|
||||
@@ -82,17 +82,15 @@ else:
|
||||
ignore_dangling_symlinks: bool = ...,
|
||||
) -> _PathReturn: ...
|
||||
|
||||
_OnErrorCallback: TypeAlias = Callable[[Callable[..., Any], Any, Any], object]
|
||||
|
||||
if sys.version_info >= (3, 11):
|
||||
def rmtree(
|
||||
path: StrOrBytesPath,
|
||||
ignore_errors: bool = ...,
|
||||
onerror: Callable[[Any, Any, Any], Any] | None = ...,
|
||||
*,
|
||||
dir_fd: int | None = ...,
|
||||
path: StrOrBytesPath, ignore_errors: bool = ..., onerror: _OnErrorCallback | None = ..., *, dir_fd: int | None = ...
|
||||
) -> None: ...
|
||||
|
||||
else:
|
||||
def rmtree(path: StrOrBytesPath, ignore_errors: bool = ..., onerror: Callable[[Any, Any, Any], Any] | None = ...) -> None: ...
|
||||
def rmtree(path: StrOrBytesPath, ignore_errors: bool = ..., onerror: _OnErrorCallback | None = ...) -> None: ...
|
||||
|
||||
_CopyFn: TypeAlias = Callable[[str, str], object] | Callable[[StrPath, StrPath], object]
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ class Telnet:
|
||||
def read_lazy(self) -> bytes: ...
|
||||
def read_very_lazy(self) -> bytes: ...
|
||||
def read_sb_data(self) -> bytes: ...
|
||||
def set_option_negotiation_callback(self, callback: Callable[[socket.socket, bytes, bytes], Any] | None) -> None: ...
|
||||
def set_option_negotiation_callback(self, callback: Callable[[socket.socket, bytes, bytes], object] | None) -> None: ...
|
||||
def process_rawq(self) -> None: ...
|
||||
def rawq_getchar(self) -> bytes: ...
|
||||
def fill_rawq(self) -> None: ...
|
||||
|
||||
@@ -75,7 +75,7 @@ class Thread:
|
||||
def __init__(
|
||||
self,
|
||||
group: None = ...,
|
||||
target: Callable[..., Any] | None = ...,
|
||||
target: Callable[..., object] | None = ...,
|
||||
name: str | None = ...,
|
||||
args: Iterable[Any] = ...,
|
||||
kwargs: Mapping[str, Any] | None = ...,
|
||||
@@ -171,7 +171,7 @@ class Timer(Thread):
|
||||
def __init__(
|
||||
self,
|
||||
interval: float,
|
||||
function: Callable[..., Any],
|
||||
function: Callable[..., object],
|
||||
args: Iterable[Any] | None = ...,
|
||||
kwargs: Mapping[str, Any] | None = ...,
|
||||
) -> None: ...
|
||||
|
||||
@@ -5,7 +5,7 @@ from typing_extensions import TypeAlias
|
||||
__all__ = ["Timer", "timeit", "repeat", "default_timer"]
|
||||
|
||||
_Timer: TypeAlias = Callable[[], float]
|
||||
_Stmt: TypeAlias = str | Callable[[], Any]
|
||||
_Stmt: TypeAlias = str | Callable[[], object]
|
||||
|
||||
default_timer: _Timer
|
||||
|
||||
@@ -16,7 +16,7 @@ class Timer:
|
||||
def print_exc(self, file: IO[str] | None = ...) -> None: ...
|
||||
def timeit(self, number: int = ...) -> float: ...
|
||||
def repeat(self, repeat: int = ..., number: int = ...) -> list[float]: ...
|
||||
def autorange(self, callback: Callable[[int, float], Any] | None = ...) -> tuple[int, float]: ...
|
||||
def autorange(self, callback: Callable[[int, float], object] | None = ...) -> tuple[int, float]: ...
|
||||
|
||||
def timeit(
|
||||
stmt: _Stmt = ..., setup: _Stmt = ..., timer: _Timer = ..., number: int = ..., globals: dict[str, Any] | None = ...
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from _typeshed.wsgi import ErrorStream, InputStream, WSGIApplication
|
||||
from collections.abc import Callable, Iterable, Iterator
|
||||
from typing import Any, NoReturn
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
__all__ = ["validator"]
|
||||
|
||||
@@ -25,9 +26,11 @@ class ErrorWrapper:
|
||||
def writelines(self, seq: Iterable[str]) -> None: ...
|
||||
def close(self) -> NoReturn: ...
|
||||
|
||||
_WriterCallback: TypeAlias = Callable[[bytes], Any]
|
||||
|
||||
class WriteWrapper:
|
||||
writer: Callable[[bytes], Any]
|
||||
def __init__(self, wsgi_writer: Callable[[bytes], Any]) -> None: ...
|
||||
writer: _WriterCallback
|
||||
def __init__(self, wsgi_writer: _WriterCallback) -> None: ...
|
||||
def __call__(self, s: bytes) -> None: ...
|
||||
|
||||
class PartialIteratorWrapper:
|
||||
|
||||
@@ -325,7 +325,7 @@ if sys.version_info >= (3, 8):
|
||||
class C14NWriterTarget:
|
||||
def __init__(
|
||||
self,
|
||||
write: Callable[[str], Any],
|
||||
write: Callable[[str], object],
|
||||
*,
|
||||
with_comments: bool = ...,
|
||||
strip_text: bool = ...,
|
||||
|
||||
Reference in New Issue
Block a user