Use isinstance(obj, type) with mypy for if condition to be handled (type() == is deprecated in python)