From b187ca93d02f3dea2e8f4f12fb8c29ad6b7a9b12 Mon Sep 17 00:00:00 2001 From: Tomasz Jagusz Date: Thu, 17 Oct 2019 12:24:53 +0200 Subject: [PATCH] Move imports in rpi_gpio (#27752) * move imports for rpi_gpio * fixed pylint error * fix pylint error * removed empty line * add missing blank line * sort with isort --- homeassistant/components/rpi_gpio/__init__.py | 13 ++----------- homeassistant/components/rpi_gpio/binary_sensor.py | 2 +- homeassistant/components/rpi_gpio/cover.py | 4 ++-- 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/homeassistant/components/rpi_gpio/__init__.py b/homeassistant/components/rpi_gpio/__init__.py index 31509614df4..ed7eefbb1fe 100644 --- a/homeassistant/components/rpi_gpio/__init__.py +++ b/homeassistant/components/rpi_gpio/__init__.py @@ -1,6 +1,8 @@ """Support for controlling GPIO pins of a Raspberry Pi.""" import logging +from RPi import GPIO # pylint: disable=import-error + from homeassistant.const import EVENT_HOMEASSISTANT_START, EVENT_HOMEASSISTANT_STOP _LOGGER = logging.getLogger(__name__) @@ -10,7 +12,6 @@ DOMAIN = "rpi_gpio" def setup(hass, config): """Set up the Raspberry PI GPIO component.""" - from RPi import GPIO # pylint: disable=import-error def cleanup_gpio(event): """Stuff to do before stopping.""" @@ -27,34 +28,24 @@ def setup(hass, config): def setup_output(port): """Set up a GPIO as output.""" - from RPi import GPIO # pylint: disable=import-error - GPIO.setup(port, GPIO.OUT) def setup_input(port, pull_mode): """Set up a GPIO as input.""" - from RPi import GPIO # pylint: disable=import-error - GPIO.setup(port, GPIO.IN, GPIO.PUD_DOWN if pull_mode == "DOWN" else GPIO.PUD_UP) def write_output(port, value): """Write a value to a GPIO.""" - from RPi import GPIO # pylint: disable=import-error - GPIO.output(port, value) def read_input(port): """Read a value from a GPIO.""" - from RPi import GPIO # pylint: disable=import-error - return GPIO.input(port) def edge_detect(port, event_callback, bounce): """Add detection for RISING and FALLING events.""" - from RPi import GPIO # pylint: disable=import-error - GPIO.add_event_detect(port, GPIO.BOTH, callback=event_callback, bouncetime=bounce) diff --git a/homeassistant/components/rpi_gpio/binary_sensor.py b/homeassistant/components/rpi_gpio/binary_sensor.py index 4acbed9a0fa..3e38da47eed 100644 --- a/homeassistant/components/rpi_gpio/binary_sensor.py +++ b/homeassistant/components/rpi_gpio/binary_sensor.py @@ -4,7 +4,7 @@ import logging import voluptuous as vol from homeassistant.components import rpi_gpio -from homeassistant.components.binary_sensor import BinarySensorDevice, PLATFORM_SCHEMA +from homeassistant.components.binary_sensor import PLATFORM_SCHEMA, BinarySensorDevice from homeassistant.const import DEVICE_DEFAULT_NAME import homeassistant.helpers.config_validation as cv diff --git a/homeassistant/components/rpi_gpio/cover.py b/homeassistant/components/rpi_gpio/cover.py index 83cc497324d..648171b9738 100644 --- a/homeassistant/components/rpi_gpio/cover.py +++ b/homeassistant/components/rpi_gpio/cover.py @@ -4,9 +4,9 @@ from time import sleep import voluptuous as vol -from homeassistant.components.cover import CoverDevice, PLATFORM_SCHEMA -from homeassistant.const import CONF_NAME from homeassistant.components import rpi_gpio +from homeassistant.components.cover import PLATFORM_SCHEMA, CoverDevice +from homeassistant.const import CONF_NAME import homeassistant.helpers.config_validation as cv _LOGGER = logging.getLogger(__name__)