Background: I mostly run python scripts from the command line in pipelines and so my arguments are always strings that need to be type casted to the app
I know I arrived late at this game, but how about eval?
def my_cast(a): try: return eval(a) except: return a
or alternatively (and more safely):
from ast import literal_eval def mycast(a): try: return literal_eval(a) except: return a