From 8ef6602e25d563146d3f513f9201d927ec31c07e Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Mon, 4 Jul 2022 09:29:47 +0100 Subject: [PATCH] Third-party stubs: audit more `Callable[, Any]` annotations (#8233) --- stubs/aws-xray-sdk/aws_xray_sdk/core/recorder.pyi | 2 +- stubs/invoke/invoke/util.pyi | 4 ++-- stubs/opentracing/opentracing/harness/scope_check.pyi | 3 +-- stubs/paramiko/paramiko/dsskey.pyi | 4 ++-- stubs/paramiko/paramiko/ecdsakey.pyi | 2 +- stubs/paramiko/paramiko/rsakey.pyi | 4 ++-- stubs/paramiko/paramiko/sftp_client.pyi | 4 ++-- stubs/psutil/psutil/__init__.pyi | 2 +- stubs/pysftp/pysftp/__init__.pyi | 4 ++-- stubs/python-nmap/nmap/nmap.pyi | 2 +- stubs/six/six/__init__.pyi | 2 +- stubs/waitress/waitress/runner.pyi | 2 +- 12 files changed, 17 insertions(+), 18 deletions(-) diff --git a/stubs/aws-xray-sdk/aws_xray_sdk/core/recorder.pyi b/stubs/aws-xray-sdk/aws_xray_sdk/core/recorder.pyi index be2b49b62f60..7cfbf5b172eb 100644 --- a/stubs/aws-xray-sdk/aws_xray_sdk/core/recorder.pyi +++ b/stubs/aws-xray-sdk/aws_xray_sdk/core/recorder.pyi @@ -77,7 +77,7 @@ class AWSXRayRecorder: kwargs: dict[str, Any], name: str, namespace: str, - meta_processor: Callable[..., Any], + meta_processor: Callable[..., object], ) -> Any: ... @property def enabled(self) -> bool: ... diff --git a/stubs/invoke/invoke/util.pyi b/stubs/invoke/invoke/util.pyi index 7b08fef8e188..d010b60300cc 100644 --- a/stubs/invoke/invoke/util.pyi +++ b/stubs/invoke/invoke/util.pyi @@ -16,14 +16,14 @@ def cd(where: str) -> AbstractContextManager[None]: ... def has_fileno(stream) -> bool: ... def isatty(stream) -> bool: ... def encode_output(string: str, encoding: str) -> str: ... -def helpline(obj: Callable[..., Any]) -> str | None: ... +def helpline(obj: Callable[..., object]) -> str | None: ... class ExceptionHandlingThread(threading.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 = ..., diff --git a/stubs/opentracing/opentracing/harness/scope_check.pyi b/stubs/opentracing/opentracing/harness/scope_check.pyi index dd7618a0a969..10b5ce11d39e 100644 --- a/stubs/opentracing/opentracing/harness/scope_check.pyi +++ b/stubs/opentracing/opentracing/harness/scope_check.pyi @@ -1,11 +1,10 @@ from collections.abc import Callable -from typing import Any from ..scope_manager import ScopeManager class ScopeCompatibilityCheckMixin: def scope_manager(self) -> ScopeManager: ... - def run_test(self, test_fn: Callable[[Any], Any]) -> None: ... + def run_test(self, test_fn: Callable[[], object]) -> None: ... def test_missing_active_external(self) -> None: ... def test_missing_active(self) -> None: ... def test_activate(self) -> None: ... diff --git a/stubs/paramiko/paramiko/dsskey.pyi b/stubs/paramiko/paramiko/dsskey.pyi index 587347e5fb61..f98c69f5191e 100644 --- a/stubs/paramiko/paramiko/dsskey.pyi +++ b/stubs/paramiko/paramiko/dsskey.pyi @@ -1,5 +1,5 @@ from collections.abc import Callable -from typing import IO, Any +from typing import IO from paramiko.message import Message from paramiko.pkey import PKey @@ -31,4 +31,4 @@ class DSSKey(PKey): def write_private_key_file(self, filename: str, password: str | None = ...) -> None: ... def write_private_key(self, file_obj: IO[str], password: str | None = ...) -> None: ... @staticmethod - def generate(bits: int = ..., progress_func: Callable[..., Any] | None = ...) -> DSSKey: ... + def generate(bits: int = ..., progress_func: Callable[..., object] | None = ...) -> DSSKey: ... diff --git a/stubs/paramiko/paramiko/ecdsakey.pyi b/stubs/paramiko/paramiko/ecdsakey.pyi index 7eae8ef2219d..e5ff63c6b9ca 100644 --- a/stubs/paramiko/paramiko/ecdsakey.pyi +++ b/stubs/paramiko/paramiko/ecdsakey.pyi @@ -50,5 +50,5 @@ class ECDSAKey(PKey): def write_private_key(self, file_obj: IO[str], password: str | None = ...) -> None: ... @classmethod def generate( - cls, curve: EllipticCurve = ..., progress_func: Callable[..., Any] | None = ..., bits: int | None = ... + cls, curve: EllipticCurve = ..., progress_func: Callable[..., object] | None = ..., bits: int | None = ... ) -> ECDSAKey: ... diff --git a/stubs/paramiko/paramiko/rsakey.pyi b/stubs/paramiko/paramiko/rsakey.pyi index f71014f0ec62..477ac328ab77 100644 --- a/stubs/paramiko/paramiko/rsakey.pyi +++ b/stubs/paramiko/paramiko/rsakey.pyi @@ -1,5 +1,5 @@ from collections.abc import Callable -from typing import IO, Any +from typing import IO from cryptography.hazmat.primitives.asymmetric.rsa import RSAPrivateKey, RSAPublicKey, RSAPublicNumbers from paramiko.message import Message @@ -31,4 +31,4 @@ class RSAKey(PKey): def write_private_key_file(self, filename: str, password: str | None = ...) -> None: ... def write_private_key(self, file_obj: IO[str], password: str | None = ...) -> None: ... @staticmethod - def generate(bits: int, progress_func: Callable[..., Any] | None = ...) -> RSAKey: ... + def generate(bits: int, progress_func: Callable[..., object] | None = ...) -> RSAKey: ... diff --git a/stubs/paramiko/paramiko/sftp_client.pyi b/stubs/paramiko/paramiko/sftp_client.pyi index 3ca463b556cd..ebaa92cb7ca4 100644 --- a/stubs/paramiko/paramiko/sftp_client.pyi +++ b/stubs/paramiko/paramiko/sftp_client.pyi @@ -1,7 +1,7 @@ from _typeshed import Self from collections.abc import Callable, Iterator from logging import Logger -from typing import IO, Any +from typing import IO from typing_extensions import TypeAlias from paramiko.channel import Channel @@ -11,7 +11,7 @@ from paramiko.sftp_file import SFTPFile from paramiko.transport import Transport from paramiko.util import ClosingContextManager -_Callback: TypeAlias = Callable[[int, int], Any] +_Callback: TypeAlias = Callable[[int, int], object] b_slash: bytes diff --git a/stubs/psutil/psutil/__init__.pyi b/stubs/psutil/psutil/__init__.pyi index 309b25ac6d01..4c62a88997d7 100644 --- a/stubs/psutil/psutil/__init__.pyi +++ b/stubs/psutil/psutil/__init__.pyi @@ -195,7 +195,7 @@ def process_iter( attrs: list[str] | tuple[str, ...] | set[str] | frozenset[str] | None = ..., ad_value: Any | None = ... ) -> Iterator[Process]: ... def wait_procs( - procs: Iterable[Process], timeout: float | None = ..., callback: Callable[[Process], Any] | None = ... + procs: Iterable[Process], timeout: float | None = ..., callback: Callable[[Process], object] | None = ... ) -> tuple[list[Process], list[Process]]: ... def cpu_count(logical: bool = ...) -> int: ... def cpu_times(percpu: bool = ...): ... diff --git a/stubs/pysftp/pysftp/__init__.pyi b/stubs/pysftp/pysftp/__init__.pyi index 8b5b7aacdce1..89d52ead34bd 100644 --- a/stubs/pysftp/pysftp/__init__.pyi +++ b/stubs/pysftp/pysftp/__init__.pyi @@ -3,7 +3,7 @@ from collections.abc import Callable, Sequence from contextlib import AbstractContextManager from stat import S_IMODE as S_IMODE from types import TracebackType -from typing import IO, Any +from typing import IO from typing_extensions import Literal, TypeAlias import paramiko @@ -33,7 +33,7 @@ class CnOpts: def __init__(self, knownhosts: str | None = ...) -> None: ... def get_hostkey(self, host: str) -> paramiko.PKey: ... -_Callback: TypeAlias = Callable[[int, int], Any] +_Callback: TypeAlias = Callable[[int, int], object] _Path: TypeAlias = str | bytes class Connection: diff --git a/stubs/python-nmap/nmap/nmap.pyi b/stubs/python-nmap/nmap/nmap.pyi index 23b471acacfc..4b7aa0591dad 100644 --- a/stubs/python-nmap/nmap/nmap.pyi +++ b/stubs/python-nmap/nmap/nmap.pyi @@ -3,7 +3,7 @@ from typing import Any, TypeVar from typing_extensions import TypeAlias, TypedDict _T = TypeVar("_T") -_Callback: TypeAlias = Callable[[str, _Result], Any] +_Callback: TypeAlias = Callable[[str, _Result], object] class _Result(TypedDict): nmap: _ResultNmap diff --git a/stubs/six/six/__init__.pyi b/stubs/six/six/__init__.pyi index 79aaf98bae29..2189c70a3d8c 100644 --- a/stubs/six/six/__init__.pyi +++ b/stubs/six/six/__init__.pyi @@ -71,7 +71,7 @@ def assertCountEqual(self: unittest.TestCase, first: Iterable[_T], second: Itera @overload def assertRaisesRegex(self: unittest.TestCase, msg: str | None = ...) -> Any: ... @overload -def assertRaisesRegex(self: unittest.TestCase, callable_obj: Callable[..., Any], *args: Any, **kwargs: Any) -> Any: ... +def assertRaisesRegex(self: unittest.TestCase, callable_obj: Callable[..., object], *args: Any, **kwargs: Any) -> Any: ... def assertRegex( self: unittest.TestCase, text: AnyStr, expected_regex: AnyStr | Pattern[AnyStr], msg: str | None = ... ) -> None: ... diff --git a/stubs/waitress/waitress/runner.pyi b/stubs/waitress/waitress/runner.pyi index 6967c6ebbe27..f34e064f1ff3 100644 --- a/stubs/waitress/waitress/runner.pyi +++ b/stubs/waitress/waitress/runner.pyi @@ -9,4 +9,4 @@ def match(obj_name: str) -> tuple[str, str]: ... def resolve(module_name: str, object_name: str) -> Any: ... def show_help(stream: TextIOWrapper, name: str, error: str | None = ...) -> None: ... def show_exception(stream: TextIOWrapper) -> None: ... -def run(argv: Sequence[str] = ..., _serve: Callable[..., Any] = ...) -> None: ... +def run(argv: Sequence[str] = ..., _serve: Callable[..., object] = ...) -> None: ...