Skip to content

Commit aea2e2d

Browse files
Added return typing to gamma_adjust, recommending rewriting function as a future issue.
1 parent 5acca0e commit aea2e2d

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

adafruit_fancyled/adafruit_fancyled.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ class CHSV:
188188
"""
189189

190190
# pylint: disable=invalid-name
191-
def __init__(self, h: float, s: float = 1.0, v: float = 1.0):
191+
def __init__(self, h: float, s: float = 1.0, v: float = 1.0) -> None:
192192
if isinstance(h, float):
193193
self.hue = h # Don't clamp! Hue can wrap around forever.
194194
else:
@@ -283,7 +283,9 @@ def clamp_norm(val: Union[float, int]) -> Union[float, int]:
283283
return normalize(val)
284284

285285

286-
def denormalize(val: Union[float, List[float]], inplace=False) -> Union[int, List[int]]:
286+
def denormalize(
287+
val: Union[float, List[float], Tuple[float]], inplace=False
288+
) -> Union[int, List[int]]:
287289
"""Convert normalized (0.0 to 1.0) value to 8-bit (0 to 255) value
288290
289291
Accepts float, 0.0 to 1.0 range or a list or tuple of floats. In
@@ -384,7 +386,9 @@ def mix(
384386
GFACTOR = 2.7 # Default gamma-correction factor for function below
385387

386388

387-
def gamma_adjust(val, gamma_value=None, brightness=1.0, inplace=False):
389+
def gamma_adjust(
390+
val: Any, gamma_value: Any = None, brightness: Any = 1.0, inplace=False
391+
) -> Union[float, CRGB, List[Union[float, CRGB]]]:
388392
"""Provides gamma adjustment for single values, `CRGB` and `CHSV` types
389393
and lists of any of these.
390394
@@ -545,12 +549,11 @@ def palette_lookup(
545549
return mix(color1, color2, weight2)
546550

547551

548-
# gradient: Union[
549-
# List[Union[List[Union[float, CRGB, CHSV]], Tuple[Union[float, CRGB, CHSV]]]],
550-
# Tuple[Union[List[Union[float, CRGB, CHSV]], Tuple[Union[float, CRGB, CHSV]]]],
551-
# ],
552552
def expand_gradient(
553-
gradient: Any,
553+
gradient: Union[
554+
List[List[float, Union[int, CRGB, CHSV]]],
555+
Tuple[Tuple[float, Union[int, CRGB, CHSV]]],
556+
],
554557
length: float,
555558
) -> List[CRGB]:
556559
"""Convert gradient palette into standard equal-interval palette.

0 commit comments

Comments
 (0)