this would be a bit more readable if you didn't bother with the outer `if` and then just had `do_constrain = bool(constraint_dict)` at the end.