Use add_metaclass instead of with_metaclass as suggested by @astrofrog