adds is_descriptor helper method

This commit is contained in:
Mose Müller 2024-08-05 16:41:11 +02:00
parent e69ef376ae
commit 456090fee9

View File

@ -196,3 +196,7 @@ def function_has_arguments(func: Callable[..., Any]) -> bool:
# Check if there are any parameters left which would indicate additional arguments.
return len(parameters) > 0
def is_descriptor(obj):
"""Check if an object is a descriptor."""
return any(hasattr(obj, method) for method in ("__get__", "__set__", "__delete__"))