In general, I prefer to test for positive conditions rather than negative conditions.  Why check if the task type is `u"grade"`?

Also, `is` in Python is used for exact identity comparison, which you don't want here.  Use `==` instead.