mirror of
https://github.com/tiqi-group/pydase.git
synced 2025-07-05 01:44:47 +02:00
updates is_descriptor to exclude false positives for methods, functions and builtins
This commit is contained in:
@ -204,6 +204,17 @@ def function_has_arguments(func: Callable[..., Any]) -> bool:
|
|||||||
|
|
||||||
def is_descriptor(obj: object) -> bool:
|
def is_descriptor(obj: object) -> bool:
|
||||||
"""Check if an object is a descriptor."""
|
"""Check if an object is a descriptor."""
|
||||||
|
|
||||||
|
# Exclude functions, methods, builtins and properties
|
||||||
|
if (
|
||||||
|
inspect.isfunction(obj)
|
||||||
|
or inspect.ismethod(obj)
|
||||||
|
or inspect.isbuiltin(obj)
|
||||||
|
or isinstance(obj, property)
|
||||||
|
):
|
||||||
|
return False
|
||||||
|
|
||||||
|
# Check if it has any descriptor methods
|
||||||
return any(hasattr(obj, method) for method in ("__get__", "__set__", "__delete__"))
|
return any(hasattr(obj, method) for method in ("__get__", "__set__", "__delete__"))
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user