Actually, assuming that the getattr() call *can* return a value in some circumstances, mumble mumble stylesheets, then presumably this is the fix?
def weight_modifier(item: Item, param: str) -> None:
# attempt to turn eg 'Bold' into a stylesheet-derived value
arg = getattr(QtGui.QFont, param, None)
if arg is None:
# use our own mapping, eg. if no stylesheet in effect?
arg = {"Thin": QtGui.QFont.Weight.Thin,
"ExtraLight": QtGui.QFont.Weight.ExtraLight,
"Light": QtGui.QFont.Weight.Light,
"Normal": QtGui.QFont.Weight.Normal,
"Medium": QtGui.QFont.Weight.Medium,
"DemiBold": QtGui.QFont.Weight.DemiBold,
"Bold": QtGui.QFont.Weight.Bold,
"ExtraBold": QtGui.QFont.Weight.ExtraBold,
"Black": QtGui.QFont.Weight.Black
}.get(param, QtGui.QFont.Weight.Medium)
# apply the discovered weight
font = item.font(0)
font.setWeight(arg)
item.setFont(0, font)
modifier = weight_modifier