From d1007fad1435f32eb913d79134ad6a98a164f2dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mose=20M=C3=BCller?= Date: Wed, 27 Mar 2024 16:51:56 +0100 Subject: [PATCH] removes unused code --- src/pydase/data_service/data_service.py | 16 ++------- src/pydase/utils/helpers.py | 43 ------------------------- 2 files changed, 2 insertions(+), 57 deletions(-) diff --git a/src/pydase/data_service/data_service.py b/src/pydase/data_service/data_service.py index eae41a1..c72c866 100644 --- a/src/pydase/data_service/data_service.py +++ b/src/pydase/data_service/data_service.py @@ -1,7 +1,7 @@ import inspect import logging from enum import Enum -from typing import Any, get_type_hints +from typing import Any import pydase.units as u from pydase.data_service.abstract_data_service import AbstractDataService @@ -10,7 +10,6 @@ from pydase.observer_pattern.observable.observable import ( Observable, ) from pydase.utils.helpers import ( - convert_arguments_to_hinted_types, get_class_and_instance_attributes, is_property_attribute, ) @@ -22,19 +21,8 @@ from pydase.utils.serialization.serializer import ( logger = logging.getLogger(__name__) -def process_callable_attribute(attr: Any, args: dict[str, Any]) -> Any: - converted_args_or_error_msg = convert_arguments_to_hinted_types( - args, get_type_hints(attr) - ) - return ( - attr(**converted_args_or_error_msg) - if not isinstance(converted_args_or_error_msg, str) - else converted_args_or_error_msg - ) - - class DataService(AbstractDataService): - def __init__(self, **kwargs: Any) -> None: + def __init__(self) -> None: super().__init__() self._task_manager = TaskManager(self) diff --git a/src/pydase/utils/helpers.py b/src/pydase/utils/helpers.py index 1b08a06..09f648f 100644 --- a/src/pydase/utils/helpers.py +++ b/src/pydase/utils/helpers.py @@ -63,49 +63,6 @@ def get_object_attr_from_path_list(target_obj: Any, path: list[str]) -> Any: return target_obj -def convert_arguments_to_hinted_types( - args: dict[str, Any], type_hints: dict[str, Any] -) -> dict[str, Any] | str: - """ - Convert the given arguments to their types hinted in the type_hints dictionary. - - This function attempts to convert each argument in the args dictionary to the type - specified for the argument in the type_hints dictionary. If the conversion is - successful, the function replaces the original argument in the args dictionary with - the converted argument. - - If a ValueError is raised during the conversion of an argument, the function logs - an error message and returns the error message as a string. - - Args: - args: A dictionary of arguments to be converted. The keys are argument names - and the values are the arguments themselves. - type_hints: A dictionary of type hints for the arguments. The keys are - argument names and the values are the hinted types. - - Returns: - A dictionary of the converted arguments if all conversions are successful, - or an error message string if a ValueError is raised during a conversion. - """ - - # Convert arguments to their hinted types - for arg_name, arg_value in args.items(): - if arg_name in type_hints: - arg_type = type_hints[arg_name] - if isinstance(arg_type, type): - # Attempt to convert the argument to its hinted type - try: - args[arg_name] = arg_type(arg_value) - except ValueError: - msg = ( - f"Failed to convert argument '{arg_name}' to type " - f"{arg_type.__name__}" - ) - logger.error(msg) - return msg - return args - - def update_value_if_changed( target: Any, attr_name_or_index: str | int, new_value: Any ) -> None: