def is_dataclass_type(cls: type) -> bool:
    """Like dataclasses.is_dataclass(), but works correctly for a
    non-dataclass subclass of a dataclass."""
    try:
        return "__dataclass_fields__" in cls.__dict__
    except Exception:
        return False