Use descriptors to type the behavior of Blender when using `mathutils.(Vector|Color|Euler|Quaternion|Matrix).
When getting an attribute, the obtain type is the mathutils type.
But when setting an attribute, it either accepts a sequence or the type of the attribute.
When used as a function argument, we have to specify that it either accept a sequence or the mathutils type, as descriptors only apply to classes.
For Vector, Color, Euler, and Quaternion the sequence type is Sequence[float].
For Matrix the sequence type is Sequence[Sequence[float]].
Sequence[float] is used instead of list[float] | tuple[float, float, float] as it encapsulates it while still being correct.
In #158, @Road-hog123 proposed to use a protocol instead of Sequence to allow numpy arrays.
I will leave this for another PR.
Purpose of the pull request
Description about the pull request
Use descriptors to type the behavior of Blender when using `mathutils.(Vector|Color|Euler|Quaternion|Matrix). When getting an attribute, the obtain type is the mathutils type. But when setting an attribute, it either accepts a sequence or the type of the attribute.
When used as a function argument, we have to specify that it either accept a sequence or the mathutils type, as descriptors only apply to classes.
For
Vector
,Color
,Euler
, andQuaternion
the sequence type isSequence[float]
. ForMatrix
the sequence type isSequence[Sequence[float]]
.Sequence[float]
is used instead oflist[float] | tuple[float, float, float]
as it encapsulates it while still being correct.In #158, @Road-hog123 proposed to use a protocol instead of
Sequence
to allow numpy arrays. I will leave this for another PR.