Skip to content

Commit 979eb63

Browse files
authored
Merge pull request #47 from adafruit/pylint-update
Ran black, updated to pylint 2.x
2 parents f7051cd + 89fa658 commit 979eb63

File tree

14 files changed

+276
-237
lines changed

14 files changed

+276
-237
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: 2 additions & 1 deletion
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]

adafruit_hid/__init__.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,17 @@
4040
__version__ = "0.0.0-auto.0"
4141
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_HID.git"
4242

43+
4344
def find_device(devices, *, usage_page, usage):
4445
"""Search through the provided list of devices to find the one with the matching usage_page and
4546
usage."""
4647
if hasattr(devices, "send_report"):
4748
devices = [devices]
4849
for device in devices:
49-
if (device.usage_page == usage_page and
50-
device.usage == usage and
51-
hasattr(device, "send_report")):
50+
if (
51+
device.usage_page == usage_page
52+
and device.usage == usage
53+
and hasattr(device, "send_report")
54+
):
5255
return device
5356
raise ValueError("Could not find matching HID device.")

adafruit_hid/consumer_control.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,18 @@
2929
"""
3030

3131
import sys
32+
3233
if sys.implementation.version[0] < 3:
33-
raise ImportError('{0} is not supported in CircuitPython 2.x or lower'.format(__name__))
34+
raise ImportError(
35+
"{0} is not supported in CircuitPython 2.x or lower".format(__name__)
36+
)
3437

3538
# pylint: disable=wrong-import-position
3639
import struct
3740
import time
3841
from . import find_device
3942

43+
4044
class ConsumerControl:
4145
"""Send ConsumerControl code reports, used by multimedia keyboards, remote controls, etc.
4246
"""

adafruit_hid/consumer_control_code.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
* Author(s): Dan Halbert
2929
"""
3030

31+
3132
class ConsumerControlCode:
3233
"""USB HID Consumer Control Device constants.
3334
@@ -36,7 +37,8 @@ class ConsumerControlCode:
3637
3738
*New in CircuitPython 3.0.*
3839
"""
39-
#pylint: disable-msg=too-few-public-methods
40+
41+
# pylint: disable-msg=too-few-public-methods
4042

4143
RECORD = 0xB2
4244
"""Record"""

adafruit_hid/gamepad.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
from . import find_device
3535

36+
3637
class Gamepad:
3738
"""Emulate a generic gamepad controller with 16 buttons,
3839
numbered 1-16, and two joysticks, one controlling
@@ -147,10 +148,16 @@ def _send(self, always=False):
147148
"""Send a report with all the existing settings.
148149
If ``always`` is ``False`` (the default), send only if there have been changes.
149150
"""
150-
struct.pack_into('<Hbbbb', self._report, 0,
151-
self._buttons_state,
152-
self._joy_x, self._joy_y,
153-
self._joy_z, self._joy_r_z)
151+
struct.pack_into(
152+
"<Hbbbb",
153+
self._report,
154+
0,
155+
self._buttons_state,
156+
self._joy_x,
157+
self._joy_y,
158+
self._joy_z,
159+
self._joy_r_z,
160+
)
154161

155162
if always or self._last_report != self._report:
156163
self._gamepad_device.send_report(self._report)

adafruit_hid/keyboard.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737

3838
_MAX_KEYPRESSES = const(6)
3939

40+
4041
class Keyboard:
4142
"""Send HID keyboard reports."""
4243

@@ -73,7 +74,6 @@ def __init__(self, devices):
7374
time.sleep(1)
7475
self.release_all()
7576

76-
7777
def press(self, *keycodes):
7878
"""Send a report indicating that the given keys have been pressed.
7979

adafruit_hid/keyboard_layout_us.py

Lines changed: 129 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
from .keycode import Keycode
3232

