def METHOD_NAME(cmd):
    # type: (sublime_plugin.Command) -> Callable[[str, Dict], None]
    if isinstance(cmd, sublime_plugin.TextCommand):
        return cmd.view.run_command
    elif isinstance(cmd, sublime_plugin.WindowCommand):
        return cmd.window.run_command
    else:
        return sublime.run_command