CustomJS and CustomJSHover --> args argument not consistent

3 line MRE:

from bokeh.models import CustomJS, CustomJSHover
cb = CustomJS(args=dict(v='something')) #fine
cbh = CustomJSHover(args=dict(v='something')) #not fine

cb instantiates no prob, but cbh raises:

Is this intended and if so why/what am I missing? Bokeh 2.4.2 if it matters.

@gmerritt123 The original motivating use-case for the args dict was specifically (and only) to be a mechanism for cloning Bokeh model objects across the Python → JS boundary. I think somewhere along the line some of the property definitions were loosened in some places, incidentally, as part of other work, which would allow more types to be passed-in in those places. There’s probably no reason CustomJSHover could not also be updated (i.e. it’s probably only the way it is now because that’s the way it was when it was first created). Please feel free to make a GitHub Issue to propose bringing all of the various args property definitions into better alignment.

Thanks, will do.

I’m gonna have to make one hell of a janky workaround in the meantime :joy:

EDIT: This would fall under feature request correct?

Yah that’s a reasonable start, we might re-tag it as a task since it is more or less just some housekeeping that has been neglected.

I’m gonna have to make one hell of a janky workaround in the meantime :joy:

FWIW a common approach in the past was to use string formatting/substitution on the text of the code block.

I was thinking using a CDS with one long columns to mimic a dictionary, which would more or less cover me:

dum = ColumnDataSource(data={'v':['something']})
cbh = CustomJSHover(args=dict(d=dum)
                    var janky_lookup =['v'][0]

That’s definitely an option. A less “janky” option would be to define a DataModel with named properties you want, then that DataModel instance could be passed in args. See:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.