33+
3334
class KeyboardLayoutUS:
3435
"""Map ASCII characters to appropriate keypresses on a standard US PC keyboard.
3536
@@ -51,134 +52,134 @@ class KeyboardLayoutUS:
5152
# \x00 entries have no keyboard key and so won't be sent.
5253
SHIFT_FLAG = 0x80
5354
ASCII_TO_KEYCODE = (
54-
b'\x00' # NUL
55-
b'\x00' # SOH
56-
b'\x00' # STX
57-
b'\x00' # ETX
58-
b'\x00' # EOT
59-
b'\x00' # ENQ
60-
b'\x00' # ACK
61-
b'\x00' # BEL \a
62-
b'\x2a' # BS BACKSPACE \b (called DELETE in the usb.org document)
63-
b'\x2b' # TAB \t
64-
b'\x28' # LF \n (called Return or ENTER in the usb.org document)
65-
b'\x00' # VT \v
66-
b'\x00' # FF \f
67-
b'\x00' # CR \r
68-
b'\x00' # SO
69-
b'\x00' # SI
70-
b'\x00' # DLE
71-
b'\x00' # DC1
72-
b'\x00' # DC2
73-
b'\x00' # DC3
74-
b'\x00' # DC4
75-
b'\x00' # NAK
76-
b'\x00' # SYN
77-
b'\x00' # ETB
78-
b'\x00' # CAN
79-
b'\x00' # EM
80-
b'\x00' # SUB
81-
b'\x29' # ESC
82-
b'\x00' # FS
83-
b'\x00' # GS
84-
b'\x00' # RS
85-
b'\x00' # US
86-
b'\x2c' # SPACE
87-
b'\x9e' # ! x1e|SHIFT_FLAG (shift 1)
88-
b'\xb4' # " x34|SHIFT_FLAG (shift ')
89-
b'\xa0' # # x20|SHIFT_FLAG (shift 3)
90-
b'\xa1' # $ x21|SHIFT_FLAG (shift 4)
91-
b'\xa2' # % x22|SHIFT_FLAG (shift 5)
92-
b'\xa4' # & x24|SHIFT_FLAG (shift 7)
93-
b'\x34' # '
94-
b'\xa6' # ( x26|SHIFT_FLAG (shift 9)
95-
b'\xa7' # ) x27|SHIFT_FLAG (shift 0)
96-
b'\xa5' # * x25|SHIFT_FLAG (shift 8)
97-
b'\xae' # + x2e|SHIFT_FLAG (shift =)
98-
b'\x36' # ,
99-
b'\x2d' # -
100-
b'\x37' # .
101-
b'\x38' # /
102-
b'\x27' # 0
103-
b'\x1e' # 1
104-
b'\x1f' # 2
105-
b'\x20' # 3
106-
b'\x21' # 4
107-
b'\x22' # 5
108-
b'\x23' # 6
109-
b'\x24' # 7
110-
b'\x25' # 8
111-
b'\x26' # 9
112-
b'\xb3' # : x33|SHIFT_FLAG (shift ;)
113-
b'\x33' # ;
114-
b'\xb6' # < x36|SHIFT_FLAG (shift ,)
115-
b'\x2e' # =
116-
b'\xb7' # > x37|SHIFT_FLAG (shift .)
117-
b'\xb8' # ? x38|SHIFT_FLAG (shift /)
118-
b'\x9f' # @ x1f|SHIFT_FLAG (shift 2)
119-
b'\x84' # A x04|SHIFT_FLAG (shift a)
120-
b'\x85' # B x05|SHIFT_FLAG (etc.)
121-
b'\x86' # C x06|SHIFT_FLAG
122-
b'\x87' # D x07|SHIFT_FLAG
123-
b'\x88' # E x08|SHIFT_FLAG
124-
b'\x89' # F x09|SHIFT_FLAG
125-
b'\x8a' # G x0a|SHIFT_FLAG
126-
b'\x8b' # H x0b|SHIFT_FLAG
127-
b'\x8c' # I x0c|SHIFT_FLAG
128-
b'\x8d' # J x0d|SHIFT_FLAG
129-
b'\x8e' # K x0e|SHIFT_FLAG
130-
b'\x8f' # L x0f|SHIFT_FLAG
131-
b'\x90' # M x10|SHIFT_FLAG
132-
b'\x91' # N x11|SHIFT_FLAG
133-
b'\x92' # O x12|SHIFT_FLAG
134-
b'\x93' # P x13|SHIFT_FLAG
135-
b'\x94' # Q x14|SHIFT_FLAG
136-
b'\x95' # R x15|SHIFT_FLAG
137-
b'\x96' # S x16|SHIFT_FLAG
138-
b'\x97' # T x17|SHIFT_FLAG
139-
b'\x98' # U x18|SHIFT_FLAG
140-
b'\x99' # V x19|SHIFT_FLAG
141-
b'\x9a' # W x1a|SHIFT_FLAG
142-
b'\x9b' # X x1b|SHIFT_FLAG
143-
b'\x9c' # Y x1c|SHIFT_FLAG
144-
b'\x9d' # Z x1d|SHIFT_FLAG
145-
b'\x2f' # [
146-
b'\x31' # \ backslash
147-
b'\x30' # ]
148-
b'\xa3' # ^ x23|SHIFT_FLAG (shift 6)
149-
b'\xad' # _ x2d|SHIFT_FLAG (shift -)
150-
b'\x35' # `
151-
b'\x04' # a
152-
b'\x05' # b
153-
b'\x06' # c
154-
b'\x07' # d
155-
b'\x08' # e
156-
b'\x09' # f
157-
b'\x0a' # g
158-
b'\x0b' # h
159-
b'\x0c' # i
160-
b'\x0d' # j
161-
b'\x0e' # k
162-
b'\x0f' # l
163-
b'\x10' # m
164-
b'\x11' # n
165-
b'\x12' # o
166-
b'\x13' # p
167-
b'\x14' # q
168-
b'\x15' # r
169-
b'\x16' # s
170-
b'\x17' # t
171-
b'\x18' # u
172-
b'\x19' # v
173-
b'\x1a' # w
174-
b'\x1b' # x
175-
b'\x1c' # y
176-
b'\x1d' # z
177-
b'\xaf' # { x2f|SHIFT_FLAG (shift [)
178-
b'\xb1' # | x31|SHIFT_FLAG (shift \)
179-
b'\xb0' # } x30|SHIFT_FLAG (shift ])
180-
b'\xb5' # ~ x35|SHIFT_FLAG (shift `)
181-
b'\x4c' # DEL DELETE (called Forward Delete in usb.org document)
55+
b"\x00" # NUL
56+
b"\x00" # SOH
57+
b"\x00" # STX
58+
b"\x00" # ETX
59+
b"\x00" # EOT
60+
b"\x00" # ENQ
61+
b"\x00" # ACK
62+
b"\x00" # BEL \a
63+
b"\x2a" # BS BACKSPACE \b (called DELETE in the usb.org document)
64+
b"\x2b" # TAB \t
65+
b"\x28" # LF \n (called Return or ENTER in the usb.org document)
66+
b"\x00" # VT \v
67+
b"\x00" # FF \f
68+
b"\x00" # CR \r
69+
b"\x00" # SO
70+
b"\x00" # SI
71+
b"\x00" # DLE
72+
b"\x00" # DC1
73+
b"\x00" # DC2
74+
b"\x00" # DC3
75+
b"\x00" # DC4
76+
b"\x00" # NAK
77+
b"\x00" # SYN
78+
b"\x00" # ETB
79+
b"\x00" # CAN
80+
b"\x00" # EM
81+
b"\x00" # SUB
82+
b"\x29" # ESC
83+
b"\x00" # FS
84+
b"\x00" # GS
85+
b"\x00" # RS
86+
b"\x00" # US
87+
b"\x2c" # SPACE
88+
b"\x9e" # ! x1e|SHIFT_FLAG (shift 1)
89+
b"\xb4" # " x34|SHIFT_FLAG (shift ')
90+
b"\xa0" # # x20|SHIFT_FLAG (shift 3)
91+
b"\xa1" # $ x21|SHIFT_FLAG (shift 4)
92+
b"\xa2" # % x22|SHIFT_FLAG (shift 5)
93+
b"\xa4" # & x24|SHIFT_FLAG (shift 7)
94+
b"\x34" # '
95+
b"\xa6" # ( x26|SHIFT_FLAG (shift 9)
96+
b"\xa7" # ) x27|SHIFT_FLAG (shift 0)
97+
b"\xa5" # * x25|SHIFT_FLAG (shift 8)
98+
b"\xae" # + x2e|SHIFT_FLAG (shift =)
99+
b"\x36" # ,
100+
b"\x2d" # -
101+
b"\x37" # .
102+
b"\x38" # /
103+
b"\x27" # 0
104+
b"\x1e" # 1
105+
b"\x1f" # 2
106+
b"\x20" # 3
107+
b"\x21" # 4
108+
b"\x22" # 5
109+
b"\x23" # 6
110+
b"\x24" # 7
111+
b"\x25" # 8
112+
b"\x26" # 9
113+
b"\xb3" # : x33|SHIFT_FLAG (shift ;)
114+
b"\x33" # ;
115+
b"\xb6" # < x36|SHIFT_FLAG (shift ,)
116+
b"\x2e" # =
117+
b"\xb7" # > x37|SHIFT_FLAG (shift .)
118+
b"\xb8" # ? x38|SHIFT_FLAG (shift /)
119+
b"\x9f" # @ x1f|SHIFT_FLAG (shift 2)
120+
b"\x84" # A x04|SHIFT_FLAG (shift a)
121+
b"\x85" # B x05|SHIFT_FLAG (etc.)
122+
b"\x86" # C x06|SHIFT_FLAG
123+
b"\x87" # D x07|SHIFT_FLAG
124+
b"\x88" # E x08|SHIFT_FLAG
125+
b"\x89" # F x09|SHIFT_FLAG
126+
b"\x8a" # G x0a|SHIFT_FLAG
127+
b"\x8b" # H x0b|SHIFT_FLAG
128+
b"\x8c" # I x0c|SHIFT_FLAG
129+
b"\x8d" # J x0d|SHIFT_FLAG
130+
b"\x8e" # K x0e|SHIFT_FLAG
131+
b"\x8f" # L x0f|SHIFT_FLAG
132+
b"\x90" # M x10|SHIFT_FLAG
133+
b"\x91" # N x11|SHIFT_FLAG
134+
b"\x92" # O x12|SHIFT_FLAG
135+
b"\x93" # P x13|SHIFT_FLAG
136+
b"\x94" # Q x14|SHIFT_FLAG
137+
b"\x95" # R x15|SHIFT_FLAG
138+
b"\x96" # S x16|SHIFT_FLAG
139+
b"\x97" # T x17|SHIFT_FLAG
140+
b"\x98" # U x18|SHIFT_FLAG
141+
b"\x99" # V x19|SHIFT_FLAG
142+
b"\x9a" # W x1a|SHIFT_FLAG
143+
b"\x9b" # X x1b|SHIFT_FLAG
144+
b"\x9c" # Y x1c|SHIFT_FLAG
145+
b"\x9d" # Z x1d|SHIFT_FLAG
146+
b"\x2f" # [
147+
b"\x31" # \ backslash
148+
b"\x30" # ]
149+
b"\xa3" # ^ x23|SHIFT_FLAG (shift 6)
150+
b"\xad" # _ x2d|SHIFT_FLAG (shift -)
151+
b"\x35" # `
152+
b"\x04" # a
153+
b"\x05" # b
154+
b"\x06" # c
155+
b"\x07" # d
156+
b"\x08" # e
157+
b"\x09" # f
158+
b"\x0a" # g
159+
b"\x0b" # h
160+
b"\x0c" # i
161+
b"\x0d" # j
162+
b"\x0e" # k
163+
b"\x0f" # l
164+
b"\x10" # m
165+
b"\x11" # n
166+
b"\x12" # o
167+
b"\x13" # p
168+
b"\x14" # q
169+
b"\x15" # r
170+
b"\x16" # s
171+
b"\x17" # t
172+
b"\x18" # u
173+
b"\x19" # v
174+
b"\x1a" # w
175+
b"\x1b" # x
176+
b"\x1c" # y
177+
b"\x1d" # z
178+
b"\xaf" # { x2f|SHIFT_FLAG (shift [)
179+
b"\xb1" # | x31|SHIFT_FLAG (shift \)
180+
b"\xb0" # } x30|SHIFT_FLAG (shift ])
181+
b"\xb5" # ~ x35|SHIFT_FLAG (shift `)
182+
b"\x4c" # DEL DELETE (called Forward Delete in usb.org document)
182183
)
183184

184185
def __init__(self, keyboard):

0 commit comments

Comments
 (0)