From 3a4dfbc4751c0abe5d3333e77597d332f53d2b6b Mon Sep 17 00:00:00 2001 From: Sveinung Gundersen Date: Mon, 9 Dec 2024 21:49:29 +0100 Subject: [PATCH] Callable[[Any] -> Callable[... --- src/omnipy/api/protocols/public/data.py | 2 +- src/omnipy/data/serializer.py | 2 +- src/omnipy/util/publisher.py | 6 +++--- tests/compute/cases/flows.py | 4 ++-- tests/compute/cases/tasks.py | 4 ++-- tests/data/test_model.py | 2 +- tests/engine/helpers/classes.py | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/omnipy/api/protocols/public/data.py b/src/omnipy/api/protocols/public/data.py index 414b1523..8bd5cbf0 100644 --- a/src/omnipy/api/protocols/public/data.py +++ b/src/omnipy/api/protocols/public/data.py @@ -90,7 +90,7 @@ class IsTarFileSerializer(IsSerializer, Protocol): @classmethod def create_tarfile_from_dataset(cls, dataset: IsDataset, - data_encode_func: Callable[[Any], bytes | memoryview]) -> bytes: + data_encode_func: Callable[..., bytes | memoryview]) -> bytes: """""" ... diff --git a/src/omnipy/data/serializer.py b/src/omnipy/data/serializer.py index d4515093..92fc92e8 100644 --- a/src/omnipy/data/serializer.py +++ b/src/omnipy/data/serializer.py @@ -47,7 +47,7 @@ class TarFileSerializer(Serializer): @classmethod def create_tarfile_from_dataset(cls, dataset: IsDataset, - data_encode_func: Callable[[Any], bytes | memoryview]) -> bytes: + data_encode_func: Callable[..., bytes | memoryview]) -> bytes: bytes_io = BytesIO() with tarfile.open(fileobj=bytes_io, mode='w:gz') as tarfile_stream: for data_file, data in dataset.items(): # type: ignore[attr-defined] diff --git a/src/omnipy/util/publisher.py b/src/omnipy/util/publisher.py index ae271803..662aff1e 100644 --- a/src/omnipy/util/publisher.py +++ b/src/omnipy/util/publisher.py @@ -1,6 +1,6 @@ from collections import defaultdict from dataclasses import dataclass, field -from typing import Any, Callable, DefaultDict +from typing import Callable, DefaultDict from omnipy.api.protocols.public.hub import IsRuntime @@ -11,9 +11,9 @@ def _subscribers_factory(): @dataclass class DataPublisher: - _self_subscriptions: list[Callable[[Any], None]] = field( + _self_subscriptions: list[Callable[..., None]] = field( default_factory=list, init=False, repr=False) - _attr_subscriptions: DefaultDict[str, list[Callable[[Any], None]]] = \ + _attr_subscriptions: DefaultDict[str, list[Callable[..., None]]] = \ field(default_factory=_subscribers_factory, init=False, repr=False) def subscribe_attr(self, attr_name: str, callback_fun: Callable[..., None]): diff --git a/tests/compute/cases/flows.py b/tests/compute/cases/flows.py index 87292a94..86a71141 100644 --- a/tests/compute/cases/flows.py +++ b/tests/compute/cases/flows.py @@ -23,8 +23,8 @@ class FlowCase(Generic[CallP, RetT]): flow_template: IsLinearFlowTemplate | IsDagFlowTemplate | IsFuncFlowTemplate args: tuple[Any, ...] kwargs: dict[str, Any] - assert_results_func: Callable[[Any], None] - # assert_signature_and_return_type_func: Callable[[Any], None] + assert_results_func: Callable[..., None] + # assert_signature_and_return_type_func: Callable[..., None] # TODO: Add assert_signature_and_return_type_func diff --git a/tests/compute/cases/tasks.py b/tests/compute/cases/tasks.py index f6fb0bc9..e0d2e2b6 100644 --- a/tests/compute/cases/tasks.py +++ b/tests/compute/cases/tasks.py @@ -27,8 +27,8 @@ class TaskCase(Generic[CallP, RetT]): task_func: Callable[CallP, RetT] args: tuple[Any, ...] kwargs: dict[str, Any] - assert_results_func: Callable[[Any], None] - assert_signature_and_return_type_func: Callable[[Any], None] + assert_results_func: Callable[..., None] + assert_signature_and_return_type_func: Callable[..., None] @pc.case( diff --git a/tests/data/test_model.py b/tests/data/test_model.py index 4cef8c2f..991e298e 100644 --- a/tests/data/test_model.py +++ b/tests/data/test_model.py @@ -1847,7 +1847,7 @@ def test_weakly_referenced_snapshot_deepcopy_memo_entry( class ModelCase: new_model_func: Callable[[], Model] deepcopy_memo_count: int - contents_modify_func: Callable[[Any], None] + contents_modify_func: Callable[..., None] target_contents: Any diff --git a/tests/engine/helpers/classes.py b/tests/engine/helpers/classes.py index 6b99036f..bd80d879 100644 --- a/tests/engine/helpers/classes.py +++ b/tests/engine/helpers/classes.py @@ -27,7 +27,7 @@ class JobType(Enum): class JobCase(Generic[ArgT, ReturnT]): name: str job_func: Callable[[ArgT], ReturnT] - run_and_assert_results_func: Callable[[Any], None] | Awaitable[Callable[[Any], None]] + run_and_assert_results_func: Callable[..., None] | Awaitable[Callable[..., None]] job_type: JobType | None = None job: IsJob | None = None