From 43048962f25bac7a59e169740b7a4ae1c7a925a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Thu, 25 Oct 2018 23:15:20 +0300 Subject: [PATCH] Upgrade flake8 to 3.6.0 (#17770) * Upgrade flake8 to 3.6.0 * flake8/pylint comment tweaks * flake8 F841 fixes * flake8 W605 fix * Ignore pyflakes bug #373 false positives https://github.com/PyCQA/pyflakes/issues/373 * pycodestyle bug #811 workaround https://github.com/PyCQA/pycodestyle/issues/811 --- homeassistant/components/cloud/auth_api.py | 2 +- homeassistant/components/cover/garadget.py | 4 ++-- homeassistant/components/device_tracker/__init__.py | 4 ++-- homeassistant/components/device_tracker/tplink.py | 2 +- homeassistant/components/google_assistant/smart_home.py | 2 +- homeassistant/components/light/tplink.py | 3 ++- homeassistant/components/light/yeelight.py | 3 ++- homeassistant/components/mqtt/__init__.py | 2 +- homeassistant/components/sensor/tcp.py | 2 +- homeassistant/components/snips.py | 2 +- homeassistant/components/zwave/__init__.py | 2 +- homeassistant/helpers/service.py | 2 +- requirements_test.txt | 2 +- requirements_test_all.txt | 2 +- script/gen_requirements_all.py | 2 +- 15 files changed, 19 insertions(+), 17 deletions(-) diff --git a/homeassistant/components/cloud/auth_api.py b/homeassistant/components/cloud/auth_api.py index 042b90bf9cb..954d28b803f 100644 --- a/homeassistant/components/cloud/auth_api.py +++ b/homeassistant/components/cloud/auth_api.py @@ -144,7 +144,7 @@ def _authenticate(cloud, email, password): cognito.authenticate(password=password) return cognito - except ForceChangePasswordException as err: + except ForceChangePasswordException: raise PasswordChangeRequired except ClientError as err: diff --git a/homeassistant/components/cover/garadget.py b/homeassistant/components/cover/garadget.py index 7a04aa4c71a..03756a971bc 100644 --- a/homeassistant/components/cover/garadget.py +++ b/homeassistant/components/cover/garadget.py @@ -106,7 +106,7 @@ class GaradgetCover(CoverDevice): self._state = STATE_OFFLINE self._available = False self._name = DEFAULT_NAME - except KeyError as ex: + except KeyError: _LOGGER.warning("Garadget device %(device)s seems to be offline", dict(device=self.device_id)) self._name = DEFAULT_NAME @@ -235,7 +235,7 @@ class GaradgetCover(CoverDevice): _LOGGER.error( "Unable to connect to server: %(reason)s", dict(reason=ex)) self._state = STATE_OFFLINE - except KeyError as ex: + except KeyError: _LOGGER.warning("Garadget device %(device)s seems to be offline", dict(device=self.device_id)) self._state = STATE_OFFLINE diff --git a/homeassistant/components/device_tracker/__init__.py b/homeassistant/components/device_tracker/__init__.py index cbf32b4cd5a..82a9fefbb71 100644 --- a/homeassistant/components/device_tracker/__init__.py +++ b/homeassistant/components/device_tracker/__init__.py @@ -699,8 +699,8 @@ def async_setup_scanner_platform(hass: HomeAssistantType, config: ConfigType, seen.add(mac) try: - extra_attributes = (await - scanner.async_get_extra_attributes(mac)) + extra_attributes = \ + await scanner.async_get_extra_attributes(mac) except NotImplementedError: extra_attributes = dict() diff --git a/homeassistant/components/device_tracker/tplink.py b/homeassistant/components/device_tracker/tplink.py index 9bf85e39faf..78f16a82d56 100644 --- a/homeassistant/components/device_tracker/tplink.py +++ b/homeassistant/components/device_tracker/tplink.py @@ -254,7 +254,7 @@ class Tplink3DeviceScanner(Tplink1DeviceScanner): self.sysauth = regex_result.group(1) _LOGGER.info(self.sysauth) return True - except (ValueError, KeyError) as _: + except (ValueError, KeyError): _LOGGER.error("Couldn't fetch auth tokens! Response was: %s", response.text) return False diff --git a/homeassistant/components/google_assistant/smart_home.py b/homeassistant/components/google_assistant/smart_home.py index 1cb4bf4cb32..9c8f949b175 100644 --- a/homeassistant/components/google_assistant/smart_home.py +++ b/homeassistant/components/google_assistant/smart_home.py @@ -213,7 +213,7 @@ async def _process(hass, config, message): 'requestId': request_id, 'payload': {'errorCode': err.code} } - except Exception as err: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except _LOGGER.exception('Unexpected error') return { 'requestId': request_id, diff --git a/homeassistant/components/light/tplink.py b/homeassistant/components/light/tplink.py index 0cc02e82b65..b0f4c6d1a3c 100644 --- a/homeassistant/components/light/tplink.py +++ b/homeassistant/components/light/tplink.py @@ -56,7 +56,8 @@ def brightness_from_percentage(percent): class TPLinkSmartBulb(Light): """Representation of a TPLink Smart Bulb.""" - def __init__(self, smartbulb: 'SmartBulb', name) -> None: + # F821: https://github.com/PyCQA/pyflakes/issues/373 + def __init__(self, smartbulb: 'SmartBulb', name) -> None: # noqa: F821 """Initialize the bulb.""" self.smartbulb = smartbulb self._name = name diff --git a/homeassistant/components/light/yeelight.py b/homeassistant/components/light/yeelight.py index 7efd62e3de5..1275d854e0b 100644 --- a/homeassistant/components/light/yeelight.py +++ b/homeassistant/components/light/yeelight.py @@ -278,8 +278,9 @@ class YeelightLight(Light): def _properties(self) -> dict: return self._bulb.last_properties + # F821: https://github.com/PyCQA/pyflakes/issues/373 @property - def _bulb(self) -> 'yeelight.Bulb': + def _bulb(self) -> 'yeelight.Bulb': # noqa: F821 import yeelight if self._bulb_device is None: try: diff --git a/homeassistant/components/mqtt/__init__.py b/homeassistant/components/mqtt/__init__.py index 2f1895019dd..e06e025c7ab 100644 --- a/homeassistant/components/mqtt/__init__.py +++ b/homeassistant/components/mqtt/__init__.py @@ -35,7 +35,7 @@ from homeassistant.util.async_ import ( run_callback_threadsafe, run_coroutine_threadsafe) # Loading the config flow file will register the flow -from . import config_flow # noqa # pylint: disable=unused-import +from . import config_flow # noqa pylint: disable=unused-import from .const import CONF_BROKER, CONF_DISCOVERY, DEFAULT_DISCOVERY from .server import HBMQTT_CONFIG_SCHEMA diff --git a/homeassistant/components/sensor/tcp.py b/homeassistant/components/sensor/tcp.py index 19197c06295..d214bd3d425 100644 --- a/homeassistant/components/sensor/tcp.py +++ b/homeassistant/components/sensor/tcp.py @@ -130,7 +130,7 @@ class TcpSensor(Entity): self._state = self._config[CONF_VALUE_TEMPLATE].render( value=value) return - except TemplateError as err: + except TemplateError: _LOGGER.error( "Unable to render template of %r with value: %r", self._config[CONF_VALUE_TEMPLATE], value) diff --git a/homeassistant/components/snips.py b/homeassistant/components/snips.py index 88a93408056..1aebeae59cb 100644 --- a/homeassistant/components/snips.py +++ b/homeassistant/components/snips.py @@ -142,7 +142,7 @@ async def async_setup(hass, config): hass, DOMAIN, intent_type, slots, request['input']) if 'plain' in intent_response.speech: snips_response = intent_response.speech['plain']['speech'] - except intent.UnknownIntent as err: + except intent.UnknownIntent: _LOGGER.warning("Received unknown intent %s", request['intent']['intentName']) except intent.IntentError: diff --git a/homeassistant/components/zwave/__init__.py b/homeassistant/components/zwave/__init__.py index 1743abaf810..e91ba244ce8 100644 --- a/homeassistant/components/zwave/__init__.py +++ b/homeassistant/components/zwave/__init__.py @@ -29,7 +29,7 @@ from homeassistant.helpers.dispatcher import ( async_dispatcher_connect, async_dispatcher_send) from . import const -from . import config_flow # noqa # pylint: disable=unused-import +from . import config_flow # noqa pylint: disable=unused-import from .const import ( CONF_AUTOHEAL, CONF_DEBUG, CONF_POLLING_INTERVAL, CONF_USB_STICK_PATH, CONF_CONFIG_PATH, CONF_NETWORK_KEY, diff --git a/homeassistant/helpers/service.py b/homeassistant/helpers/service.py index 3abf1dab59e..0f394a6f153 100644 --- a/homeassistant/helpers/service.py +++ b/homeassistant/helpers/service.py @@ -56,7 +56,7 @@ async def async_call_from_config(hass, config, blocking=False, variables=None, except TemplateError as ex: _LOGGER.error('Error rendering service name template: %s', ex) return - except vol.Invalid as ex: + except vol.Invalid: _LOGGER.error('Template rendered invalid service: %s', domain_service) return diff --git a/requirements_test.txt b/requirements_test.txt index 5d5d1c4fd04..29e31c977ac 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -4,7 +4,7 @@ asynctest==0.12.2 coveralls==1.2.0 flake8-docstrings==1.3.0 -flake8==3.5 +flake8==3.6.0 mock-open==1.3.1 mypy==0.641 pydocstyle==2.1.1 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 61bd3db0276..e81e8664856 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -5,7 +5,7 @@ asynctest==0.12.2 coveralls==1.2.0 flake8-docstrings==1.3.0 -flake8==3.5 +flake8==3.6.0 mock-open==1.3.1 mypy==0.641 pydocstyle==2.1.1 diff --git a/script/gen_requirements_all.py b/script/gen_requirements_all.py index 491531ee12b..945bc60b4ea 100755 --- a/script/gen_requirements_all.py +++ b/script/gen_requirements_all.py @@ -90,7 +90,7 @@ TEST_REQUIREMENTS = ( 'pyspcwebgw', 'python-forecastio', 'python-nest', - 'pytradfri\[async\]', + 'pytradfri\\[async\\]', 'pyunifi', 'pyupnp-async', 'pywebpush',