Skip to content

Commit 5e5f508

Browse files
authored
Merge pull request #19 from tekktrik/doc/add-typing
Add type annotations
2 parents 342e58c + 52405c0 commit 5e5f508

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

colorsys.py

+9-4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
2323
"""
2424

25+
try:
26+
from typing import Tuple
27+
except ImportError:
28+
pass
29+
2530
__all__ = ["hls_to_rgb", "hsv_to_rgb"]
2631

2732
# Some floating point constants
@@ -36,7 +41,7 @@
3641
# S: color saturation
3742

3843

39-
def hls_to_rgb(hue, light, sat):
44+
def hls_to_rgb(hue: float, light: float, sat: float) -> Tuple[float, float, float]:
4045
""" Converts HLS to RGB values """
4146
if sat == 0.0:
4247
return light, light, light
@@ -52,7 +57,7 @@ def hls_to_rgb(hue, light, sat):
5257
)
5358

5459

55-
def _v(chroma1, chroma2, hue):
60+
def _v(chroma1: float, chroma2: float, hue: float) -> float:
5661
hue = hue % 1.0
5762
if hue < ONE_SIXTH:
5863
return chroma1 + (chroma2 - chroma1) * hue * 6.0
@@ -70,8 +75,8 @@ def _v(chroma1, chroma2, hue):
7075

7176

7277
def hsv_to_rgb( # pylint: disable=too-many-return-statements,inconsistent-return-statements
73-
hue, sat, val
74-
):
78+
hue: float, sat: float, val: float
79+
) -> Tuple[float, float, float]:
7580
""" Converts HSV to RGB values """
7681
if sat == 0.0:
7782
return val, val, val

0 commit comments

Comments
 (0)