Changing tile provider does not remove attribution

In reference to a previous topic on changing tile providers, I noticed that the attribution in the bottom right hand corner is not removed when changing the TileRender which leads to the attributions stacking on top of each other.

Screenshot of the issue
image

MWE below

from bokeh.plotting import figure
from bokeh.layouts import column
from bokeh.tile_providers import get_provider
from bokeh.models.renderers import TileRenderer
from bokeh.io import curdoc
from bokeh.models import RadioButtonGroup

#dictionary of TileRenders
tiles = {'Cartodb': TileRenderer(tile_source=get_provider('CARTODBPOSITRON')),
         'Esri': TileRenderer(tile_source=get_provider('ESRI_IMAGERY')),
         }

tile_labels = list(tiles.keys())

#callback
def tile_select_cb(new):
    p.renderers[0] = tiles[tile_labels[new]]

#widget for changing tiles
tile_selector = RadioButtonGroup(labels=tile_labels, active=0)
tile_selector.on_click(tile_select_cb)


p = figure(x_range=(-2000000, 6000000), y_range=(-1000000, 7000000),
           x_axis_type="mercator", y_axis_type="mercator")
p.renderers.append(tiles['Cartodb'])

layout = column(tile_selector, p, name='layout')
curdoc().add_root(layout)

This was run on a bokeh server using the following (assuming above is in mwe.py)

bokeh serve --show mwe.py --allow-websocket-origin='*'

I’m allowing the websocket origins due to running this on an Amazon EC2 Linux instance.

I have tried the callback in the topic above which suffers the same issue.

def change_tiles_callback(attr, old, new):

    #removing the renderer corresponding to the tile layer
    plot.renderers = [x for x in plot.renderers if not str(x).startswith('TileRenderer')]
    ##inserting the new tile renderer
    tile_renderer = TileRenderer(tile_source=tiles[new])
    plot.renderers.insert(0, tile_renderer)

It appears that the attribution might be stored elsewhere in the figure object but I haven’t been able to locate it easily. My questions is where is it stored and how may I modify my callback to deal with it, but also if this is intended behaviour?

Looking at tile_renderer.ts it seem like perhaps old attributions are not cleaned up or removed. So this seems like a bug. Please file a GitHub Issue with these details.