Better use `isinstance` rather than `type`.