More python 3.14 fixes, see 9bac66a

This commit is contained in:
Bruno Postle
2026-01-03 21:58:05 +00:00
parent 9bac66a01b
commit c20ed44a0f
3 changed files with 35 additions and 7 deletions
+15 -3
View File
@@ -837,7 +837,11 @@ class BIM_ADDON_preferences(bpy.types.AddonPreferences):
gizmo_prop_names = {p.attr_name for p in GizmoDoorEdition.dimension_gizmo_props}
# Add special gizmos not in dimension_gizmo_props
gizmo_prop_names.update(("swing_arc", "flip_arc"))
for prop in door_gizmos.__annotations__:
try:
annotations = door_gizmos.__annotations__
except AttributeError:
annotations = type(door_gizmos).__annotations__
for prop in annotations:
if prop in gizmo_prop_names:
layout.prop(door_gizmos, prop)
@@ -846,7 +850,11 @@ class BIM_ADDON_preferences(bpy.types.AddonPreferences):
window_gizmos = self.gizmos.window
gizmo_prop_names = {p.attr_name for p in GizmoWindowEdition.dimension_gizmo_props}
for prop in window_gizmos.__annotations__:
try:
annotations = window_gizmos.__annotations__
except AttributeError:
annotations = type(window_gizmos).__annotations__
for prop in annotations:
if prop in gizmo_prop_names:
layout.prop(window_gizmos, prop)
@@ -857,7 +865,11 @@ class BIM_ADDON_preferences(bpy.types.AddonPreferences):
gizmo_prop_names = {p.attr_name for p in GizmoStairEdition.dimension_gizmo_props}
# Add special gizmos not in dimension_gizmo_props
special_gizmo_names = {"lock", "plus", "minus", "cycle"}
for prop in stair_gizmos.__annotations__:
try:
annotations = stair_gizmos.__annotations__
except AttributeError:
annotations = type(stair_gizmos).__annotations__
for prop in annotations:
if prop in gizmo_prop_names or prop in special_gizmo_names:
layout.prop(stair_gizmos, prop)
+10 -2
View File
@@ -553,7 +553,11 @@ class Snap(bonsai.core.tool.Snap):
def filter_snapping_points_by_type(snapping_points):
options = ["Plane", "Axis"]
props = tool.Snap.get_snap_props()
for prop in props.__annotations__.keys():
try:
annotations = props.__annotations__
except AttributeError:
annotations = type(props).__annotations__
for prop in annotations.keys():
if getattr(props, prop):
options.append(props.rna_type.properties[prop].name)
@@ -563,7 +567,11 @@ class Snap(bonsai.core.tool.Snap):
def filter_snapping_points_by_group(detected_snaps):
options = ["Wireframe", "Axis", "Plane"]
props = tool.Snap.get_snap_groups()
for prop in props.__annotations__.keys():
try:
annotations = props.__annotations__
except AttributeError:
annotations = type(props).__annotations__
for prop in annotations.keys():
if getattr(props, prop):
options.append(props.rna_type.properties[prop].name)
filtered_groups = [group for group in detected_snaps if group["group"] in options]
+10 -2
View File
@@ -96,7 +96,11 @@ class PanelSpy:
def __getattr__(self, attr: str) -> PanelSpy | Any:
self.spied_attr = attr
if annotation := self.blender_panel.__annotations__.get(attr, None):
try:
annotations = self.blender_panel.__annotations__
except AttributeError:
annotations = type(self.blender_panel).__annotations__
if annotation := annotations.get(attr, None):
return annotation.keywords.get("default", None) # An operator property
if attr == "layout":
return self
@@ -136,7 +140,11 @@ class PanelSpy:
prop_type = props.bl_rna.properties[name].type
enum_items = []
if prop_type == "ENUM":
prop_keywords = props.__annotations__[name].keywords
try:
annotations = props.__annotations__
except AttributeError:
annotations = type(props).__annotations__
prop_keywords = annotations[name].keywords
items = prop_keywords.get("items")
if items is not None:
if isinstance(items, (list, tuple)):