Skip to content

Commit b1ad905

Browse files
authored
Merge pull request #46 from adafruit/pylint-update
Ran black, updated to pylint 2.x
2 parents 5cdd686 + 8002a00 commit b1ad905

17 files changed

+272
-174
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
source actions-ci/install.sh
4141
- name: Pip install pylint, black, & Sphinx
4242
run: |
43-
pip install --force-reinstall pylint==1.9.2 black==19.10b0 Sphinx sphinx-rtd-theme
43+
pip install --force-reinstall pylint black==19.10b0 Sphinx sphinx-rtd-theme
4444
- name: Library version
4545
run: git describe --dirty --always --tags
4646
- name: PyLint

.pylintrc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ spelling-store-unknown-words=no
119119
[MISCELLANEOUS]
120120

121121
# List of note tags to take in consideration, separated by a comma.
122-
notes=FIXME,XXX,TODO
122+
# notes=FIXME,XXX,TODO
123+
notes=FIXME,XXX
123124

124125

125126
[TYPECHECK]
@@ -155,7 +156,7 @@ ignored-classes=optparse.Values,thread._local,_thread._local
155156
# (useful for modules/projects where namespaces are manipulated during runtime
156157
# and thus existing member attributes cannot be deduced by static analysis. It
157158
# supports qualified module names, as well as Unix pattern matching.
158-
ignored-modules=board,pulseio
159+
ignored-modules=board
159160

160161
# Show a hint with possible names when a member name was not found. The aspect
161162
# of finding the hint is based on edit distance.
@@ -300,7 +301,7 @@ function-rgx=(([a-z][a-z0-9_]{2,30})|(_[a-z0-9_]*))$
300301

301302
# Good variable names which should always be accepted, separated by a comma
302303
# good-names=i,j,k,ex,Run,_
303-
good-names=r,g,b,i,j,k,n,ex,Run,_
304+
good-names=r,g,b,w,i,j,k,n,x,y,z,ex,ok,Run,_
304305

305306
# Include a hint for the correct naming format with invalid-name
306307
include-naming-hint=no
@@ -422,7 +423,7 @@ max-returns=6
422423
max-statements=50
423424

424425
# Minimum number of public methods for a class (see R0903).
425-
min-public-methods=2
426+
min-public-methods=1
426427

427428

428429
[EXCEPTIONS]

adafruit_character_lcd/character_lcd.py

Lines changed: 67 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -54,39 +54,39 @@
5454

5555
# pylint: disable-msg=bad-whitespace
5656
# Commands
57-
_LCD_CLEARDISPLAY = const(0x01)
58-
_LCD_RETURNHOME = const(0x02)
59-
_LCD_ENTRYMODESET = const(0x04)
60-
_LCD_DISPLAYCONTROL = const(0x08)
61-
_LCD_CURSORSHIFT = const(0x10)
62-
_LCD_FUNCTIONSET = const(0x20)
63-
_LCD_SETCGRAMADDR = const(0x40)
64-
_LCD_SETDDRAMADDR = const(0x80)
57+
_LCD_CLEARDISPLAY = const(0x01)
58+
_LCD_RETURNHOME = const(0x02)
59+
_LCD_ENTRYMODESET = const(0x04)
60+
_LCD_DISPLAYCONTROL = const(0x08)
61+
_LCD_CURSORSHIFT = const(0x10)
62+
_LCD_FUNCTIONSET = const(0x20)
63+
_LCD_SETCGRAMADDR = const(0x40)
64+
_LCD_SETDDRAMADDR = const(0x80)
6565

6666
# Entry flags
67-
_LCD_ENTRYLEFT = const(0x02)
67+
_LCD_ENTRYLEFT = const(0x02)
6868
_LCD_ENTRYSHIFTDECREMENT = const(0x00)
6969

