fake-bpy-module
fake-bpy-module copied to clipboard
`Vector` - cannot convert to tuple / list / use slices
trafficstars
See example below - typing errors converting Vector to tuple/list/use slices though it is actually possible.
from mathutils import Vector
from typing import assert_type
v = Vector()
# Argument of type "Vector" cannot be assigned to parameter "iterable" of type "Iterable[_T_co@tuple]" in function "__new__"
# "Vector" is incompatible with protocol "Iterable[_T_co@tuple]"
# "__iter__" is not present
l = list(v)
assert_type(list(v), list[float])
t = tuple(v)
assert_type(t, tuple[float, ...])
# Argument of type "slice" cannot be assigned to parameter "key" of type "int" in function "__getitem__"
# "slice" is incompatible with "int"
sl = v[:3]
assert_type(sl, tuple[float, ...])
sl2 = v[:2]
# Ideally this also should work since Vector size is always >= 2
# but not sure if it's possible.
assert_type(sl2, tuple[float, float])