Provide a base class for objects that can have declarative, typed, serializable properties.


These classes form part of the very low-level machinery that implements the Bokeh model and property system. It is unlikely that any of these classes or their methods will be applicable to any standard usage or to anyone who is not directly developing on Bokeh’s own infrastructure.

class HasProps(**properties: Any)[source]#

Base class for all class types that have Bokeh properties.

__init__(**properties: Any) None[source]#
apply_theme(property_values: dict[str, Any]) None[source]#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the HasProps instance should modify it).


property_values (dict) – theme values to use in place of defaults



clone() HasProps[source]#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated.

classmethod dataspecs() dict[str, DataSpec][source]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.


names of DataSpec properties

Return type:


classmethod descriptors() list[[Any]][source]#

List of property descriptors in the order of definition.

equals(other: HasProps) bool[source]#

Structural equality of models.


other (HasProps) – the other instance to compare to


True, if properties are structurally equal, otherwise False

classmethod lookup(name: str, *, raises: Literal[True] = True) PropertyDescriptor[Any][source]#
classmethod lookup(name: str, *, raises: Literal[False] = False) PropertyDescriptor[Any] | None

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing


descriptor for property named name

Return type:


classmethod properties(*, _with_props: Literal[False] = False) set[str][source]#
classmethod properties(*, _with_props: Literal[True] = True) dict[str, Property[Any]]

Collect the names of properties on this class.


In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.


property names

classmethod properties_with_refs() dict[str, Property[Any]][source]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.


names of properties that have references

Return type:


properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.


include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)


mapping from property names to their values

Return type:


query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Query the properties values of HasProps instances with a predicate.

  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)


mapping of property names and values for matching properties

Return type:


set_from_json(name: str, value: Any, *, setter: Setter | None = None) None[source]#

Set a property value on this object from JSON.

  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.



themed_values() dict[str, Any] | None[source]#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.


dict or None

to_serializable(serializer: Serializer) ObjectRep[source]#

Converts this object to a serializable representation.

unapply_theme() None[source]#

Remove any themed values and restore defaults.



update(**kwargs: Any) None[source]#

Updates the object’s properties from the given keyword arguments.




The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
class MetaHasProps(class_name: str, bases: tuple[type, ...], class_dict: dict[str, Any])[source]#

Specialize the construction of HasProps classes.

This class is a metaclass for HasProps that is responsible for creating and adding the PropertyDescriptor instances that delegate validation and serialization to Property attributes.

property model_class_reverse_map: dict[str, type[bokeh.core.has_props.HasProps]]#
class NonQualified[source]#

Resolve this class by a non-qualified name.

class Qualified[source]#

Resolve this class by a fully qualified name.

abstract(cls: C) C[source]#

A decorator to mark abstract base classes derived from HasProps.