7070
# Control flags
71-
_LCD_DISPLAYON = const(0x04)
72-
_LCD_CURSORON = const(0x02)
73-
_LCD_CURSOROFF = const(0x00)
74-
_LCD_BLINKON = const(0x01)
75-
_LCD_BLINKOFF = const(0x00)
71+
_LCD_DISPLAYON = const(0x04)
72+
_LCD_CURSORON = const(0x02)
73+
_LCD_CURSOROFF = const(0x00)
74+
_LCD_BLINKON = const(0x01)
75+
_LCD_BLINKOFF = const(0x00)
7676

7777
# Move flags
78-
_LCD_DISPLAYMOVE = const(0x08)
79-
_LCD_MOVERIGHT = const(0x04)
80-
_LCD_MOVELEFT = const(0x00)
78+
_LCD_DISPLAYMOVE = const(0x08)
79+
_LCD_MOVERIGHT = const(0x04)
80+
_LCD_MOVELEFT = const(0x00)
8181

8282
# Function set flags
83-
_LCD_4BITMODE = const(0x00)
84-
_LCD_2LINE = const(0x08)
85-
_LCD_1LINE = const(0x00)
86-
_LCD_5X8DOTS = const(0x00)
83+
_LCD_4BITMODE = const(0x00)
84+
_LCD_2LINE = const(0x08)
85+
_LCD_1LINE = const(0x00)
86+
_LCD_5X8DOTS = const(0x00)
8787

8888
# Offset for up to 4 rows.
89-
_LCD_ROW_OFFSETS = (0x00, 0x40, 0x14, 0x54)
89+
_LCD_ROW_OFFSETS = (0x00, 0x40, 0x14, 0x54)
9090

9191
# pylint: enable-msg=bad-whitespace
9292

@@ -128,12 +128,12 @@ class Character_LCD:
128128
:param lines: The lines on the charLCD
129129
130130
"""
131+
131132
LEFT_TO_RIGHT = const(0)
132133
RIGHT_TO_LEFT = const(1)
133134

134135
# pylint: disable-msg=too-many-arguments
135-
def __init__(self, rs, en, d4, d5, d6, d7, columns, lines
136-
):
136+
def __init__(self, rs, en, d4, d5, d6, d7, columns, lines):
137137

138138
self.columns = columns
139139
self.lines = lines
@@ -146,7 +146,7 @@ def __init__(self, rs, en, d4, d5, d6, d7, columns, lines
146146
self.dl7 = d7
147147

148148
# set all pins as outputs
149-
for pin in(rs, en, d4, d5, d6, d7):
149+
for pin in (rs, en, d4, d5, d6, d7):
150150
pin.direction = digitalio.Direction.OUTPUT
151151

152152
# Initialise the display
@@ -174,6 +174,7 @@ def __init__(self, rs, en, d4, d5, d6, d7, columns, lines
174174
self.row = 0
175175
self.column = 0
176176
self._column_align = False
177+
177178
# pylint: enable-msg=too-many-arguments
178179

179180
def home(self):
@@ -215,7 +216,7 @@ def column_align(self, enable):
215216
if isinstance(enable, bool):
216217
self._column_align = enable
217218
else:
218-
raise ValueError('The column_align value must be either True or False')
219+
raise ValueError("The column_align value must be either True or False")
219220

220221
@property
221222
def cursor(self):
@@ -379,7 +380,7 @@ def message(self, message):
379380
self.cursor_position(col, line)
380381
initial_character += 1
381382
# If character is \n, go to next line
382-
if character == '\n':
383+
if character == "\n":
383384
line += 1
384385
# Start the second line at (0, 1) unless direction is set right to left in
385386
# which case start on the opposite side of the display if cursor_position
@@ -540,6 +541,8 @@ def _pulse_enable(self):
540541
time.sleep(0.0000001)
541542
self.enable.value = False
542543
time.sleep(0.0000001)
544+
545+
543546
# pylint: enable-msg=too-many-instance-attributes
544547

545548

@@ -561,9 +564,21 @@ class Character_LCD_Mono(Character_LCD):
561564
to common cathode.
562565
563566
"""
567+
564568
# pylint: disable-msg=too-many-arguments
565-
def __init__(self, rs, en, db4, db5, db6, db7, columns, lines,
566-
backlight_pin=None, backlight_inverted=False):
569+
def __init__(
570+
self,
571+
rs,
572+
en,
573+
db4,
574+
db5,
575+
db6,
576+
db7,
577+
columns,
578+
lines,
579+
backlight_pin=None,
580+
backlight_inverted=False,
581+
):
567582

