we have the slightly confusingly named `to_function` that you can use to not reproduce this logic. https://github.com/dimagi/dimagi-utils/blob/master/dimagi/utils/modules.py#L10