|
2 | 2 | #
|
3 | 3 | # SPDX-License-Identifier: MIT
|
4 | 4 |
|
| 5 | +# pylint: disable=raise-missing-from |
5 | 6 | """
|
6 | 7 | `adafruit_rgbled`
|
7 | 8 | ================================================================================
|
@@ -106,12 +107,11 @@ def __init__(
|
106 | 107 | if pin_type.startswith("<class '") and pin_type.endswith("Pin'>"):
|
107 | 108 | self._rgb_led_pins[pin] = PWMOut(self._rgb_led_pins[pin])
|
108 | 109 | self._rgb_led_pins[pin].duty_cycle = 0
|
109 |
| - except AttributeError as exc: |
110 |
| - raise TypeError( |
111 |
| - "Pins must be of type Pin, PWMOut or PWMChannel" |
112 |
| - ) from exc |
| 110 | + except AttributeError: |
| 111 | + raise TypeError("Pins must be of type Pin, PWMOut or PWMChannel") |
113 | 112 | self._invert_pwm = invert_pwm
|
114 | 113 | self._current_color = (0, 0, 0)
|
| 114 | + self.color = self._current_color |
115 | 115 |
|
116 | 116 | def __enter__(self) -> "RGBLED":
|
117 | 117 | return self
|
@@ -144,17 +144,17 @@ def color(self, value: Union[int, tuple]):
|
144 | 144 | try:
|
145 | 145 | # Check that integer is <= 0xffffff and create an iterable.
|
146 | 146 | rgb = value.to_bytes(3, "big", signed=False)
|
147 |
| - except OverflowError as exc: |
148 |
| - raise ValueError("Only bits 0->23 valid for integer input") from exc |
| 147 | + except OverflowError: |
| 148 | + raise ValueError("Only bits 0->23 valid for integer input") |
149 | 149 | elif isinstance(value, tuple):
|
150 | 150 | try:
|
151 | 151 | rgb = bytes(value) # Check that tuple has integers of 0 - 255.
|
152 | 152 | if len(rgb) != 3:
|
153 | 153 | raise ValueError
|
154 |
| - except (ValueError, TypeError) as exc: |
| 154 | + except (ValueError, TypeError): |
155 | 155 | raise ValueError(
|
156 | 156 | "Only a tuple of 3 integers of 0 - 255 for tuple input."
|
157 |
| - ) from exc |
| 157 | + ) |
158 | 158 | else:
|
159 | 159 | raise TypeError(
|
160 | 160 | "Color must be a tuple of 3 integers or 24-bit integer value."
|
|
0 commit comments