diff --git a/.travis.yml b/.travis.yml index bcf4f7e1cb9..88bc8b707cf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,7 +31,8 @@ jobs: - python: "3.7.1" env: TOXENV=lint - python: "3.7.1" - env: TOXENV=pylint PYLINT_ARGS=--jobs=0 TRAVIS_WAIT=30 + # PYLINT_ARGS=--jobs=0 disabled for now: https://github.com/PyCQA/pylint/issues/3584 + env: TOXENV=pylint TRAVIS_WAIT=30 - python: "3.7.1" env: TOXENV=typing diff --git a/homeassistant/auth/permissions/__init__.py b/homeassistant/auth/permissions/__init__.py index 92d02c75b91..2f887d21b02 100644 --- a/homeassistant/auth/permissions/__init__.py +++ b/homeassistant/auth/permissions/__init__.py @@ -72,4 +72,4 @@ class _OwnerPermissions(AbstractPermissions): return lambda entity_id, key: True -OwnerPermissions = _OwnerPermissions() # pylint: disable=invalid-name +OwnerPermissions = _OwnerPermissions() diff --git a/homeassistant/components/acmeda/config_flow.py b/homeassistant/components/acmeda/config_flow.py index 33dac4814e5..816768b0800 100644 --- a/homeassistant/components/acmeda/config_flow.py +++ b/homeassistant/components/acmeda/config_flow.py @@ -26,10 +26,8 @@ class AcmedaFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): if ( user_input is not None and self.discovered_hubs is not None - # pylint: disable=unsupported-membership-test and user_input["id"] in self.discovered_hubs ): - # pylint: disable=unsubscriptable-object return await self.async_create(self.discovered_hubs[user_input["id"]]) # Already configured hosts diff --git a/homeassistant/components/almond/config_flow.py b/homeassistant/components/almond/config_flow.py index 73dc85c5fd0..0421612b702 100644 --- a/homeassistant/components/almond/config_flow.py +++ b/homeassistant/components/almond/config_flow.py @@ -11,7 +11,7 @@ from yarl import URL from homeassistant import config_entries, core, data_entry_flow from homeassistant.helpers import aiohttp_client, config_entry_oauth2_flow -from .const import DOMAIN, TYPE_LOCAL, TYPE_OAUTH2 +from .const import DOMAIN as ALMOND_DOMAIN, TYPE_LOCAL, TYPE_OAUTH2 async def async_verify_local_connection(hass: core.HomeAssistant, host: str): @@ -28,11 +28,11 @@ async def async_verify_local_connection(hass: core.HomeAssistant, host: str): return False -@config_entries.HANDLERS.register(DOMAIN) +@config_entries.HANDLERS.register(ALMOND_DOMAIN) class AlmondFlowHandler(config_entry_oauth2_flow.AbstractOAuth2FlowHandler): """Implementation of the Almond OAuth2 config flow.""" - DOMAIN = DOMAIN + DOMAIN = ALMOND_DOMAIN host = None hassio_discovery = None diff --git a/homeassistant/components/androidtv/media_player.py b/homeassistant/components/androidtv/media_player.py index 0d39d528cca..a46685a1c65 100644 --- a/homeassistant/components/androidtv/media_player.py +++ b/homeassistant/components/androidtv/media_player.py @@ -374,7 +374,7 @@ def adb_decorator(override_available=False): err, ) await self.aftv.adb_close() - self._available = False # pylint: disable=protected-access + self._available = False return None return _adb_exception_catcher diff --git a/homeassistant/components/apache_kafka/__init__.py b/homeassistant/components/apache_kafka/__init__.py index 7bd23630bd0..c64e2159977 100644 --- a/homeassistant/components/apache_kafka/__init__.py +++ b/homeassistant/components/apache_kafka/__init__.py @@ -64,7 +64,7 @@ class DateTimeJSONEncoder(json.JSONEncoder): Additionally add encoding for datetime objects as isoformat. """ - def default(self, o): # pylint: disable=method-hidden + def default(self, o): """Implement encoding logic.""" if isinstance(o, datetime): return o.isoformat() diff --git a/homeassistant/components/apple_tv/__init__.py b/homeassistant/components/apple_tv/__init__.py index aae4165fe5f..80c09606dbf 100644 --- a/homeassistant/components/apple_tv/__init__.py +++ b/homeassistant/components/apple_tv/__init__.py @@ -39,7 +39,7 @@ NOTIFICATION_AUTH_TITLE = "Apple TV Authentication" NOTIFICATION_SCAN_ID = "apple_tv_scan_notification" NOTIFICATION_SCAN_TITLE = "Apple TV Scan" -T = TypeVar("T") # pylint: disable=invalid-name +T = TypeVar("T") # This version of ensure_list interprets an empty dict as no value diff --git a/homeassistant/components/avea/light.py b/homeassistant/components/avea/light.py index 8f57fb08e96..c3f6e19c2e2 100644 --- a/homeassistant/components/avea/light.py +++ b/homeassistant/components/avea/light.py @@ -1,7 +1,7 @@ """Support for the Elgato Avea lights.""" import logging -import avea +import avea # pylint: disable=import-error from homeassistant.components.light import ( ATTR_BRIGHTNESS, diff --git a/homeassistant/components/beewi_smartclim/sensor.py b/homeassistant/components/beewi_smartclim/sensor.py index ec124b24971..b4dcc289a7b 100644 --- a/homeassistant/components/beewi_smartclim/sensor.py +++ b/homeassistant/components/beewi_smartclim/sensor.py @@ -1,7 +1,7 @@ """Platform for beewi_smartclim integration.""" import logging -from beewi_smartclim import BeewiSmartClimPoller +from beewi_smartclim import BeewiSmartClimPoller # pylint: disable=import-error import voluptuous as vol from homeassistant.components.sensor import PLATFORM_SCHEMA diff --git a/homeassistant/components/conversation/__init__.py b/homeassistant/components/conversation/__init__.py index dd17eca6792..f8534d99935 100644 --- a/homeassistant/components/conversation/__init__.py +++ b/homeassistant/components/conversation/__init__.py @@ -41,7 +41,7 @@ CONFIG_SCHEMA = vol.Schema( extra=vol.ALLOW_EXTRA, ) -async_register = bind_hass(async_register) # pylint: disable=invalid-name +async_register = bind_hass(async_register) @core.callback diff --git a/homeassistant/components/decora/light.py b/homeassistant/components/decora/light.py index b9bf09f0c6d..4335c99076a 100644 --- a/homeassistant/components/decora/light.py +++ b/homeassistant/components/decora/light.py @@ -4,7 +4,9 @@ from functools import wraps import logging import time -from bluepy.btle import BTLEException # pylint: disable=import-error, no-member +from bluepy.btle import ( # pylint: disable=import-error, no-member, no-name-in-module + BTLEException, +) import decora # pylint: disable=import-error, no-member import voluptuous as vol diff --git a/homeassistant/components/dialogflow/__init__.py b/homeassistant/components/dialogflow/__init__.py index ae3c0288aed..b9ba977e422 100644 --- a/homeassistant/components/dialogflow/__init__.py +++ b/homeassistant/components/dialogflow/__init__.py @@ -80,7 +80,6 @@ async def async_unload_entry(hass, entry): return True -# pylint: disable=invalid-name async_remove_entry = config_entry_flow.webhook_async_remove_entry diff --git a/homeassistant/components/eq3btsmart/climate.py b/homeassistant/components/eq3btsmart/climate.py index 402dfc684b3..6eb0276c314 100644 --- a/homeassistant/components/eq3btsmart/climate.py +++ b/homeassistant/components/eq3btsmart/climate.py @@ -1,8 +1,7 @@ """Support for eQ-3 Bluetooth Smart thermostats.""" import logging -# pylint: disable=import-error -from bluepy.btle import BTLEException +from bluepy.btle import BTLEException # pylint: disable=import-error, no-name-in-module import eq3bt as eq3 # pylint: disable=import-error import voluptuous as vol diff --git a/homeassistant/components/esphome/__init__.py b/homeassistant/components/esphome/__init__.py index cdc9074c5ab..4248366ffad 100644 --- a/homeassistant/components/esphome/__init__.py +++ b/homeassistant/components/esphome/__init__.py @@ -433,7 +433,6 @@ def esphome_state_property(func): @property def _wrapper(self): - # pylint: disable=protected-access if self._state is None: return None val = func(self) diff --git a/homeassistant/components/flume/config_flow.py b/homeassistant/components/flume/config_flow.py index 80f1698a7e6..e0e5bf8efe9 100644 --- a/homeassistant/components/flume/config_flow.py +++ b/homeassistant/components/flume/config_flow.py @@ -59,7 +59,7 @@ async def validate_input(hass: core.HomeAssistant, data): flume_devices = await hass.async_add_executor_job(FlumeDeviceList, flume_auth) except RequestException as err: raise CannotConnect from err - except Exception as err: # pylint: disable=broad-except + except Exception as err: raise InvalidAuth from err if not flume_devices or not flume_devices.device_list: raise CannotConnect diff --git a/homeassistant/components/geofency/__init__.py b/homeassistant/components/geofency/__init__.py index cb663676512..50a7d8ac577 100644 --- a/homeassistant/components/geofency/__init__.py +++ b/homeassistant/components/geofency/__init__.py @@ -154,5 +154,4 @@ async def async_unload_entry(hass, entry): return True -# pylint: disable=invalid-name async_remove_entry = config_entry_flow.webhook_async_remove_entry diff --git a/homeassistant/components/google_assistant/trait.py b/homeassistant/components/google_assistant/trait.py index f7aa2d43663..569b12e4730 100644 --- a/homeassistant/components/google_assistant/trait.py +++ b/homeassistant/components/google_assistant/trait.py @@ -1715,7 +1715,7 @@ class VolumeTrait(_Trait): svc = media_player.SERVICE_VOLUME_DOWN relative = -relative - for i in range(relative): + for _ in range(relative): await self.hass.services.async_call( media_player.DOMAIN, svc, diff --git a/homeassistant/components/google_pubsub/__init__.py b/homeassistant/components/google_pubsub/__init__.py index bc7811a7a8f..8d7a675860c 100644 --- a/homeassistant/components/google_pubsub/__init__.py +++ b/homeassistant/components/google_pubsub/__init__.py @@ -89,7 +89,7 @@ class DateTimeJSONEncoder(json.JSONEncoder): Additionally add encoding for datetime objects as isoformat. """ - def default(self, o): # pylint: disable=method-hidden + def default(self, o): """Implement encoding logic.""" if isinstance(o, datetime.datetime): return o.isoformat() diff --git a/homeassistant/components/gpslogger/__init__.py b/homeassistant/components/gpslogger/__init__.py index aa95d17cbfc..f09a7f86d2a 100644 --- a/homeassistant/components/gpslogger/__init__.py +++ b/homeassistant/components/gpslogger/__init__.py @@ -116,5 +116,4 @@ async def async_unload_entry(hass, entry): return True -# pylint: disable=invalid-name async_remove_entry = config_entry_flow.webhook_async_remove_entry diff --git a/homeassistant/components/habitica/__init__.py b/homeassistant/components/habitica/__init__.py index ac504821b35..b2c3fb16831 100644 --- a/homeassistant/components/habitica/__init__.py +++ b/homeassistant/components/habitica/__init__.py @@ -49,7 +49,7 @@ INSTANCE_SCHEMA = vol.Schema( } ) -has_unique_values = vol.Schema(vol.Unique()) # pylint: disable=invalid-name +has_unique_values = vol.Schema(vol.Unique()) # because we want a handy alias diff --git a/homeassistant/components/hdmi_cec/__init__.py b/homeassistant/components/hdmi_cec/__init__.py index c9a5d27a3be..c272ad19c8d 100644 --- a/homeassistant/components/hdmi_cec/__init__.py +++ b/homeassistant/components/hdmi_cec/__init__.py @@ -4,9 +4,13 @@ from functools import reduce import logging import multiprocessing -from pycec.cec import CecAdapter -from pycec.commands import CecCommand, KeyPressCommand, KeyReleaseCommand -from pycec.const import ( +from pycec.cec import CecAdapter # pylint: disable=import-error +from pycec.commands import ( # pylint: disable=import-error + CecCommand, + KeyPressCommand, + KeyReleaseCommand, +) +from pycec.const import ( # pylint: disable=import-error ADDR_AUDIOSYSTEM, ADDR_BROADCAST, ADDR_UNREGISTERED, @@ -21,8 +25,8 @@ from pycec.const import ( STATUS_STILL, STATUS_STOP, ) -from pycec.network import HDMINetwork, PhysicalAddress -from pycec.tcp import TcpAdapter +from pycec.network import HDMINetwork, PhysicalAddress # pylint: disable=import-error +from pycec.tcp import TcpAdapter # pylint: disable=import-error import voluptuous as vol from homeassistant.components.media_player import DOMAIN as MEDIA_PLAYER diff --git a/homeassistant/components/hdmi_cec/media_player.py b/homeassistant/components/hdmi_cec/media_player.py index c3cab6a8f98..f81ee20afe3 100644 --- a/homeassistant/components/hdmi_cec/media_player.py +++ b/homeassistant/components/hdmi_cec/media_player.py @@ -1,8 +1,12 @@ """Support for HDMI CEC devices as media players.""" import logging -from pycec.commands import CecCommand, KeyPressCommand, KeyReleaseCommand -from pycec.const import ( +from pycec.commands import ( # pylint: disable=import-error + CecCommand, + KeyPressCommand, + KeyReleaseCommand, +) +from pycec.const import ( # pylint: disable=import-error KEY_BACKWARD, KEY_FORWARD, KEY_MUTE_TOGGLE, diff --git a/homeassistant/components/homekit/__init__.py b/homeassistant/components/homekit/__init__.py index e8360b1d73b..f72cb082671 100644 --- a/homeassistant/components/homekit/__init__.py +++ b/homeassistant/components/homekit/__init__.py @@ -723,7 +723,6 @@ class HomeKitPairingQRView(HomeAssistantView): name = "api:homekit:pairingqr" requires_auth = False - # pylint: disable=no-self-use async def get(self, request): """Retrieve the pairing QRCode image.""" if not request.query_string: diff --git a/homeassistant/components/ifttt/__init__.py b/homeassistant/components/ifttt/__init__.py index 4c579033fff..9e77e49709c 100644 --- a/homeassistant/components/ifttt/__init__.py +++ b/homeassistant/components/ifttt/__init__.py @@ -123,5 +123,4 @@ async def async_unload_entry(hass, entry): return True -# pylint: disable=invalid-name async_remove_entry = config_entry_flow.webhook_async_remove_entry diff --git a/homeassistant/components/itunes/media_player.py b/homeassistant/components/itunes/media_player.py index 707cac6f953..a62930ff9dc 100644 --- a/homeassistant/components/itunes/media_player.py +++ b/homeassistant/components/itunes/media_player.py @@ -388,7 +388,7 @@ class ItunesDevice(MediaPlayerEntity): def media_next_track(self): """Send media_next command to media player.""" - response = self.client.next() + response = self.client.next() # pylint: disable=not-callable self.update_state(response) def media_previous_track(self): diff --git a/homeassistant/components/knx/light.py b/homeassistant/components/knx/light.py index ac0bf2122a8..2fc53fa3b7c 100644 --- a/homeassistant/components/knx/light.py +++ b/homeassistant/components/knx/light.py @@ -94,7 +94,6 @@ class KNXLight(LightEntity): return self.device.current_brightness hsv_color = self._hsv_color if self.device.supports_color and hsv_color: - # pylint: disable=unsubscriptable-object return round(hsv_color[-1] / 100 * 255) return None diff --git a/homeassistant/components/light/__init__.py b/homeassistant/components/light/__init__.py index b97e9e90248..723967b3d51 100644 --- a/homeassistant/components/light/__init__.py +++ b/homeassistant/components/light/__init__.py @@ -442,7 +442,6 @@ class LightEntity(ToggleEntity): data[ATTR_COLOR_TEMP] = self.color_temp if supported_features & SUPPORT_COLOR and self.hs_color: - # pylint: disable=unsubscriptable-object,not-an-iterable hs_color = self.hs_color data[ATTR_HS_COLOR] = (round(hs_color[0], 3), round(hs_color[1], 3)) data[ATTR_RGB_COLOR] = color_util.color_hs_to_RGB(*hs_color) diff --git a/homeassistant/components/limitlessled/light.py b/homeassistant/components/limitlessled/light.py index 682d619a92c..6dbaf0c3b7c 100644 --- a/homeassistant/components/limitlessled/light.py +++ b/homeassistant/components/limitlessled/light.py @@ -176,7 +176,7 @@ def state(new_state): def decorator(function): """Set up the decorator function.""" - # pylint: disable=protected-access + def wrapper(self, **kwargs): """Wrap a group state change.""" diff --git a/homeassistant/components/locative/__init__.py b/homeassistant/components/locative/__init__.py index 978f50b0ffd..28af822ae63 100644 --- a/homeassistant/components/locative/__init__.py +++ b/homeassistant/components/locative/__init__.py @@ -128,5 +128,4 @@ async def async_unload_entry(hass, entry): return await hass.config_entries.async_forward_entry_unload(entry, DEVICE_TRACKER) -# pylint: disable=invalid-name async_remove_entry = config_entry_flow.webhook_async_remove_entry diff --git a/homeassistant/components/lutron_caseta/binary_sensor.py b/homeassistant/components/lutron_caseta/binary_sensor.py index b517dda1ba3..cb50cb1a6e8 100644 --- a/homeassistant/components/lutron_caseta/binary_sensor.py +++ b/homeassistant/components/lutron_caseta/binary_sensor.py @@ -64,7 +64,7 @@ class LutronOccupancySensor(LutronCasetaDevice, BinarySensorEntity): sensors by each room. Therefore, there shouldn't be devices related to any sensor entities. """ - return None # pylint: disable=useless-return + return None @property def device_state_attributes(self): diff --git a/homeassistant/components/mailgun/__init__.py b/homeassistant/components/mailgun/__init__.py index 57c83d8c20c..42b51c23c74 100644 --- a/homeassistant/components/mailgun/__init__.py +++ b/homeassistant/components/mailgun/__init__.py @@ -95,5 +95,4 @@ async def async_unload_entry(hass, entry): return True -# pylint: disable=invalid-name async_remove_entry = config_entry_flow.webhook_async_remove_entry diff --git a/homeassistant/components/miflora/sensor.py b/homeassistant/components/miflora/sensor.py index 8ed4d02ea1d..3b5d7166425 100644 --- a/homeassistant/components/miflora/sensor.py +++ b/homeassistant/components/miflora/sensor.py @@ -5,7 +5,7 @@ import logging import btlewrap from btlewrap import BluetoothBackendException -from miflora import miflora_poller +from miflora import miflora_poller # pylint: disable=import-error import voluptuous as vol from homeassistant.components.sensor import PLATFORM_SCHEMA diff --git a/homeassistant/components/mikrotik/hub.py b/homeassistant/components/mikrotik/hub.py index fb120aa29c7..4136377fde9 100644 --- a/homeassistant/components/mikrotik/hub.py +++ b/homeassistant/components/mikrotik/hub.py @@ -129,7 +129,11 @@ class MikrotikData: """Return device model name.""" cmd = IDENTITY if param == NAME else INFO data = self.command(MIKROTIK_SERVICES[cmd]) - return data[0].get(param) if data else None + return ( + data[0].get(param) # pylint: disable=unsubscriptable-object + if data + else None + ) def get_hub_details(self): """Get Hub info.""" @@ -229,7 +233,7 @@ class MikrotikData: data = self.command(cmd, params) if data is not None: status = 0 - for result in data: + for result in data: # pylint: disable=not-an-iterable if "status" in result: status += 1 if status == len(data): diff --git a/homeassistant/components/nuheat/config_flow.py b/homeassistant/components/nuheat/config_flow.py index dc72438ce5e..eb76c620767 100644 --- a/homeassistant/components/nuheat/config_flow.py +++ b/homeassistant/components/nuheat/config_flow.py @@ -48,7 +48,7 @@ async def validate_input(hass: core.HomeAssistant, data): # # The underlying module throws a generic exception on login failure # - except Exception as ex: # pylint: disable=broad-except + except Exception as ex: raise InvalidAuth from ex try: diff --git a/homeassistant/components/plex/server.py b/homeassistant/components/plex/server.py index 2ddb5ef0a29..1d237dedb01 100644 --- a/homeassistant/components/plex/server.py +++ b/homeassistant/components/plex/server.py @@ -184,7 +184,7 @@ class PlexServer: if _update_plexdirect_hostname(): config_entry_update_needed = True else: - raise Unauthorized( + raise Unauthorized( # pylint: disable=raise-missing-from "New certificate cannot be validated with provided token" ) else: diff --git a/homeassistant/components/simplisafe/__init__.py b/homeassistant/components/simplisafe/__init__.py index 4b843d6eebe..0a42d42be3a 100644 --- a/homeassistant/components/simplisafe/__init__.py +++ b/homeassistant/components/simplisafe/__init__.py @@ -566,7 +566,7 @@ class SimpliSafe: LOGGER.error("SimpliSafe error while updating: %s", result) return - if isinstance(result, Exception): # pylint: disable=broad-except + if isinstance(result, Exception): LOGGER.error("Unknown error while updating: %s", result) return diff --git a/homeassistant/components/system_log/__init__.py b/homeassistant/components/system_log/__init__.py index 6f658962fe0..b8d6b1664ac 100644 --- a/homeassistant/components/system_log/__init__.py +++ b/homeassistant/components/system_log/__init__.py @@ -165,7 +165,7 @@ class LogErrorQueueHandler(logging.handlers.QueueHandler): """Emit a log record.""" try: self.enqueue(record) - except asyncio.CancelledError: # pylint: disable=try-except-raise + except asyncio.CancelledError: raise except Exception: # pylint: disable=broad-except self.handleError(record) diff --git a/homeassistant/components/traccar/__init__.py b/homeassistant/components/traccar/__init__.py index 03482292135..5203ea5ec90 100644 --- a/homeassistant/components/traccar/__init__.py +++ b/homeassistant/components/traccar/__init__.py @@ -107,5 +107,4 @@ async def async_unload_entry(hass, entry): return True -# pylint: disable=invalid-name async_remove_entry = config_entry_flow.webhook_async_remove_entry diff --git a/homeassistant/components/twilio/__init__.py b/homeassistant/components/twilio/__init__.py index 15c6697b2f7..7c65a693af1 100644 --- a/homeassistant/components/twilio/__init__.py +++ b/homeassistant/components/twilio/__init__.py @@ -64,5 +64,4 @@ async def async_unload_entry(hass, entry): return True -# pylint: disable=invalid-name async_remove_entry = config_entry_flow.webhook_async_remove_entry diff --git a/homeassistant/components/websocket_api/__init__.py b/homeassistant/components/websocket_api/__init__.py index 60177fcde90..bfcfc796bad 100644 --- a/homeassistant/components/websocket_api/__init__.py +++ b/homeassistant/components/websocket_api/__init__.py @@ -15,7 +15,6 @@ DOMAIN = const.DOMAIN DEPENDENCIES = ("http",) # Backwards compat / Make it easier to integrate -# pylint: disable=invalid-name ActiveConnection = connection.ActiveConnection BASE_COMMAND_MESSAGE_SCHEMA = messages.BASE_COMMAND_MESSAGE_SCHEMA error_message = messages.error_message @@ -25,7 +24,6 @@ async_response = decorators.async_response require_admin = decorators.require_admin ws_require_user = decorators.ws_require_user websocket_command = decorators.websocket_command -# pylint: enable=invalid-name @bind_hass diff --git a/homeassistant/components/zha/core/registries.py b/homeassistant/components/zha/core/registries.py index 0df3b1070bf..0cc350ba4b8 100644 --- a/homeassistant/components/zha/core/registries.py +++ b/homeassistant/components/zha/core/registries.py @@ -240,12 +240,9 @@ class MatchRule: return matches -RegistryDictType = Dict[ - str, Dict[MatchRule, CALLABLE_T] -] # pylint: disable=invalid-name +RegistryDictType = Dict[str, Dict[MatchRule, CALLABLE_T]] - -GroupRegistryDictType = Dict[str, CALLABLE_T] # pylint: disable=invalid-name +GroupRegistryDictType = Dict[str, CALLABLE_T] class ZHAEntityRegistry: diff --git a/homeassistant/components/zwave/__init__.py b/homeassistant/components/zwave/__init__.py index 4e0598fed95..296271288d2 100644 --- a/homeassistant/components/zwave/__init__.py +++ b/homeassistant/components/zwave/__init__.py @@ -593,7 +593,7 @@ async def async_setup_entry(hass, config_entry): async def rename_node(service): """Rename a node.""" node_id = service.data.get(const.ATTR_NODE_ID) - node = network.nodes[node_id] + node = network.nodes[node_id] # pylint: disable=unsubscriptable-object name = service.data.get(const.ATTR_NAME) node.name = name _LOGGER.info("Renamed Z-Wave node %d to %s", node_id, name) @@ -613,7 +613,7 @@ async def async_setup_entry(hass, config_entry): """Rename a node value.""" node_id = service.data.get(const.ATTR_NODE_ID) value_id = service.data.get(const.ATTR_VALUE_ID) - node = network.nodes[node_id] + node = network.nodes[node_id] # pylint: disable=unsubscriptable-object value = node.values[value_id] name = service.data.get(const.ATTR_NAME) value.label = name @@ -629,7 +629,7 @@ async def async_setup_entry(hass, config_entry): """Set the polling intensity of a node value.""" node_id = service.data.get(const.ATTR_NODE_ID) value_id = service.data.get(const.ATTR_VALUE_ID) - node = network.nodes[node_id] + node = network.nodes[node_id] # pylint: disable=unsubscriptable-object value = node.values[value_id] intensity = service.data.get(const.ATTR_POLL_INTENSITY) if intensity == 0: @@ -667,7 +667,7 @@ async def async_setup_entry(hass, config_entry): def set_config_parameter(service): """Set a config parameter to a node.""" node_id = service.data.get(const.ATTR_NODE_ID) - node = network.nodes[node_id] + node = network.nodes[node_id] # pylint: disable=unsubscriptable-object param = service.data.get(const.ATTR_CONFIG_PARAMETER) selection = service.data.get(const.ATTR_CONFIG_VALUE) size = service.data.get(const.ATTR_CONFIG_SIZE) @@ -725,7 +725,7 @@ async def async_setup_entry(hass, config_entry): """Refresh the specified value from a node.""" node_id = service.data.get(const.ATTR_NODE_ID) value_id = service.data.get(const.ATTR_VALUE_ID) - node = network.nodes[node_id] + node = network.nodes[node_id] # pylint: disable=unsubscriptable-object node.values[value_id].refresh() _LOGGER.info("Node %s value %s refreshed", node_id, value_id) @@ -734,14 +734,14 @@ async def async_setup_entry(hass, config_entry): node_id = service.data.get(const.ATTR_NODE_ID) value_id = service.data.get(const.ATTR_VALUE_ID) value = service.data.get(const.ATTR_CONFIG_VALUE) - node = network.nodes[node_id] + node = network.nodes[node_id] # pylint: disable=unsubscriptable-object node.values[value_id].data = value _LOGGER.info("Node %s value %s set to %s", node_id, value_id, value) def print_config_parameter(service): """Print a config parameter from a node.""" node_id = service.data.get(const.ATTR_NODE_ID) - node = network.nodes[node_id] + node = network.nodes[node_id] # pylint: disable=unsubscriptable-object param = service.data.get(const.ATTR_CONFIG_PARAMETER) _LOGGER.info( "Config parameter %s on Node %s: %s", @@ -753,13 +753,13 @@ async def async_setup_entry(hass, config_entry): def print_node(service): """Print all information about z-wave node.""" node_id = service.data.get(const.ATTR_NODE_ID) - node = network.nodes[node_id] + node = network.nodes[node_id] # pylint: disable=unsubscriptable-object nice_print_node(node) def set_wakeup(service): """Set wake-up interval of a node.""" node_id = service.data.get(const.ATTR_NODE_ID) - node = network.nodes[node_id] + node = network.nodes[node_id] # pylint: disable=unsubscriptable-object value = service.data.get(const.ATTR_CONFIG_VALUE) if node.can_wake_up(): for value_id in node.get_values(class_id=const.COMMAND_CLASS_WAKE_UP): @@ -806,14 +806,14 @@ async def async_setup_entry(hass, config_entry): def refresh_node(service): """Refresh all node info.""" node_id = service.data.get(const.ATTR_NODE_ID) - node = network.nodes[node_id] + node = network.nodes[node_id] # pylint: disable=unsubscriptable-object node.refresh_info() def reset_node_meters(service): """Reset meter counters of a node.""" node_id = service.data.get(const.ATTR_NODE_ID) instance = service.data.get(const.ATTR_INSTANCE) - node = network.nodes[node_id] + node = network.nodes[node_id] # pylint: disable=unsubscriptable-object for value in node.get_values(class_id=const.COMMAND_CLASS_METER).values(): if value.index != const.INDEX_METER_RESET: continue @@ -833,7 +833,7 @@ async def async_setup_entry(hass, config_entry): """Heal a node on the network.""" node_id = service.data.get(const.ATTR_NODE_ID) update_return_routes = service.data.get(const.ATTR_RETURN_ROUTES) - node = network.nodes[node_id] + node = network.nodes[node_id] # pylint: disable=unsubscriptable-object _LOGGER.info("Z-Wave node heal running for node %s", node_id) node.heal(update_return_routes) @@ -841,7 +841,7 @@ async def async_setup_entry(hass, config_entry): """Send test messages to a node on the network.""" node_id = service.data.get(const.ATTR_NODE_ID) messages = service.data.get(const.ATTR_MESSAGES) - node = network.nodes[node_id] + node = network.nodes[node_id] # pylint: disable=unsubscriptable-object _LOGGER.info("Sending %s test-messages to node %s", messages, node_id) node.test(messages) diff --git a/homeassistant/config_entries.py b/homeassistant/config_entries.py index f708f138f88..347ca294d34 100644 --- a/homeassistant/config_entries.py +++ b/homeassistant/config_entries.py @@ -743,6 +743,7 @@ class ConfigEntries: self, entry: ConfigEntry, *, + # pylint: disable=dangerous-default-value # _UNDEFs not modified unique_id: Union[str, dict, None] = _UNDEF, title: Union[str, dict] = _UNDEF, data: dict = _UNDEF, diff --git a/homeassistant/core.py b/homeassistant/core.py index 6b44386eadf..1540b69b36b 100644 --- a/homeassistant/core.py +++ b/homeassistant/core.py @@ -158,7 +158,7 @@ class CoreState(enum.Enum): final_write = "FINAL_WRITE" stopped = "STOPPED" - def __str__(self) -> str: + def __str__(self) -> str: # pylint: disable=invalid-str-returned """Return the event.""" return self.value # type: ignore @@ -523,7 +523,7 @@ class EventOrigin(enum.Enum): local = "LOCAL" remote = "REMOTE" - def __str__(self) -> str: + def __str__(self) -> str: # pylint: disable=invalid-str-returned """Return the event.""" return self.value # type: ignore @@ -1483,6 +1483,7 @@ class Config: unit_system: Optional[str] = None, location_name: Optional[str] = None, time_zone: Optional[str] = None, + # pylint: disable=dangerous-default-value # _UNDEFs not modified external_url: Optional[Union[str, dict]] = _UNDEF, internal_url: Optional[Union[str, dict]] = _UNDEF, ) -> None: diff --git a/homeassistant/helpers/event.py b/homeassistant/helpers/event.py index 21f49c008c8..0530ad7cdc7 100644 --- a/homeassistant/helpers/event.py +++ b/homeassistant/helpers/event.py @@ -47,9 +47,6 @@ TRACK_ENTITY_REGISTRY_UPDATED_LISTENER = "track_entity_registry_updated_listener _LOGGER = logging.getLogger(__name__) -# PyLint does not like the use of threaded_listener_factory -# pylint: disable=invalid-name - def threaded_listener_factory(async_factory: Callable[..., Any]) -> CALLBACK_TYPE: """Convert an async event helper to a threaded one.""" diff --git a/homeassistant/helpers/json.py b/homeassistant/helpers/json.py index 025cac11641..4acb9fd500a 100644 --- a/homeassistant/helpers/json.py +++ b/homeassistant/helpers/json.py @@ -10,7 +10,6 @@ _LOGGER = logging.getLogger(__name__) class JSONEncoder(json.JSONEncoder): """JSONEncoder that supports Home Assistant objects.""" - # pylint: disable=method-hidden def default(self, o: Any) -> Any: """Convert Home Assistant objects. diff --git a/homeassistant/helpers/typing.py b/homeassistant/helpers/typing.py index 0be267e3a86..6bcc98c10a8 100644 --- a/homeassistant/helpers/typing.py +++ b/homeassistant/helpers/typing.py @@ -3,8 +3,6 @@ from typing import Any, Dict, Optional, Tuple, Union import homeassistant.core -# pylint: disable=invalid-name - GPSType = Tuple[float, float] ConfigType = Dict[str, Any] ContextType = homeassistant.core.Context diff --git a/homeassistant/runner.py b/homeassistant/runner.py index f35de991a27..a5cf0f88a40 100644 --- a/homeassistant/runner.py +++ b/homeassistant/runner.py @@ -46,7 +46,7 @@ class RuntimeConfig: if sys.platform == "win32" and sys.version_info[:2] < (3, 8): PolicyBase = asyncio.WindowsProactorEventLoopPolicy else: - PolicyBase = asyncio.DefaultEventLoopPolicy # pylint: disable=invalid-name + PolicyBase = asyncio.DefaultEventLoopPolicy class HassEventLoopPolicy(PolicyBase): # type: ignore @@ -117,9 +117,7 @@ def _async_loop_exception_handler(_: Any, context: Dict) -> None: ) -async def setup_and_run_hass( - runtime_config: RuntimeConfig, -) -> int: +async def setup_and_run_hass(runtime_config: RuntimeConfig) -> int: """Set up Home Assistant and run.""" hass = await bootstrap.async_setup_hass(runtime_config) diff --git a/homeassistant/util/async_.py b/homeassistant/util/async_.py index a33f548a8a9..0b48e2159c0 100644 --- a/homeassistant/util/async_.py +++ b/homeassistant/util/async_.py @@ -10,7 +10,7 @@ from typing import Any, Callable, Coroutine, TypeVar _LOGGER = logging.getLogger(__name__) -T = TypeVar("T") # pylint: disable=invalid-name +T = TypeVar("T") def fire_coroutine_threadsafe(coro: Coroutine, loop: AbstractEventLoop) -> None: diff --git a/homeassistant/util/logging.py b/homeassistant/util/logging.py index ed710f573f4..629928f43d7 100644 --- a/homeassistant/util/logging.py +++ b/homeassistant/util/logging.py @@ -34,7 +34,7 @@ class HomeAssistantQueueHandler(logging.handlers.QueueHandler): """Emit a log record.""" try: self.enqueue(record) - except asyncio.CancelledError: # pylint: disable=try-except-raise + except asyncio.CancelledError: raise except Exception: # pylint: disable=broad-except self.handleError(record) diff --git a/pylintrc b/pylintrc index f2860026cd8..86f3d4caea0 100644 --- a/pylintrc +++ b/pylintrc @@ -2,7 +2,8 @@ ignore=tests # Use a conservative default here; 2 should speed up most setups and not hurt # any too bad. Override on command line as appropriate. -jobs=2 +# Disabled for now: https://github.com/PyCQA/pylint/issues/3584 +#jobs=2 load-plugins=pylint_strict_informational persistent=no extension-pkg-whitelist=ciso8601,cv2 @@ -46,6 +47,7 @@ disable= too-many-boolean-expressions, unused-argument, wrong-import-order +# enable useless-suppression temporarily every now and then to clean them up enable= use-symbolic-message-instead diff --git a/requirements_test.txt b/requirements_test.txt index 094ff1a00c6..600916615be 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -10,8 +10,8 @@ coverage==5.2.1 mock-open==1.4.0 mypy==0.780 pre-commit==2.7.1 -pylint==2.4.4 -astroid==2.3.3 +pylint==2.6.0 +astroid==2.4.2 pylint-strict-informational==0.1 pytest-aiohttp==0.3.0 pytest-cov==2.10.0