fixing ruff and mypy errors

This commit is contained in:
Mose Müller 2024-08-06 08:16:20 +02:00
parent 80da96657c
commit 7ddcd97f68
3 changed files with 4 additions and 3 deletions

View File

@ -24,7 +24,7 @@ class Observable(ObservableObject):
for name, value in class_attrs.items():
if isinstance(value, property) or callable(value):
continue
elif is_descriptor(value):
if is_descriptor(value):
# Descriptors have to be stored as a class variable in another class to
# work properly. So don't make it an instance attribute.
self._initialise_new_objects(name, value)

View File

@ -80,7 +80,7 @@ class Task(pydase.DataService, Generic[P, R]):
# containing the function
if instance:
async def bound_func(*args, **kwargs) -> R | None:
async def bound_func(*args: P.args, **kwargs: P.kwargs) -> R | None:
return await self._func(instance, *args, **kwargs)
self._bound_func = bound_func

View File

@ -197,6 +197,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):
def is_descriptor(obj: object) -> bool:
"""Check if an object is a descriptor."""
return any(hasattr(obj, method) for method in ("__get__", "__set__", "__delete__"))