diff --git a/tests/test_descriptor.py b/tests/test_descriptor.py index c6173a6..5a0a43e 100644 --- a/tests/test_descriptor.py +++ b/tests/test_descriptor.py @@ -184,8 +184,8 @@ def test_descriptor_metadata(): class WithSetAttr: """Modify the value before saving it.""" - value = Descriptor(on_setattr=lambda self, value: value + 1) - value_frozen = Descriptor(frozen=True, on_setattr=lambda self, value: value + 1) + value = Descriptor(on_setattr=lambda value: value + 1) + value_frozen = Descriptor(frozen=True, on_setattr=lambda value: value + 1) def test_with_setattr(): diff --git a/zninit/descriptor/__init__.py b/zninit/descriptor/__init__.py index fb94e14..c372d7c 100644 --- a/zninit/descriptor/__init__.py +++ b/zninit/descriptor/__init__.py @@ -170,7 +170,7 @@ def __set__(self, instance, value): if self._frozen.get(instance, False): raise TypeError(f"Frozen attribute '{self.name}' can not be changed.") if self.on_setattr is not None: - value = self.on_setattr(instance, value) + value = self.on_setattr(value) if self.check_types: typeguard.check_type( argname=self.name, value=value, expected_type=self.annotation