The problem is that python-nav-end-of-defun used in python-hideshow-forward-sexp-function can not handle backslash escaped newline in class/function definitions. Attached is a patch to fix the problem.