Skip to content

Commit f34aa59

Browse files
committed
Merge branch 'main' into Error_check_colors
# Conflicts: # adafruit_rgbled.py
2 parents d6f6b27 + 6fb99e4 commit f34aa59

File tree

6 files changed

+33
-16
lines changed

6 files changed

+33
-16
lines changed

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@
44

55
repos:
66
- repo: https://github.com/python/black
7-
rev: 22.3.0
7+
rev: 23.3.0
88
hooks:
99
- id: black
1010
- repo: https://github.com/fsfe/reuse-tool
11-
rev: v0.14.0
11+
rev: v1.1.2
1212
hooks:
1313
- id: reuse
1414
- repo: https://github.com/pre-commit/pre-commit-hooks
15-
rev: v4.2.0
15+
rev: v4.4.0
1616
hooks:
1717
- id: check-yaml
1818
- id: end-of-file-fixer
1919
- id: trailing-whitespace
2020
- repo: https://github.com/pycqa/pylint
21-
rev: v2.15.5
21+
rev: v2.17.4
2222
hooks:
2323
- id: pylint
2424
name: pylint (library code)

.pylintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,4 +396,4 @@ min-public-methods=1
396396

397397
# Exceptions that will emit a warning when being caught. Defaults to
398398
# "Exception"
399-
overgeneral-exceptions=Exception
399+
overgeneral-exceptions=builtins.Exception

adafruit_rgbled.py

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@
2020
https://github.com/adafruit/circuitpython/releases
2121
"""
2222
try:
23-
from typing import Union
23+
from typing import Union, Optional, Type
24+
from types import TracebackType
25+
from microcontroller import Pin
26+
from adafruit_pca9685 import PWMChannel
27+
from circuitpython_typing.led import ColorBasedColorUnion
2428
except ImportError:
2529
pass
2630

@@ -32,9 +36,9 @@
3236

3337
class RGBLED:
3438
"""
35-
Creates a RGBLED object given three physical pins or PWMOut objects.
39+
Create an RGBLED object given three physical pins or PWMOut objects.
3640
37-
Example for setting a RGB LED using a RGB Tuple (Red, Green, Blue):
41+
Example for setting an RGB LED using an RGB Tuple (Red, Green, Blue):
3842
3943
.. code-block:: python
4044
@@ -49,7 +53,7 @@ class RGBLED:
4953
led = adafruit_rgbled.RGBLED(RED_LED, BLUE_LED, GREEN_LED)
5054
led.color = (255, 0, 0)
5155
52-
Example for setting a RGB LED using a 24-bit integer (hex syntax):
56+
Example for setting an RGB LED using a 24-bit integer (hex syntax):
5357
5458
.. code-block:: python
5559
@@ -60,11 +64,11 @@ class RGBLED:
6064
GREEN_LED = board.D6
6165
BLUE_LED = board.D7
6266
63-
# Create a RGB LED object
67+
# Create an RGB LED object
6468
led = adafruit_rgbled.RGBLED(RED_LED, BLUE_LED, GREEN_LED)
6569
led.color = 0x100000
6670
67-
Example for setting a RGB LED using a ContextManager:
71+
Example for setting an RGB LED using a ContextManager:
6872
6973
.. code-block:: python
7074
@@ -115,7 +119,12 @@ def __init__(
115119
def __enter__(self) -> "RGBLED":
116120
return self
117121

118-
def __exit__(self, exception_type, exception_value, traceback) -> None:
122+
def __exit__(
123+
self,
124+
exception_type: Optional[Type[type]],
125+
exception_value: Optional[BaseException],
126+
traceback: Optional[TracebackType],
127+
) -> None:
119128
self.deinit()
120129

121130
def deinit(self) -> None:
@@ -125,11 +134,15 @@ def deinit(self) -> None:
125134
self._current_color = (0, 0, 0)
126135

127136
@property
128-
def color(self) -> Union[int, tuple]:
137+
def color(self) -> ColorBasedColorUnion:
129138
"""
130139
Sets the RGB LED to a desired color.
131-
:param Union[int, tuple] value: RGB LED desired value - can be a RGB tuple of values
132-
0 - 255 or a 24-bit integer. e.g. (255, 64, 35) and 0xff4023 are equivalent.
140+
141+
:param ColorBasedColorUnion value: RGB LED desired value - can be a RGB
142+
tuple of values 0 - 255 or a 24-bit integer. e.g. (255, 64, 35) and 0xff4023
143+
are equivalent.
144+
145+
:returns Union[int, Tuple[int, int, int]]: The current LED color setting.
133146
134147
:raises ValueError: If the input is an int > 0xffffff or is a tuple that does not
135148
contain 3 integers of 0 - 255.
@@ -138,7 +151,7 @@ def color(self) -> Union[int, tuple]:
138151
return self._current_color
139152

140153
@color.setter
141-
def color(self, value: Union[int, tuple]):
154+
def color(self, value: ColorBasedColorUnion):
142155
if isinstance(value, int):
143156
try:
144157
# Check that integer is <= 0xffffff and create an iterable.

docs/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
# ones.
1818
extensions = [
1919
"sphinx.ext.autodoc",
20+
"sphinxcontrib.jquery",
2021
"sphinx.ext.intersphinx",
2122
"sphinx.ext.napoleon",
2223
"sphinx.ext.todo",

docs/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
# SPDX-License-Identifier: Unlicense
44

55
sphinx>=4.0.0
6+
sphinxcontrib-jquery

requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33
# SPDX-License-Identifier: Unlicense
44

55
Adafruit-Blinka
6+
adafruit-circuitpython-typing~=1.4
7+
adafruit-circuitpython-pca9685

0 commit comments

Comments
 (0)