Cleanup: simplify attribute access

Avoid getattr(..) when values are know to exist.
This commit is contained in:
Campbell Barton
2024-10-01 10:20:14 +10:00
parent 0afce08c20
commit 4c36f9a566
2 changed files with 3 additions and 3 deletions

View File

@@ -694,7 +694,7 @@ class ANIM_OT_slot_new_for_id(Operator):
return True
def execute(self, context):
animated_id = getattr(context, "animated_id", None)
animated_id = context.animated_id
action = animated_id.animation_data.action
slot = action.slots.new(for_id=animated_id)
@@ -726,7 +726,7 @@ class ANIM_OT_slot_unassign_from_id(Operator):
return True
def execute(self, context):
animated_id = getattr(context, "animated_id", None)
animated_id = context.animated_id
animated_id.animation_data.action_slot = None
return {'FINISHED'}

View File

@@ -342,7 +342,7 @@ class DOPESHEET_HT_editor_buttons:
case 'ACTION':
return context.object
case 'SHAPEKEY':
return context.object.data and getattr(context.object.data, 'shape_keys', None)
return getattr(context.object.data, "shape_keys", None)
case _:
print("Dope Sheet mode '{:s}' not expected to have an Action selector".format(st.mode))
return context.object