Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ran black, updated to pylint 2.x #30

Merged
merged 1 commit into from
Mar 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
source actions-ci/install.sh
- name: Pip install pylint, black, & Sphinx
run: |
pip install --force-reinstall pylint==1.9.2 black==19.10b0 Sphinx sphinx-rtd-theme
pip install --force-reinstall pylint black==19.10b0 Sphinx sphinx-rtd-theme
- name: Library version
run: git describe --dirty --always --tags
- name: PyLint
Expand Down
15 changes: 10 additions & 5 deletions adafruit_pybadger/clue.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@

Buttons = namedtuple("Buttons", "a b")


class Clue(PyBadgerBase):
"""Class that represents a single CLUE."""

_audio_out = audiopwmio.PWMAudioOut
_neopixel_count = 1

Expand All @@ -68,8 +70,10 @@ def __init__(self):
if i2c is not None:
self._accelerometer = adafruit_lsm6ds.LSM6DS33(i2c)

self._buttons = GamePad(digitalio.DigitalInOut(board.BUTTON_A),
digitalio.DigitalInOut(board.BUTTON_B))
self._buttons = GamePad(
digitalio.DigitalInOut(board.BUTTON_A),
digitalio.DigitalInOut(board.BUTTON_B),
)

@property
def button(self):
Expand All @@ -88,9 +92,9 @@ def button(self):
print("Button B")
"""
button_values = self._buttons.get_pressed()
return Buttons(button_values & PyBadgerBase.BUTTON_B,
button_values & PyBadgerBase.BUTTON_A)

return Buttons(
button_values & PyBadgerBase.BUTTON_B, button_values & PyBadgerBase.BUTTON_A
)

@property
def _unsupported(self):
Expand All @@ -103,5 +107,6 @@ def _unsupported(self):
play_file = _unsupported
light = _unsupported


clue = Clue() # pylint: disable=invalid-name
"""Object that is automatically created on import."""
34 changes: 25 additions & 9 deletions adafruit_pybadger/pybadge.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@

Buttons = namedtuple("Buttons", "b a start select right down up left")


class PyBadge(PyBadgerBase):
"""Class that represents a single PyBadge, PyBadge LC, or EdgeBadge."""

Expand All @@ -81,13 +82,17 @@ def __init__(self):
if i2c is not None:
int1 = digitalio.DigitalInOut(board.ACCELEROMETER_INTERRUPT)
try:
self._accelerometer = adafruit_lis3dh.LIS3DH_I2C(i2c, address=0x19, int1=int1)
self._accelerometer = adafruit_lis3dh.LIS3DH_I2C(
i2c, address=0x19, int1=int1
)
except ValueError:
self._accelerometer = adafruit_lis3dh.LIS3DH_I2C(i2c, int1=int1)

self._buttons = GamePadShift(digitalio.DigitalInOut(board.BUTTON_CLOCK),
digitalio.DigitalInOut(board.BUTTON_OUT),
digitalio.DigitalInOut(board.BUTTON_LATCH))
self._buttons = GamePadShift(
digitalio.DigitalInOut(board.BUTTON_CLOCK),
digitalio.DigitalInOut(board.BUTTON_OUT),
digitalio.DigitalInOut(board.BUTTON_LATCH),
)

self._light_sensor = analogio.AnalogIn(board.A7)

Expand All @@ -113,11 +118,22 @@ def button(self):

"""
button_values = self._buttons.get_pressed()
return Buttons(*[button_values & button for button in
(PyBadgerBase.BUTTON_B, PyBadgerBase.BUTTON_A,
PyBadgerBase.BUTTON_START, PyBadgerBase.BUTTON_SELECT,
PyBadgerBase.BUTTON_RIGHT, PyBadgerBase.BUTTON_DOWN,
PyBadgerBase.BUTTON_UP, PyBadgerBase.BUTTON_LEFT)])
return Buttons(
*[
button_values & button
for button in (
PyBadgerBase.BUTTON_B,
PyBadgerBase.BUTTON_A,
PyBadgerBase.BUTTON_START,
PyBadgerBase.BUTTON_SELECT,
PyBadgerBase.BUTTON_RIGHT,
PyBadgerBase.BUTTON_DOWN,
PyBadgerBase.BUTTON_UP,
PyBadgerBase.BUTTON_LEFT,
)
]
)


pybadge = PyBadge() # pylint: disable=invalid-name
"""Object that is automatically created on import."""
Loading