568583
# Backlight pin and inversion
569584
self.backlight_pin = backlight_pin
@@ -574,6 +589,7 @@ def __init__(self, rs, en, db4, db5, db6, db7, columns, lines,
574589
self.backlight_pin.direction = digitalio.Direction.OUTPUT
575590
self.backlight = True
576591
super().__init__(rs, en, db4, db5, db6, db7, columns, lines)
592+
577593
# pylint: enable-msg=too-many-arguments
578594

579595
@property
@@ -631,9 +647,23 @@ class Character_LCD_RGB(Character_LCD):
631647
write from the display. Not necessary if only writing to the display. Used on shield.
632648
633649
"""
650+
634651
# pylint: disable-msg=too-many-arguments
635-
def __init__(self, rs, en, db4, db5, db6, db7, columns, lines,
636-
red, green, blue, read_write=None):
652+
def __init__(
653+
self,
654+
rs,
655+
en,
656+
db4,
657+
db5,
658+
db6,
659+
db7,
660+
columns,
661+
lines,
662+
red,
663+
green,
664+
blue,
665+
read_write=None,
666+
):
637667

638668
# Define read_write (rw) pin
639669
self.read_write = read_write
@@ -646,13 +676,13 @@ def __init__(self, rs, en, db4, db5, db6, db7, columns, lines,
646676
self.rgb_led = [red, green, blue]
647677

648678
for pin in self.rgb_led:
649-
if hasattr(pin, 'direction'):
679+
if hasattr(pin, "direction"):
650680
# Assume a digitalio.DigitalInOut or compatible interface:
651681
pin.direction = digitalio.Direction.OUTPUT
652-
elif not hasattr(pin, 'duty_cycle'):
682+
elif not hasattr(pin, "duty_cycle"):
653683
raise TypeError(
654-
'RGB LED objects must be instances of digitalio.DigitalInOut'
655-
' or pulseio.PWMOut, or provide a compatible interface.'
684+
"RGB LED objects must be instances of digitalio.DigitalInOut"
685+
" or pulseio.PWMOut, or provide a compatible interface."
656686
)
657687

658688
self._color = [0, 0, 0]
@@ -691,10 +721,10 @@ def color(self):
691721
def color(self, color):
692722
self._color = color
693723
for number, pin in enumerate(self.rgb_led):
694-
if hasattr(pin, 'duty_cycle'):
724+
if hasattr(pin, "duty_cycle"):
695725
# Assume a pulseio.PWMOut or compatible interface and set duty cycle:
696726
pin.duty_cycle = int(_map(color[number], 0, 100, 65535, 0))
697-
elif hasattr(pin, 'value'):
727+
elif hasattr(pin, "value"):
698728
# If we don't have a PWM interface, all we can do is turn each color
699729
# on / off. Assume a DigitalInOut (or compatible interface) and write
700730
# 0 (on) to pin for any value greater than 0, or 1 (off) for 0:

adafruit_character_lcd/character_lcd_i2c.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
4444
"""
4545

46+
from adafruit_mcp230xx.mcp23008 import MCP23008
4647
from adafruit_character_lcd.character_lcd import Character_LCD_Mono
4748

4849
__version__ = "0.0.0-auto.0"
@@ -66,22 +67,26 @@ class Character_LCD_I2C(Character_LCD_Mono):
6667
i2c = busio.I2C(board.SCL, board.SDA)
6768
lcd = Character_LCD_I2C(i2c, 16, 2)
6869
"""
70+
6971
def __init__(self, i2c, columns, lines, address=None, backlight_inverted=False):
7072
"""Initialize character LCD connected to backpack using I2C connection
7173
on the specified I2C bus with the specified number of columns and
7274
lines on the display. Optionally specify if backlight is inverted.
7375
"""
74-
from adafruit_mcp230xx.mcp23008 import MCP23008
76+
7577
if address:
7678
mcp = MCP23008(i2c, address=address)
7779
else:
7880
mcp = MCP23008(i2c)
79-
super().__init__(mcp.get_pin(1),
80-
mcp.get_pin(2),
81-
mcp.get_pin(3),
82-
mcp.get_pin(4),
83-
mcp.get_pin(5),
84-
mcp.get_pin(6),
85-
columns, lines,
86-
backlight_pin=mcp.get_pin(7),
87-
backlight_inverted=backlight_inverted)
81+
super().__init__(
82+
mcp.get_pin(1),
83+
mcp.get_pin(2),
84+
mcp.get_pin(3),
85+
mcp.get_pin(4),
86+
mcp.get_pin(5),
87+
mcp.get_pin(6),
88+
columns,
89+
lines,
90+
backlight_pin=mcp.get_pin(7),
91+
backlight_inverted=backlight_inverted,
92+
)

adafruit_character_lcd/character_lcd_rgb_i2c.py

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
"""
5555

5656
import digitalio
57+
from adafruit_mcp230xx.mcp23017 import MCP23017
5758
from adafruit_character_lcd.character_lcd import Character_LCD_RGB
5859

5960
__version__ = "0.0.0-auto.0"
@@ -77,13 +78,14 @@ class Character_LCD_RGB_I2C(Character_LCD_RGB):
7778
lcd = Character_LCD_RGB_I2C(i2c, 16, 2)
7879
7980
"""
81+
8082
def __init__(self, i2c, columns, lines, address=None):
8183
# pylint: disable=too-many-locals
8284
"""Initialize RGB character LCD connected to shield using I2C connection
8385
on the specified I2C bus with the specified number of columns and lines
8486
on the display.
8587
"""
86-
from adafruit_mcp230xx.mcp23017 import MCP23017
88+
8789
if address:
8890
mcp = MCP23017(i2c, address=address)
8991
else:
@@ -95,25 +97,31 @@ def __init__(self, i2c, columns, lines, address=None):
9597
self._right_button = mcp.get_pin(1)
9698
self._select_button = mcp.get_pin(0)
9799

98-
self._buttons = [self._left_button, self._up_button, self._down_button, self._right_button,
99-
self._select_button]
100+
self._buttons = [
101+
self._left_button,
102+
self._up_button,
103+
self._down_button,
104+
self._right_button,
105+
self._select_button,
106+
]
100107

101108
for pin in self._buttons:
102109
pin.switch_to_input(pull=digitalio.Pull.UP)
103110

104-
super().__init__(mcp.get_pin(15),
105-
mcp.get_pin(13),
106-
mcp.get_pin(12),
107-
mcp.get_pin(11),
108-
mcp.get_pin(10),
109-
mcp.get_pin(9),
110-
columns,
111-
lines,
112-
mcp.get_pin(6),
113-
mcp.get_pin(7),
114-
mcp.get_pin(8),
115-
mcp.get_pin(14))
116-
111+
super().__init__(
112+
mcp.get_pin(15),
113+
mcp.get_pin(13),
114+
mcp.get_pin(12),
115+
mcp.get_pin(11),
116+
mcp.get_pin(10),
117+
mcp.get_pin(9),
118+
columns,
119+
lines,
120+
mcp.get_pin(6),
121+
mcp.get_pin(7),
122+
mcp.get_pin(8),
123+
mcp.get_pin(14),
124+
)
117125

118126
@property
119127
def left_button(self):

0 commit comments

Comments
 (0)