Skip to content

Commit

Permalink
Ensure reference is resolved when passing options to from_param (#6762)
Browse files Browse the repository at this point in the history
* Ensure reference is resolved when passing options to from_param

* Fix resolution
  • Loading branch information
philippjfr committed Apr 24, 2024
1 parent 900fb09 commit ec4a4b3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion panel/param.py
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ def action(event):
watchers.append(self.object.param.watch(link, p_name, 'step'))
watchers.append(self.object.param.watch(link, p_name))

options = kwargs.get('options', [])
options = resolve_value(kwargs.get('options', []), recursive=False)
if isinstance(options, dict):
options = options.values()
if ((is_parameterized(value) or any(is_parameterized(o) for o in options))
Expand Down
18 changes: 18 additions & 0 deletions panel/tests/test_param.py
Original file line number Diff line number Diff line change
Expand Up @@ -1646,6 +1646,24 @@ class Test(param.Parameterized):
assert w.value == (1, 2)


def test_from_param_with_ref_as_option():
class Test(param.Parameterized):
s = param.String(default='A')

@param.depends('s')
def ref(self):
return [self.s] + ['B']

t = Test()
w = AutocompleteInput.from_param(t.param.s, options=t.ref)

assert w.options == ['A', 'B']

t.s = 'C'

assert w.options == ['C', 'B']


def test_paramfunction_bare_emits_warning(caplog):

def foo():
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def run(self):

install_requires = [
'bokeh >=3.4.0,<3.5.0',
'param >=2.0.0,<3.0',
'param >=2.1.0,<3.0',
'pyviz_comms >=2.0.0',
'xyzservices >=2021.09.1', # Bokeh dependency, but pyodide 23.0.0 does not always pick it up
'markdown',
Expand Down

0 comments on commit ec4a4b3

Please sign in to comment.