Fix for python 3.14

"In some versions of Python, instances of classes may have an
__annotations__ attribute. However, this is not supported functionality.
If you need the annotations of an instance, you can use type() to access
its class" https://docs.python.org/3/howto/annotations.html
This commit is contained in:
Bruno Postle
2026-01-03 17:53:59 +00:00
parent 93de429e03
commit 9bac66a01b
2 changed files with 10 additions and 2 deletions
+5 -1
View File
@@ -428,7 +428,11 @@ def get_enum_items(
else:
annotations_data = data
prop = annotations_data.__annotations__[prop_name]
try:
annotations = annotations_data.__annotations__
except AttributeError:
annotations = type(annotations_data).__annotations__
prop = annotations[prop_name]
items = prop.keywords.get("items")
if items is None:
return
+5 -1
View File
@@ -742,7 +742,11 @@ class Blender(bonsai.core.tool.Blender):
# Yes, accessing items through annotations is a bit hacky
# but it's the only way to get the dynamic enum items
# besides providing them to get_enum_safe explicitly.
prop_keywords = props.__annotations__[prop_name].keywords
try:
annotations = props.__annotations__
except AttributeError:
annotations = type(props).__annotations__
prop_keywords = annotations[prop_name].keywords
items = prop_keywords.get("items")
if items is None:
return None