Use `isinstance` rather than `type`.