Page MenuHome

Documentation inconsistency for VertexGroup.remove
Closed, ResolvedPublic

Description

Blender Version
Broken: 2.83
Worked: Never

Short description of error

The VertexGroup.remove method says it expects index, with the description "Remove a vertex from the group". In actuality, though, it expects a sequence and will throw an error if an index is passed.

I believe the more consistent behavior with the rest of the Python API would be for this function to expect a single integer, but I would also be happy with the documentation updating to reflect its current behavior (though if this were to be the case, I think the method would need a new name).

Exact steps for others to reproduce the error

  1. Open the default blend file
  2. With the cube selected & active, add a new vertex group
  3. In edit mode, assign all of the Cube vertices to the new vertex group.
  4. In the Python console, type the following: C.object.vertex_groups[0].remove(0)

Event Timeline

Campbell Barton (campbellbarton) added a project: Restricted Project.

I think the API is clear here it says it expects an array (list) and the description says "index list" and lists are a sequence data type. I changed the wording to "List of indices" which is a tad more specific sounding.

I am going to leave it up to the Python API if they want to support passing single int values here.
However, to me, it seems a bit unnecessary simply use a single item list: C.object.vertex_groups[0].remove([0])

Accepting both a list of items and a single item is a confusing convention as it's likely not to be followed everywhere.

The documentation should be updated to match functionality.