[lib] Use isinstance vs type==type.