Repository: home-assistant/core
File: homeassistant/components/tuya/type_information.py (Python)

Code before:
                    and (
                        type_information := cls._from_json(
                            dpcode=dpcode,
                            type_data=current_definition.values,
                            report_type=getattr(
                                current_definition, "report_type", None
                            ),
                        )
                    )
                ):
                    return type_information

        return None


@dataclass(kw_only=True)
class BitmapTypeInformation(TypeInformation[int]):
    """Bitmap type information."""

    _DPTYPE = DPType.BITMAP

    label: list[str]

    @classmethod
    def _from_json(
        cls, dpcode: str, type_data: str, *, report_type: str | None = None
    ) -> Self | None:
        """Load JSON string and return a BitmapTypeInformation object."""
        if not (parsed := cast(dict[str, Any] | None, json_loads_object(type_data))):
            return None
        return cls(
            dpcode=dpcode,
            type_data=type_data,
            label=parsed["label"],
        )


@dataclass(kw_only=True)
class BooleanTypeInformation(TypeInformation[bool]):
    """Boolean type information."""

    _DPTYPE = DPType.BOOLEAN

    def process_raw_value(
        self, raw_value: Any | None, device: CustomerDevice
    ) -> bool | None:
        """Read and process raw value against this type information."""
        if raw_value is None:
            return None
        # Validate input against defined range
        if raw_value not in (True, False):

Review comment (suggestion):
```suggestion
        cls, dpcode: str, type_data: str, *, report_type: str | None
```

Code after:
                if (
                    (current_definition := device_specs.get(dpcode))
                    and parse_dptype(current_definition.type) is cls._DPTYPE
                    and (
                        type_information := cls._from_json(
                            dpcode=dpcode,
                            type_data=current_definition.values,
                            report_type=report_type,
                        )
                    )
                ):
                    return type_information

        return None


@dataclass(kw_only=True)
class BitmapTypeInformation(TypeInformation[int]):
    """Bitmap type information."""

    _DPTYPE = DPType.BITMAP

    label: list[str]

    @classmethod
    def _from_json(
        cls, dpcode: str, type_data: str, *, report_type: str | None
    ) -> Self | None:
        """Load JSON string and return a BitmapTypeInformation object."""
        if not (parsed := cast(dict[str, Any] | None, json_loads_object(type_data))):
            return None
        return cls(
            dpcode=dpcode,
            type_data=type_data,
            label=parsed["label"],
        )


@dataclass(kw_only=True)
class BooleanTypeInformation(TypeInformation[bool]):
    """Boolean type information."""

    _DPTYPE = DPType.BOOLEAN

    def process_raw_value(
        self, raw_value: Any | None, device: CustomerDevice
    ) -> bool | None:
        """Read and process raw value against this type information."""
        if raw_value is None:
            return None
        # Validate input against defined range