def cast_int_like_to_int(cli_arg: Union[None, str, int]) -> Union[None, str, int]:
    """Cast int-like objects to int if possible

    If the arg cannot be cast to an integer, return the unmodified object instead."""
    try:
        cli_arg_int = int(cli_arg)
        return cli_arg_int
    except TypeError:
        # Don't cast if None
        return cli_arg
    except ValueError:
        # Don't cast non-int-like strings
        return cli_arg
Cast int-like objects to int if possible

    If the arg cannot be cast to an integer, return the unmodified object instead.
flask_appbuilder/cli.py