fake-bpy-module
fake-bpy-module copied to clipboard
Feature request - support typing for bmesh layers values
See example below:
import bmesh
from typing import assert_type
bm = bmesh.new()
layer = bm.verts.layers.float.verify()
deform = bm.verts.layers.deform.active
vert = bm.verts[0]
f = vert[layer]
dv = vert[deform]
# It would be nice if it could support those cases:
# "assert_type" mismatch: expected "float" but received "Any"
assert_type(f, float)
# "assert_type" mismatch: expected "BMDeformVert" but received "Any"
assert_type(dv, bmesh.types.BMDeformVert)
# Possibly by adding generics support for BMLayerItem:
assert_type(layer, bmesh.types.BMLayerItem[float])
assert_type(layer, bmesh.types.BMLayerItem[bmesh.types.BMDeformVert])
Yep, known limitation of #232 :
- Added
__getitem__(),__setitem__()and__delitem__()toBMVert,BMEdge,BMLoopandBMFace.**Presently these methods get/set
Any—to fix thisBMLayerItemneeds to be made generic (trivial), but that generic type needs to come fromBMLayerCollectionwhich also needs to be made generic, which involves modding all of its methods and uses (non-trivial), and I don't think it's currently possible to bind that generic type toBMLayerItem(but it might be after #161's work on PEP 695 is implemented?).
Created the PR to support this feature. https://projects.blender.org/blender/blender/pulls/125851
After this PR is merged, I will make some classes generic.
The PR is now merged. Then, I will start to tackle this issue from fake-bpy-module side.
This feature is now supported. Close this issue.