Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions homeassistant/util/color.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,8 @@ def color_hs_to_xy(
return color_RGB_to_xy(*color_hs_to_RGB(iH, iS), Gamut)


def _match_max_scale(
input_colors: tuple[int, ...], output_colors: tuple[int, ...]
def match_max_scale(
input_colors: tuple[int, ...], output_colors: tuple[float, ...]
) -> tuple[int, ...]:
"""Match the maximum value of the output to the input."""
max_in = max(input_colors)
Expand All @@ -426,7 +426,7 @@ def color_rgb_to_rgbw(r: int, g: int, b: int) -> tuple[int, int, int, int]:

# Match the output maximum value to the input. This ensures the full
# channel range is used.
return _match_max_scale((r, g, b), rgbw) # type: ignore
return match_max_scale((r, g, b), rgbw) # type: ignore[return-value]

@farmio farmio Nov 6, 2021

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we add @overloads for the used tuple length variations (3, 4 and 5 x int)? or better keep the ignores?
This would add ~20 lines to the code just for type variations 馃槵

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ignore is fine.



def color_rgbw_to_rgb(r: int, g: int, b: int, w: int) -> tuple[int, int, int]:
Expand All @@ -436,7 +436,7 @@ def color_rgbw_to_rgb(r: int, g: int, b: int, w: int) -> tuple[int, int, int]:

# Match the output maximum value to the input. This ensures the
# output doesn't overflow.
return _match_max_scale((r, g, b, w), rgb) # type: ignore
return match_max_scale((r, g, b, w), rgb) # type: ignore[return-value]


def color_rgb_to_rgbww(
Expand All @@ -458,7 +458,7 @@ def color_rgb_to_rgbww(

# Match the output maximum value to the input. This ensures the full
# channel range is used.
return _match_max_scale((r, g, b), rgbww) # type: ignore
return match_max_scale((r, g, b), rgbww) # type: ignore[return-value]


def color_rgbww_to_rgb(
Expand All @@ -481,7 +481,7 @@ def color_rgbww_to_rgb(

# Match the output maximum value to the input. This ensures the
# output doesn't overflow.
return _match_max_scale((r, g, b, cw, ww), rgb) # type: ignore
return match_max_scale((r, g, b, cw, ww), rgb) # type: ignore[return-value]


def color_rgb_to_hex(r: int, g: int, b: int) -> str:
Expand Down