Skip to content

Commit 8e7c04b

Browse files
author
BiffoBear
committed
Requested changes made.
1 parent 1a13b17 commit 8e7c04b

File tree

3 files changed

+21
-46
lines changed

3 files changed

+21
-46
lines changed

.pre-commit-config.yaml

Lines changed: 9 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,12 @@
33
# SPDX-License-Identifier: Unlicense
44

55
repos:
6-
- repo: https://github.com/python/black
7-
rev: 22.3.0
8-
hooks:
9-
- id: black
10-
- repo: https://github.com/fsfe/reuse-tool
11-
rev: v0.14.0
12-
hooks:
13-
- id: reuse
14-
- repo: https://github.com/pre-commit/pre-commit-hooks
15-
rev: v4.2.0
16-
hooks:
17-
- id: check-yaml
18-
- id: end-of-file-fixer
19-
- id: trailing-whitespace
20-
- repo: https://github.com/pycqa/pylint
21-
rev: v2.11.1
22-
hooks:
23-
- id: pylint
24-
name: pylint (library code)
25-
types: [python]
26-
args:
27-
- --disable=consider-using-f-string
28-
exclude: "^(docs/|examples/|tests/|setup.py$)"
29-
- id: pylint
30-
name: pylint (example code)
31-
description: Run pylint rules on "examples/*.py" files
32-
types: [python]
33-
files: "^examples/"
34-
args:
35-
- --disable=missing-docstring,invalid-name,consider-using-f-string,duplicate-code
36-
- id: pylint
37-
name: pylint (test code)
38-
description: Run pylint rules on "tests/*.py" files
39-
types: [python]
40-
files: "^tests/"
41-
args:
42-
- --disable=missing-docstring,consider-using-f-string,duplicate-code
6+
- repo: https://github.com/fsfe/reuse-tool
7+
rev: v0.14.0
8+
hooks:
9+
- id: reuse
10+
- repo: https://github.com/pre-commit/pre-commit-hooks
11+
rev: v4.2.0
12+
hooks:
13+
- id: end-of-file-fixer
14+
- id: trailing-whitespace

adafruit_character_lcd/character_lcd.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
3030
3131
"""
32+
import circuitpython_typing
3233

3334
try:
3435
from typing import Union, Optional, List, Sequence
@@ -90,7 +91,7 @@ def _set_bit(byte_value: int, position: int, val: bool) -> int:
9091
return ret
9192

9293

93-
def _map(xval: int, in_min: int, in_max: int, out_min: int, out_max: int) -> float:
94+
def _map(xval: float, in_min: float, in_max: float, out_min: float, out_max: float) -> float:
9495
# Affine transfer/map with constrained output.
9596
outrange = float(out_max - out_min)
9697
inrange = float(in_max - in_min)
@@ -489,7 +490,7 @@ def create_char(self, location: int, pattern: Sequence[int]) -> None:
489490
To show your custom character use, for example, ``lcd.message = "\x01"``
490491
491492
:param int location: Integer in range(8) to store the created character.
492-
:param Sequence pattern: len(8) describes created character.
493+
:param Sequence[int] pattern: len(8) describes created character.
493494
494495
"""
495496
# only position 0..7 are allowed
@@ -498,9 +499,9 @@ def create_char(self, location: int, pattern: Sequence[int]) -> None:
498499
for i in range(8):
499500
self._write8(pattern[i], char_mode=True)
500501

501-
def _write8(self, value: [int], char_mode: bool = False) -> None:
502+
def _write8(self, value: int, char_mode: bool = False) -> None:
502503
# Sends 8b ``value`` in ``char_mode``.
503-
# :param value: bytes
504+
# :param value: int
504505
# :param char_mode: character/data mode selector. False (default) for
505506
# data only, True for character bits.
506507
# one ms delay to prevent writing too quickly.
@@ -708,15 +709,15 @@ def color(self) -> List[int]:
708709
return self._color
709710

710711
@color.setter
711-
def color(self, color: Union[List[int], int]) -> None:
712+
def color(self, color: Union[List[float], int]) -> None:
712713
if isinstance(color, int):
713714
if color >> 24:
714715
raise ValueError("Integer color value must be positive and 24 bits max")
715716
# NOTE: convert to 0-100
716-
r = int((color >> 16) / 2.55)
717-
g = int(((color >> 8) & 0xFF) / 2.55)
718-
b = int((color & 0xFF) / 2.55)
719-
color = [r, g, b] # This is List[float], should be List[int]
717+
r = (color >> 16) / 2.55
718+
g = ((color >> 8) & 0xFF) / 2.55
719+
b = (color & 0xFF) / 2.55
720+
color = [r, g, b]
720721
self._color = color
721722
for number, pin in enumerate(self.rgb_led):
722723
if hasattr(pin, "duty_cycle"):

docs/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
sphinx>=4.0.0
6+
adafruit_circuitpython_typing>=1.8.2
7+
typing_extensions>=4.4.0

0 commit comments

Comments
 (0)