Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Find inherited dependents of parameters through the MRO
_collect_dependents only scanned cls.__dict__, so subclasses of a parameters
class (such as the deprecated Scan) found no dependents and never invalidated
their cached properties. The memoised lookup made that permanent per class.
  • Loading branch information
tristan-deep committed Oct 20, 2026
commit ad53a72ce4331f60579e36aace94800acc71724d
18 changes: 18 additions & 0 deletions tests/test_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -828,3 +828,21 @@ def test_mapping_protocol(dummy_params):

del dummy_params["custom"]
assert "custom" not in dummy_params


class DummySubParameters(DummyParameters):
"""Subclass without its own computed properties, like the deprecated Scan."""


def test_subclass_invalidates_inherited_properties():
"""Dependents must be found through the MRO, not only in the subclass itself."""
assert DummySubParameters._find_all_dependents(
DummySubParameters, "param1"
) == DummyParameters._find_all_dependents(DummyParameters, "param1")

params = DummySubParameters(param1=5, param2=10, param3=1500.0, param4=5e6)
assert params.computed2[0] == 1
params.param1 = 3
assert params.computed1[0].shape == (3, 10)
params.computed2
assert params._computed2_count == 2
4 changes: 3 additions & 1 deletion zea/internal/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,9 @@ def _collect_dependents(cls, target, seen):
if target in seen:
return dependents
seen.add(target)
for name in cls.__dict__:
# Walk the MRO so subclasses (e.g. the deprecated Scan) see inherited properties
names = dict.fromkeys(name for klass in cls.__mro__ for name in vars(klass))
for name in names:
if cls._is_property_with_dependencies(name):
if target in cls._get_dependencies(name):
dependents.add(name)
Expand Down