Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Sep 21, 2024
1 parent 4459c0d commit d97a449
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions package/PartSegImage/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,7 @@ def _hex_to_rgb(hex_code: str) -> tuple[int, int, int]:
elif len(hex_code) != 6:
raise ValueError(f"Invalid hex code format: {hex_code}")

return (int(hex_code[0:2], 16), int(hex_code[2:4], 16), int(hex_code[4:6], 16))
return int(hex_code[:2], 16), int(hex_code[2:4], 16), int(hex_code[4:6], 16)


def _name_to_rgb(name: str) -> tuple[int, int, int]:
Expand All @@ -986,9 +986,10 @@ def _name_to_rgb(name: str) -> tuple[int, int, int]:
:param str name: The color name
:return: A tuple containing the RGB values (R, G, B)
"""
if name not in _NAMED_COLORS:
raise ValueError(f"Unknown color name: {name}")
return _hex_to_rgb(_NAMED_COLORS[name])


_NAMED_COLORS = {
"red": "#FF0000",
"green": "#00FF00",
Expand Down

0 comments on commit d97a449

Please sign in to comment.