From what I’m seeing, there doesn’t appear to be a way to do it, unless I’m missing something?
A script I’m currently working on needs to stay in edit mode, but it also needs to add verts to a vertex group. vertex_group.add() doesn’t work in edit mode where bpy.ops.object.vertex_group_assign() ONLY works in edit mode (but requires you to change the selection).
I feel like I have two hacky solutions available- I could drop out of edit mode, set the vertex group indices, go back to edit mode (rebuild my bmesh, etc). Or the lesser of two evils- I could cache the current selection, select the verts needed, run object.vertex_group_assign(), then restore the original selection.
While either of those technically work, I wonder why there isn’t a more direct way to work with vertex groups within the python API? bmesh seems to be a smart candidate for this, it would be consistent with how face maps, uvs, vertex colors, and just about everything else are manipulated while in edit mode.