From 5d2e74eb9770216a3fa5e967e4ed84438f444fcf Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Mon, 24 Aug 2020 00:42:34 +0200 Subject: [PATCH] LINT fixes for LCD plugins --- platypush/plugins/lcd/__init__.py | 20 +++++--------------- platypush/plugins/lcd/gpio.py | 1 - platypush/plugins/lcd/i2c.py | 3 +-- 3 files changed, 6 insertions(+), 18 deletions(-) diff --git a/platypush/plugins/lcd/__init__.py b/platypush/plugins/lcd/__init__.py index 275e9239a3..933ff2fd0a 100644 --- a/platypush/plugins/lcd/__init__.py +++ b/platypush/plugins/lcd/__init__.py @@ -1,16 +1,9 @@ from abc import ABC, abstractmethod -from enum import Enum from typing import List, Optional from platypush.plugins import Plugin, action -class PinMode(Enum): - import RPi.GPIO - BOARD = RPi.GPIO.BOARD - BCM = RPi.GPIO.BCM - - class LcdPlugin(Plugin, ABC): """ Abstract class for plugins to communicate with LCD displays. @@ -21,23 +14,20 @@ class LcdPlugin(Plugin, ABC): * **RPi.GPIO** (``pip install RPi.GPIO``) """ - import RPLCD.lcd - def __init__(self, **kwargs): super().__init__(**kwargs) self.lcd = None @staticmethod def _get_pin_mode(pin_mode: str) -> int: + import RPi.GPIO + pin_modes = ['BOARD', 'BCM'] pin_mode = pin_mode.upper() - assert hasattr(PinMode, pin_mode), \ - 'Invalid pin_mode: {}. Supported modes: {}'.format( - pin_mode, list([mode.name for mode in PinMode if mode.name != 'RPi'])) - - return getattr(PinMode, pin_mode).value + assert pin_mode in pin_modes, 'Invalid pin_mode: {}. Supported modes: {}'.format(pin_mode, pin_modes) + return getattr(RPi.GPIO, pin_mode).value @abstractmethod - def _get_lcd(self) -> RPLCD.lcd.BaseCharLCD: + def _get_lcd(self): pass def _init_lcd(self): diff --git a/platypush/plugins/lcd/gpio.py b/platypush/plugins/lcd/gpio.py index 2f17208702..1fe9f024ff 100644 --- a/platypush/plugins/lcd/gpio.py +++ b/platypush/plugins/lcd/gpio.py @@ -1,6 +1,5 @@ from typing import List, Optional -from platypush.plugins import action from platypush.plugins.lcd import LcdPlugin diff --git a/platypush/plugins/lcd/i2c.py b/platypush/plugins/lcd/i2c.py index 1b6b85cb68..f76e9b8e66 100644 --- a/platypush/plugins/lcd/i2c.py +++ b/platypush/plugins/lcd/i2c.py @@ -1,6 +1,5 @@ -from typing import List, Optional +from typing import Optional -from platypush.plugins import action from platypush.plugins.lcd import LcdPlugin