# Buggy code
def select(layer, event):
    """Select shapes or vertices either in select or direct select mode.

    Once selected shapes can be moved or resized, and vertices can be moved
    depending on the mode. Holding shift when resizing a shape will preserve
    the aspect ratio.
    """
    shift = "Shift" in event.modifiers
    # on press
    layer._moving_value = copy(layer._value)
    shape_under_cursor, vertex_under_cursor = layer._value
    if vertex_under_cursor is None:
        if shift and shape_under_cursor is not None:
            if shape_under_cursor in layer.selected_data:
                layer.selected_data.remove(shape_under_cursor)
                shapes = layer.selected_data
                layer._selected_box = layer.interaction_box(shapes)
            else:
                layer.selected_data.append(shape_under_cursor)
                shapes = layer.selected_data
                layer._selected_box = layer.interaction_box(shapes)
        elif shape_under_cursor is not None:
            if shape_under_cursor not in layer.selected_data:
                layer.selected_data = {shape_under_cursor}
        else:
            layer.selected_data = set()
    layer._set_highlight()
    yield

    # on move
    while event.type == "mouse_move":
        # Drag any selected shapes
        layer._move(layer.displayed_coordinates)
        yield

    # on release
    shift = "Shift" in event.modifiers
    if not layer._is_moving and not layer._is_selecting and not shift:
        if shape_under_cursor is not None:
            layer.selected_data = {shape_under_cursor}
        else:
            layer.selected_data = set()
    elif layer._is_selecting:
        layer.selected_data = layer._data_view.shapes_in_box(layer._drag_box)
        layer._is_selecting = False
        layer._set_highlight()
    layer._is_moving = False
    layer._drag_start = None
    layer._drag_box = None
    layer._fixed_vertex = None
    layer._moving_value = (None, None)
    layer._set_highlight()
    layer._update_thumbnail()


# Traceback (AttributeError)
Traceback (most recent call last):
File "/Users/yamauc0000/Documents/napari/.venv/lib/python3.7/site-packages/vispy/app/backends/_qt.py", line 447, in mousePressEvent
modifiers=self._modifiers(ev),
File "/Users/yamauc0000/Documents/napari/.venv/lib/python3.7/site-packages/vispy/app/base.py", line 181, in _vispy_mouse_press
ev = self._vispy_canvas.events.mouse_press(**kwargs)
File "/Users/yamauc0000/Documents/napari/.venv/lib/python3.7/site-packages/vispy/util/event.py", line 455, in __call__
self._invoke_callback(cb, event)
File "/Users/yamauc0000/Documents/napari/.venv/lib/python3.7/site-packages/vispy/util/event.py", line 475, in _invoke_callback
self, cb_event=(cb, event))
File "/Users/yamauc0000/Documents/napari/.venv/lib/python3.7/site-packages/vispy/util/event.py", line 471, in _invoke_callback
cb(event)
File "/Users/yamauc0000/Documents/napari/napari/_qt/qt_viewer.py", line 501, in on_mouse_press
mouse_press_callbacks(layer, event)
File "/Users/yamauc0000/Documents/napari/napari/utils/interactions.py", line 57, in mouse_press_callbacks
next(gen)
File "/Users/yamauc0000/Documents/napari/napari/layers/shapes/_shapes_mouse_bindings.py", line 31, in select
layer.selected_data.append(shape_under_cursor)
AttributeError: 'set' object has no attribute 'append'

# Fixed code
def select(layer, event):
    """Select shapes or vertices either in select or direct select mode.

    Once selected shapes can be moved or resized, and vertices can be moved
    depending on the mode. Holding shift when resizing a shape will preserve
    the aspect ratio.
    """
    shift = "Shift" in event.modifiers
    # on press
    layer._moving_value = copy(layer._value)
    shape_under_cursor, vertex_under_cursor = layer._value
    if vertex_under_cursor is None:
        if shift and shape_under_cursor is not None:
            if shape_under_cursor in layer.selected_data:
                layer.selected_data.remove(shape_under_cursor)
                shapes = layer.selected_data
                layer._selected_box = layer.interaction_box(shapes)
            else:
                layer.selected_data.add(shape_under_cursor)
                shapes = layer.selected_data
                layer._selected_box = layer.interaction_box(shapes)
        elif shape_under_cursor is not None:
            if shape_under_cursor not in layer.selected_data:
                layer.selected_data = {shape_under_cursor}
        else:
            layer.selected_data = set()
    layer._set_highlight()
    yield

    # on move
    while event.type == "mouse_move":
        # Drag any selected shapes
        layer._move(layer.displayed_coordinates)
        yield

    # on release
    shift = "Shift" in event.modifiers
    if not layer._is_moving and not layer._is_selecting and not shift:
        if shape_under_cursor is not None:
            layer.selected_data = {shape_under_cursor}
        else:
            layer.selected_data = set()
    elif layer._is_selecting:
        layer.selected_data = layer._data_view.shapes_in_box(layer._drag_box)
        layer._is_selecting = False
        layer._set_highlight()
    layer._is_moving = False
    layer._drag_start = None
    layer._drag_box = None
    layer._fixed_vertex = None
    layer._moving_value = (None, None)
    layer._set_highlight()
    layer._update_thumbnail()