mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-07 16:31:37 +00:00
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:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user