Smart UV Project Multiple Objects to Different UV Maps
Here's the working code, thanks to batFINGER:

import bpy

selection = bpy.context.selected_objects
bpy.ops.object.select_all(action='DESELECT')

for o in selection:
    o.select_set(True)
    bpy.context.view_layer.objects.active = o
    bpy.ops.uv.smart_project()
    o.select_set(False)