Skip to content

Commit

Permalink
clean up values stored on the class private namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
maximlt committed Jul 12, 2023
1 parent 077afd4 commit 3617839
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
11 changes: 8 additions & 3 deletions param/parameterized.py
Original file line number Diff line number Diff line change
Expand Up @@ -3755,9 +3755,14 @@ class Foo(Parameterized):
def __init__(self, **params):
global object_count

self._param__private = _InstancePrivate(
values=type(self)._param__private.values.copy()
)
# Setting a Parameter in an __init__ block before calling super().__init__
# fills `values` on the class private namespace, that has to be passed
# to the instance private namespace. `values` on the class is cleared
# as it's only meant to be transient data.
values = type(self)._param__private.values
cvalues = values.copy()
values.clear()
self._param__private = _InstancePrivate(values=cvalues)
self._param_watchers = {}

# Skip generating a custom instance name when a class in the hierarchy
Expand Down
1 change: 1 addition & 0 deletions tests/testparameterizedobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ def cb(self):

assert p.x == 1
assert count == 0
assert not P._param__private.values

@pytest.mark.xfail(
raises=AttributeError,
Expand Down

0 comments on commit 3617839

Please sign in to comment.