Use isinstance() instead of comparing types directly.