mirror of
https://github.com/tiqi-group/pydase.git
synced 2025-06-05 21:20:40 +02:00
adds function_has_arguments helper function
This commit is contained in:
parent
affc63219f
commit
b2f828ff6f
@ -1,5 +1,6 @@
|
||||
import inspect
|
||||
import logging
|
||||
from collections.abc import Callable
|
||||
from itertools import chain
|
||||
from typing import Any
|
||||
|
||||
@ -196,3 +197,15 @@ def get_data_service_class_reference() -> Any:
|
||||
|
||||
def is_property_attribute(target_obj: Any, attr_name: str) -> bool:
|
||||
return isinstance(getattr(type(target_obj), attr_name, None), property)
|
||||
|
||||
|
||||
def function_has_arguments(func: Callable[..., Any]) -> bool:
|
||||
sig = inspect.signature(func)
|
||||
parameters = dict(sig.parameters)
|
||||
# Remove 'self' parameter for instance methods.
|
||||
parameters.pop("self", None)
|
||||
|
||||
# Check if there are any parameters left which would indicate additional arguments.
|
||||
if len(parameters) > 0:
|
||||
return True
|
||||
return False
|
||||
|
Loading…
x
Reference in New Issue
Block a user