Is there a fast way to fill a texture mask from selected faces?

How I currently do it:

Edit mode, face select, select linked limited by UV seam
Invert selection, hide
Texture painting, paint bucket, fill with white.

I could automate this in python but I haven’t found a way to run the paint bucket with bpy.

bpy.ops.mesh.select_all(action='INVERT')
bpy.ops.mesh.hide(unselected=False)
set_context('TEXTURE_PAINT')

bpy.ops.paint.brush_select(image_tool='FILL')

strokes = [{
    "name": "",
    "location": (0, 0, 0),
    "mouse": (0, 0),
    "mouse_event": (0, 0),
    "x_tilt": 0,
    "y_tilt": 0,
    "size": 100,
    "pressure": 1,
    "pen_flip": False,
    "time": 0,
    "is_start": True
}]

bpy.ops.paint.image_paint(stroke=strokes)
set_context('EDIT')
bpy.ops.mesh.reveal()
set_context('TEXTURE_PAINT')