From 01e8af3348fac2babe3b5218dbe4ecdaa0e1eace Mon Sep 17 00:00:00 2001 From: Alexander Gavrilov Date: Sat, 12 Nov 2022 23:54:17 +0200 Subject: Rigify: annotate and fix warnings in basic rig components. Introduce a method to annotate types and names of entries in the `bones` container of rig components and apply it, and other type annotations, to a number of not very complex rig classes. - Introduce BaseRigMixin as a typed base class for mixins intended for use in rig classes (using BaseRig as a parent causes issues). - Introduce TypedBoneDict that does not suppress the unknown attribute analysis in PyCharm, and use it in a system of subclasses to annotate the bones in various rigs. BaseBoneDict is necessary because the annotation affects all subclasses, so TypedBoneDict cannot inherit from BoneDict with the annotation. - Add or adjust other type annotations of rig methods and utilities. - Fix other warnings, e.g. undeclared attributes, excessively long lines, whitespace style issues and typos. --- rigify/rigs/utils.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'rigify/rigs/utils.py') diff --git a/rigify/rigs/utils.py b/rigify/rigs/utils.py index cbc53e3a..9fd9a2c1 100644 --- a/rigify/rigs/utils.py +++ b/rigify/rigs/utils.py @@ -15,7 +15,7 @@ def get_future_names_arm(bones): farm = strip_mch(strip_org(bones[1].name)) hand = strip_mch(strip_org(bones[2].name)) - suffix='' + suffix = '' if uarm[-2:] == '.L' or uarm[-2:] == '.R': suffix = uarm[-2:] uarm = uarm.rstrip(suffix) @@ -33,7 +33,7 @@ def get_future_names_arm(bones): # pole = 'upper_arm_ik_target.L' names['controls'] = [uarm + '_ik', uarm + '_fk', farm + '_fk', hand + '_fk', hand + '_ik', - make_mechanism_name(hand + '_fk'), uarm + '_parent'] + make_mechanism_name(hand + '_fk'), uarm + '_parent'] names['ik_ctrl'] = [hand + '_ik', make_mechanism_name(uarm) + '_ik', make_mechanism_name(uarm) + '_ik_target'] names['fk_ctrl'] = uarm + '_fk' + suffix names['parent'] = uarm + '_parent' + suffix @@ -80,7 +80,7 @@ def get_future_names_leg(bones): # pole = 'thigh_ik_target.R' names['controls'] = [thigh + '_ik', thigh + '_fk', shin + '_fk', foot + '_fk', toe, foot + '_heel_ik', - foot + '_ik', make_mechanism_name(foot + '_fk'), thigh + '_parent'] + foot + '_ik', make_mechanism_name(foot + '_fk'), thigh + '_parent'] names['ik_ctrl'] = [foot + '_ik', make_mechanism_name(thigh) + '_ik', make_mechanism_name(thigh) + '_ik_target'] names['fk_ctrl'] = thigh + '_fk' + suffix names['parent'] = thigh + '_parent' + suffix @@ -128,7 +128,7 @@ def get_future_names_paw(bones): # pole = 'thigh_ik_target.R' names['controls'] = [thigh + '_ik', thigh + '_fk', shin + '_fk', foot + '_fk', toe, foot + '_heel_ik', - foot + '_ik', make_mechanism_name(foot + '_fk'), thigh + '_parent'] + foot + '_ik', make_mechanism_name(foot + '_fk'), thigh + '_parent'] names['ik_ctrl'] = [foot + '_ik', make_mechanism_name(thigh) + '_ik', make_mechanism_name(thigh) + '_ik_target'] names['fk_ctrl'] = thigh + '_fk' + suffix names['parent'] = thigh + '_parent' + suffix @@ -157,17 +157,17 @@ def get_future_names(bones): def get_limb_generated_names(rig): - pbones = rig.pose.bones + pose_bones = rig.pose.bones names = dict() - for b in pbones: + for b in pose_bones: super_limb_orgs = [] if re.match('^ORG', b.name) and b.rigify_type == 'limbs.super_limb': super_limb_orgs.append(b) children = connected_children_names(rig, b.name) for child in children: if re.match('^ORG', child) or re.match('^MCH', child): - super_limb_orgs.append(pbones[child]) + super_limb_orgs.append(pose_bones[child]) names[b.name] = get_future_names(super_limb_orgs) return names -- cgit v1.2.3