From 761d7f21e90026d4a38fb20ee125ae2594ad5a5b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ville=20Skytt=C3=A4?= <ville.skytta@iki.fi>
Date: Mon, 7 Oct 2019 18:17:39 +0300
Subject: [PATCH] Upgrade pylint (#27279)

* Upgrade pylint to 2.4.2 and astroid to 2.3.1

https://pylint.readthedocs.io/en/latest/whatsnew/2.4.html
https://pylint.readthedocs.io/en/latest/whatsnew/changelog.html#what-s-new-in-pylint-2-4-1
https://pylint.readthedocs.io/en/latest/whatsnew/changelog.html#what-s-new-in-pylint-2-4-2

* unnecessary-comprehension fixes

* invalid-name fixes

* self-assigning-variable fixes

* Re-enable not-an-iterable

* used-before-assignment fix

* invalid-overridden-method fixes

* undefined-variable __class__ workarounds

https://github.com/PyCQA/pylint/issues/3090

* no-member false positive disabling

* Remove some no longer needed disables

* using-constant-test fix

* Disable import-outside-toplevel for now

* Disable some apparent no-value-for-parameter false positives

* invalid-overridden-method false positive disables

https://github.com/PyCQA/pylint/issues/3150

* Fix unintentional Entity.force_update override in AfterShipSensor
---
 homeassistant/components/aftership/sensor.py           |  4 ++--
 homeassistant/components/axis/config_flow.py           |  2 +-
 homeassistant/components/bayesian/binary_sensor.py     |  2 +-
 homeassistant/components/bt_smarthub/device_tracker.py |  2 +-
 homeassistant/components/cert_expiry/helper.py         |  3 ++-
 homeassistant/components/ddwrt/device_tracker.py       |  2 +-
 homeassistant/components/deconz/config_flow.py         |  2 +-
 homeassistant/components/esphome/climate.py            |  3 +++
 homeassistant/components/esphome/config_flow.py        |  3 ++-
 homeassistant/components/esphome/cover.py              |  3 +++
 homeassistant/components/esphome/fan.py                |  3 +++
 homeassistant/components/esphome/light.py              |  3 +++
 homeassistant/components/esphome/sensor.py             |  4 ++++
 homeassistant/components/esphome/switch.py             |  2 ++
 .../components/homekit_controller/config_flow.py       |  2 +-
 homeassistant/components/hue/config_flow.py            |  2 ++
 homeassistant/components/mqtt/__init__.py              | 10 ++++++++--
 homeassistant/components/onkyo/media_player.py         |  4 ++--
 homeassistant/components/rmvtransport/sensor.py        |  2 +-
 homeassistant/components/sabnzbd/sensor.py             |  1 +
 homeassistant/components/synology/camera.py            |  1 +
 homeassistant/components/tplink/device_tracker.py      |  4 ++--
 homeassistant/components/tradfri/config_flow.py        |  2 +-
 homeassistant/components/upnp/sensor.py                |  1 -
 homeassistant/components/vacuum/__init__.py            |  4 +---
 homeassistant/components/vallox/__init__.py            |  2 +-
 homeassistant/components/wink/climate.py               |  4 ----
 homeassistant/components/zha/core/device.py            |  4 +---
 homeassistant/components/zha/fan.py                    |  2 +-
 homeassistant/components/zha/lock.py                   |  2 +-
 homeassistant/core.py                                  |  4 +++-
 homeassistant/helpers/config_entry_flow.py             |  2 +-
 homeassistant/util/color.py                            |  4 ++--
 homeassistant/util/dt.py                               |  2 +-
 pylintrc                                               |  6 +++---
 requirements_test.txt                                  |  4 ++--
 requirements_test_all.txt                              |  4 ++--
 37 files changed, 67 insertions(+), 44 deletions(-)

diff --git a/homeassistant/components/aftership/sensor.py b/homeassistant/components/aftership/sensor.py
index e54a48f7ee4..c41e5aec7b5 100644
--- a/homeassistant/components/aftership/sensor.py
+++ b/homeassistant/components/aftership/sensor.py
@@ -146,10 +146,10 @@ class AfterShipSensor(Entity):
     async def async_added_to_hass(self):
         """Register callbacks."""
         self.hass.helpers.dispatcher.async_dispatcher_connect(
-            UPDATE_TOPIC, self.force_update
+            UPDATE_TOPIC, self._force_update
         )
 
-    async def force_update(self):
+    async def _force_update(self):
         """Force update of data."""
         await self.async_update(no_throttle=True)
         await self.async_update_ha_state()
diff --git a/homeassistant/components/axis/config_flow.py b/homeassistant/components/axis/config_flow.py
index 3b5efe96760..3473eba3065 100644
--- a/homeassistant/components/axis/config_flow.py
+++ b/homeassistant/components/axis/config_flow.py
@@ -171,7 +171,7 @@ class AxisFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
         if discovery_info[CONF_HOST].startswith("169.254"):
             return self.async_abort(reason="link_local_address")
 
-        # pylint: disable=unsupported-assignment-operation
+        # pylint: disable=no-member # https://github.com/PyCQA/pylint/issues/3167
         self.context["macaddress"] = serialnumber
 
         if any(
diff --git a/homeassistant/components/bayesian/binary_sensor.py b/homeassistant/components/bayesian/binary_sensor.py
index acefc5a3b26..ffa13a6288c 100644
--- a/homeassistant/components/bayesian/binary_sensor.py
+++ b/homeassistant/components/bayesian/binary_sensor.py
@@ -250,7 +250,7 @@ class BayesianBinarySensor(BinarySensorDevice):
     def device_state_attributes(self):
         """Return the state attributes of the sensor."""
         return {
-            ATTR_OBSERVATIONS: [val for val in self.current_obs.values()],
+            ATTR_OBSERVATIONS: list(self.current_obs.values()),
             ATTR_PROBABILITY: round(self.probability, 2),
             ATTR_PROBABILITY_THRESHOLD: self._probability_threshold,
         }
diff --git a/homeassistant/components/bt_smarthub/device_tracker.py b/homeassistant/components/bt_smarthub/device_tracker.py
index 58f409c2d4b..ece67e3b635 100644
--- a/homeassistant/components/bt_smarthub/device_tracker.py
+++ b/homeassistant/components/bt_smarthub/device_tracker.py
@@ -69,7 +69,7 @@ class BTSmartHubScanner(DeviceScanner):
             _LOGGER.warning("Error scanning devices")
             return
 
-        clients = [client for client in data.values()]
+        clients = list(data.values())
         self.last_results = clients
 
     def get_bt_smarthub_data(self):
diff --git a/homeassistant/components/cert_expiry/helper.py b/homeassistant/components/cert_expiry/helper.py
index 9c10887293a..cd49588ec89 100644
--- a/homeassistant/components/cert_expiry/helper.py
+++ b/homeassistant/components/cert_expiry/helper.py
@@ -11,5 +11,6 @@ def get_cert(host, port):
     address = (host, port)
     with socket.create_connection(address, timeout=TIMEOUT) as sock:
         with ctx.wrap_socket(sock, server_hostname=address[0]) as ssock:
-            cert = ssock.getpeercert()
+            # pylint disable: https://github.com/PyCQA/pylint/issues/3166
+            cert = ssock.getpeercert()  # pylint: disable=no-member
             return cert
diff --git a/homeassistant/components/ddwrt/device_tracker.py b/homeassistant/components/ddwrt/device_tracker.py
index 4e661376719..bd2728d03dc 100644
--- a/homeassistant/components/ddwrt/device_tracker.py
+++ b/homeassistant/components/ddwrt/device_tracker.py
@@ -165,4 +165,4 @@ class DdWrtDeviceScanner(DeviceScanner):
 
 def _parse_ddwrt_response(data_str):
     """Parse the DD-WRT data format."""
-    return {key: val for key, val in _DDWRT_DATA_REGEX.findall(data_str)}
+    return dict(_DDWRT_DATA_REGEX.findall(data_str))
diff --git a/homeassistant/components/deconz/config_flow.py b/homeassistant/components/deconz/config_flow.py
index 66df687047f..91768584e8a 100644
--- a/homeassistant/components/deconz/config_flow.py
+++ b/homeassistant/components/deconz/config_flow.py
@@ -187,7 +187,7 @@ class DeconzFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
         ):
             return self.async_abort(reason="already_in_progress")
 
-        # pylint: disable=unsupported-assignment-operation
+        # pylint: disable=no-member # https://github.com/PyCQA/pylint/issues/3167
         self.context[CONF_BRIDGEID] = bridgeid
 
         self.deconz_config = {
diff --git a/homeassistant/components/esphome/climate.py b/homeassistant/components/esphome/climate.py
index 7337aec4541..fa840078aa4 100644
--- a/homeassistant/components/esphome/climate.py
+++ b/homeassistant/components/esphome/climate.py
@@ -126,6 +126,9 @@ class EsphomeClimateDevice(EsphomeEntity, ClimateDevice):
             features |= SUPPORT_PRESET_MODE
         return features
 
+    # https://github.com/PyCQA/pylint/issues/3150 for all @esphome_state_property
+    # pylint: disable=invalid-overridden-method
+
     @esphome_state_property
     def hvac_mode(self) -> Optional[str]:
         """Return current operation ie. heat, cool, idle."""
diff --git a/homeassistant/components/esphome/config_flow.py b/homeassistant/components/esphome/config_flow.py
index 9680ed46acd..47c00f43463 100644
--- a/homeassistant/components/esphome/config_flow.py
+++ b/homeassistant/components/esphome/config_flow.py
@@ -44,11 +44,12 @@ class EsphomeFlowHandler(config_entries.ConfigFlow):
 
     @property
     def _name(self):
+        # pylint: disable=no-member # https://github.com/PyCQA/pylint/issues/3167
         return self.context.get("name")
 
     @_name.setter
     def _name(self, value):
-        # pylint: disable=unsupported-assignment-operation
+        # pylint: disable=no-member # https://github.com/PyCQA/pylint/issues/3167
         self.context["name"] = value
         self.context["title_placeholders"] = {"name": self._name}
 
diff --git a/homeassistant/components/esphome/cover.py b/homeassistant/components/esphome/cover.py
index 31b895b4eb2..980fc936940 100644
--- a/homeassistant/components/esphome/cover.py
+++ b/homeassistant/components/esphome/cover.py
@@ -70,6 +70,9 @@ class EsphomeCover(EsphomeEntity, CoverDevice):
     def _state(self) -> Optional[CoverState]:
         return super()._state
 
+    # https://github.com/PyCQA/pylint/issues/3150 for all @esphome_state_property
+    # pylint: disable=invalid-overridden-method
+
     @esphome_state_property
     def is_closed(self) -> Optional[bool]:
         """Return if the cover is closed or not."""
diff --git a/homeassistant/components/esphome/fan.py b/homeassistant/components/esphome/fan.py
index 44059673f15..cddb75b41bf 100644
--- a/homeassistant/components/esphome/fan.py
+++ b/homeassistant/components/esphome/fan.py
@@ -92,6 +92,9 @@ class EsphomeFan(EsphomeEntity, FanEntity):
             key=self._static_info.key, oscillating=oscillating
         )
 
+    # https://github.com/PyCQA/pylint/issues/3150 for all @esphome_state_property
+    # pylint: disable=invalid-overridden-method
+
     @esphome_state_property
     def is_on(self) -> Optional[bool]:
         """Return true if the entity is on."""
diff --git a/homeassistant/components/esphome/light.py b/homeassistant/components/esphome/light.py
index 334e7e645a7..9a2a0ccd0bc 100644
--- a/homeassistant/components/esphome/light.py
+++ b/homeassistant/components/esphome/light.py
@@ -61,6 +61,9 @@ class EsphomeLight(EsphomeEntity, Light):
     def _state(self) -> Optional[LightState]:
         return super()._state
 
+    # https://github.com/PyCQA/pylint/issues/3150 for all @esphome_state_property
+    # pylint: disable=invalid-overridden-method
+
     @esphome_state_property
     def is_on(self) -> Optional[bool]:
         """Return true if the switch is on."""
diff --git a/homeassistant/components/esphome/sensor.py b/homeassistant/components/esphome/sensor.py
index 3168bae7ec8..2b7a8b94f1e 100644
--- a/homeassistant/components/esphome/sensor.py
+++ b/homeassistant/components/esphome/sensor.py
@@ -37,6 +37,10 @@ async def async_setup_entry(
     )
 
 
+# https://github.com/PyCQA/pylint/issues/3150 for all @esphome_state_property
+# pylint: disable=invalid-overridden-method
+
+
 class EsphomeSensor(EsphomeEntity):
     """A sensor implementation for esphome."""
 
diff --git a/homeassistant/components/esphome/switch.py b/homeassistant/components/esphome/switch.py
index f66bfaa39f3..b52d630e1b4 100644
--- a/homeassistant/components/esphome/switch.py
+++ b/homeassistant/components/esphome/switch.py
@@ -49,6 +49,8 @@ class EsphomeSwitch(EsphomeEntity, SwitchDevice):
         """Return true if we do optimistic updates."""
         return self._static_info.assumed_state
 
+    # https://github.com/PyCQA/pylint/issues/3150 for @esphome_state_property
+    # pylint: disable=invalid-overridden-method
     @esphome_state_property
     def is_on(self) -> Optional[bool]:
         """Return true if the switch is on."""
diff --git a/homeassistant/components/homekit_controller/config_flow.py b/homeassistant/components/homekit_controller/config_flow.py
index 008e0f8566d..40bf87d6f0a 100644
--- a/homeassistant/components/homekit_controller/config_flow.py
+++ b/homeassistant/components/homekit_controller/config_flow.py
@@ -122,7 +122,7 @@ class HomekitControllerFlowHandler(config_entries.ConfigFlow):
 
         _LOGGER.debug("Discovered device %s (%s - %s)", name, model, hkid)
 
-        # pylint: disable=unsupported-assignment-operation
+        # pylint: disable=no-member # https://github.com/PyCQA/pylint/issues/3167
         self.context["hkid"] = hkid
         self.context["title_placeholders"] = {"name": name}
 
diff --git a/homeassistant/components/hue/config_flow.py b/homeassistant/components/hue/config_flow.py
index 9c0e94bc3bd..ebd71ba7c1c 100644
--- a/homeassistant/components/hue/config_flow.py
+++ b/homeassistant/components/hue/config_flow.py
@@ -50,6 +50,8 @@ class HueFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
     VERSION = 1
     CONNECTION_CLASS = config_entries.CONN_CLASS_LOCAL_POLL
 
+    # pylint: disable=no-member # https://github.com/PyCQA/pylint/issues/3167
+
     def __init__(self):
         """Initialize the Hue flow."""
         self.host = None
diff --git a/homeassistant/components/mqtt/__init__.py b/homeassistant/components/mqtt/__init__.py
index 9b25a6ef6e4..e3605cb8664 100644
--- a/homeassistant/components/mqtt/__init__.py
+++ b/homeassistant/components/mqtt/__init__.py
@@ -776,7 +776,9 @@ class MQTT:
         self._mqttc.on_message = self._mqtt_on_message
 
         if will_message is not None:
-            self._mqttc.will_set(*attr.astuple(will_message))
+            self._mqttc.will_set(  # pylint: disable=no-value-for-parameter
+                *attr.astuple(will_message)
+            )
 
     async def async_publish(
         self, topic: str, payload: PublishPayloadType, qos: int, retain: bool
@@ -909,7 +911,11 @@ class MQTT:
             self.hass.add_job(self._async_perform_subscription, topic, max_qos)
 
         if self.birth_message:
-            self.hass.add_job(self.async_publish(*attr.astuple(self.birth_message)))
+            self.hass.add_job(
+                self.async_publish(  # pylint: disable=no-value-for-parameter
+                    *attr.astuple(self.birth_message)
+                )
+            )
 
     def _mqtt_on_message(self, _mqttc, _userdata, msg) -> None:
         """Message received callback."""
diff --git a/homeassistant/components/onkyo/media_player.py b/homeassistant/components/onkyo/media_player.py
index af92f6c5f05..92e5f01d486 100644
--- a/homeassistant/components/onkyo/media_player.py
+++ b/homeassistant/components/onkyo/media_player.py
@@ -264,7 +264,7 @@ class OnkyoDevice(MediaPlayerDevice):
             if source in self._source_mapping:
                 self._current_source = self._source_mapping[source]
                 break
-            self._current_source = "_".join([i for i in current_source_tuples[1]])
+            self._current_source = "_".join(current_source_tuples[1])
         if preset_raw and self._current_source.lower() == "radio":
             self._attributes[ATTR_PRESET] = preset_raw[1]
         elif ATTR_PRESET in self._attributes:
@@ -413,7 +413,7 @@ class OnkyoDeviceZone(OnkyoDevice):
             if source in self._source_mapping:
                 self._current_source = self._source_mapping[source]
                 break
-            self._current_source = "_".join([i for i in current_source_tuples[1]])
+            self._current_source = "_".join(current_source_tuples[1])
         self._muted = bool(mute_raw[1] == "on")
         if preset_raw and self._current_source.lower() == "radio":
             self._attributes[ATTR_PRESET] = preset_raw[1]
diff --git a/homeassistant/components/rmvtransport/sensor.py b/homeassistant/components/rmvtransport/sensor.py
index d7d075f48f7..f66f22dda17 100644
--- a/homeassistant/components/rmvtransport/sensor.py
+++ b/homeassistant/components/rmvtransport/sensor.py
@@ -157,7 +157,7 @@ class RMVDepartureSensor(Entity):
         """Return the state attributes."""
         try:
             return {
-                "next_departures": [val for val in self.data.departures[1:]],
+                "next_departures": self.data.departures[1:],
                 "direction": self.data.departures[0].get("direction"),
                 "line": self.data.departures[0].get("line"),
                 "minutes": self.data.departures[0].get("minutes"),
diff --git a/homeassistant/components/sabnzbd/sensor.py b/homeassistant/components/sabnzbd/sensor.py
index 58624c758d9..21ac9eefdb2 100644
--- a/homeassistant/components/sabnzbd/sensor.py
+++ b/homeassistant/components/sabnzbd/sensor.py
@@ -49,6 +49,7 @@ class SabnzbdSensor(Entity):
         """Return the state of the sensor."""
         return self._state
 
+    @property
     def should_poll(self):
         """Don't poll. Will be updated by dispatcher signal."""
         return False
diff --git a/homeassistant/components/synology/camera.py b/homeassistant/components/synology/camera.py
index 5594a4b3c9a..8c176f48803 100644
--- a/homeassistant/components/synology/camera.py
+++ b/homeassistant/components/synology/camera.py
@@ -105,6 +105,7 @@ class SynologyCamera(Camera):
         """Return true if the device is recording."""
         return self._camera.is_recording
 
+    @property
     def should_poll(self):
         """Update the recording state periodically."""
         return True
diff --git a/homeassistant/components/tplink/device_tracker.py b/homeassistant/components/tplink/device_tracker.py
index e7f87074cb4..f6921efed91 100644
--- a/homeassistant/components/tplink/device_tracker.py
+++ b/homeassistant/components/tplink/device_tracker.py
@@ -102,7 +102,7 @@ class TplinkDeviceScanner(DeviceScanner):
 
             self.success_init = self._update_info()
         except requests.exceptions.RequestException:
-            _LOGGER.debug("RequestException in %s", __class__.__name__)
+            _LOGGER.debug("RequestException in %s", self.__class__.__name__)
 
     def scan_devices(self):
         """Scan for new devices and return a list with found device IDs."""
@@ -150,7 +150,7 @@ class Tplink1DeviceScanner(DeviceScanner):
         try:
             self.success_init = self._update_info()
         except requests.exceptions.RequestException:
-            _LOGGER.debug("RequestException in %s", __class__.__name__)
+            _LOGGER.debug("RequestException in %s", self.__class__.__name__)
 
     def scan_devices(self):
         """Scan for new devices and return a list with found device IDs."""
diff --git a/homeassistant/components/tradfri/config_flow.py b/homeassistant/components/tradfri/config_flow.py
index 6266766f394..9da381deb75 100644
--- a/homeassistant/components/tradfri/config_flow.py
+++ b/homeassistant/components/tradfri/config_flow.py
@@ -83,7 +83,7 @@ class FlowHandler(config_entries.ConfigFlow):
         """Handle zeroconf discovery."""
         host = user_input["host"]
 
-        # pylint: disable=unsupported-assignment-operation
+        # pylint: disable=no-member # https://github.com/PyCQA/pylint/issues/3167
         self.context["host"] = host
 
         if any(host == flow["context"]["host"] for flow in self._async_in_progress()):
diff --git a/homeassistant/components/upnp/sensor.py b/homeassistant/components/upnp/sensor.py
index b721fa29cdd..40cb7ef2032 100644
--- a/homeassistant/components/upnp/sensor.py
+++ b/homeassistant/components/upnp/sensor.py
@@ -164,7 +164,6 @@ class PerSecondUPnPIGDSensor(UpnpSensor):
         """Get unit we are measuring in."""
         raise NotImplementedError()
 
-    @property
     def _async_fetch_value(self):
         """Fetch a value from the IGD."""
         raise NotImplementedError()
diff --git a/homeassistant/components/vacuum/__init__.py b/homeassistant/components/vacuum/__init__.py
index 9bc376916c6..55e56415b0d 100644
--- a/homeassistant/components/vacuum/__init__.py
+++ b/homeassistant/components/vacuum/__init__.py
@@ -6,7 +6,7 @@ import logging
 import voluptuous as vol
 
 from homeassistant.components import group
-from homeassistant.const import (
+from homeassistant.const import (  # noqa: F401 # STATE_PAUSED/IDLE are API
     ATTR_BATTERY_LEVEL,
     ATTR_COMMAND,
     SERVICE_TOGGLE,
@@ -68,8 +68,6 @@ VACUUM_SEND_COMMAND_SERVICE_SCHEMA = ENTITY_SERVICE_SCHEMA.extend(
 
 STATE_CLEANING = "cleaning"
 STATE_DOCKED = "docked"
-STATE_IDLE = STATE_IDLE
-STATE_PAUSED = STATE_PAUSED
 STATE_RETURNING = "returning"
 STATE_ERROR = "error"
 
diff --git a/homeassistant/components/vallox/__init__.py b/homeassistant/components/vallox/__init__.py
index c107e4f8894..eb5edfe7fcf 100644
--- a/homeassistant/components/vallox/__init__.py
+++ b/homeassistant/components/vallox/__init__.py
@@ -252,7 +252,7 @@ class ValloxServiceHandler:
     async def async_handle(self, service):
         """Dispatch a service call."""
         method = SERVICE_TO_METHOD.get(service.service)
-        params = {key: value for key, value in service.data.items()}
+        params = service.data.copy()
 
         if not hasattr(self, method["method"]):
             _LOGGER.error("Service not implemented: %s", method["method"])
diff --git a/homeassistant/components/wink/climate.py b/homeassistant/components/wink/climate.py
index 38f25ef0a83..6323fa7bbfe 100644
--- a/homeassistant/components/wink/climate.py
+++ b/homeassistant/components/wink/climate.py
@@ -283,10 +283,6 @@ class WinkThermostat(WinkDevice, ClimateDevice):
                 target_temp_high = target_temp
             if self.hvac_mode == HVAC_MODE_HEAT:
                 target_temp_low = target_temp
-        if target_temp_low is not None:
-            target_temp_low = target_temp_low
-        if target_temp_high is not None:
-            target_temp_high = target_temp_high
         self.wink.set_temperature(target_temp_low, target_temp_high)
 
     def set_hvac_mode(self, hvac_mode):
diff --git a/homeassistant/components/zha/core/device.py b/homeassistant/components/zha/core/device.py
index e9e2c3b7ea6..f4a3a2c3d48 100644
--- a/homeassistant/components/zha/core/device.py
+++ b/homeassistant/components/zha/core/device.py
@@ -348,7 +348,6 @@ class ZHADevice(LogMixin):
         zdo_task = None
         for channel in channels:
             if channel.name == CHANNEL_ZDO:
-                # pylint: disable=E1111
                 if zdo_task is None:  # We only want to do this once
                     zdo_task = self._async_create_task(
                         semaphore, channel, task_name, *args
@@ -373,8 +372,7 @@ class ZHADevice(LogMixin):
     @callback
     def async_unsub_dispatcher(self):
         """Unsubscribe the dispatcher."""
-        if self._unsub:
-            self._unsub()
+        self._unsub()
 
     @callback
     def async_update_last_seen(self, last_seen):
diff --git a/homeassistant/components/zha/fan.py b/homeassistant/components/zha/fan.py
index 1f119ef6657..43ad2291cb7 100644
--- a/homeassistant/components/zha/fan.py
+++ b/homeassistant/components/zha/fan.py
@@ -43,7 +43,7 @@ SPEED_LIST = [
     SPEED_SMART,
 ]
 
-VALUE_TO_SPEED = {i: speed for i, speed in enumerate(SPEED_LIST)}
+VALUE_TO_SPEED = dict(enumerate(SPEED_LIST))
 SPEED_TO_VALUE = {speed: i for i, speed in enumerate(SPEED_LIST)}
 
 
diff --git a/homeassistant/components/zha/lock.py b/homeassistant/components/zha/lock.py
index afc4618343c..a2151b4bdcb 100644
--- a/homeassistant/components/zha/lock.py
+++ b/homeassistant/components/zha/lock.py
@@ -27,7 +27,7 @@ _LOGGER = logging.getLogger(__name__)
 
 STATE_LIST = [STATE_UNLOCKED, STATE_LOCKED, STATE_UNLOCKED]
 
-VALUE_TO_STATE = {i: state for i, state in enumerate(STATE_LIST)}
+VALUE_TO_STATE = dict(enumerate(STATE_LIST))
 
 
 async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
diff --git a/homeassistant/core.py b/homeassistant/core.py
index feb4445d36d..90d197906cb 100644
--- a/homeassistant/core.py
+++ b/homeassistant/core.py
@@ -186,7 +186,9 @@ class HomeAssistant:
         self.data: dict = {}
         self.state = CoreState.not_running
         self.exit_code = 0
-        self.config_entries: Optional[ConfigEntries] = None
+        self.config_entries: Optional[
+            ConfigEntries  # pylint: disable=used-before-assignment
+        ] = None
         # If not None, use to signal end-of-loop
         self._stopped: Optional[asyncio.Event] = None
 
diff --git a/homeassistant/helpers/config_entry_flow.py b/homeassistant/helpers/config_entry_flow.py
index 922878fb324..88aae3721b1 100644
--- a/homeassistant/helpers/config_entry_flow.py
+++ b/homeassistant/helpers/config_entry_flow.py
@@ -38,7 +38,7 @@ class DiscoveryFlowHandler(config_entries.ConfigFlow):
         if user_input is None:
             return self.async_show_form(step_id="confirm")
 
-        if (
+        if (  # pylint: disable=no-member # https://github.com/PyCQA/pylint/issues/3167
             self.context
             and self.context.get("source") != config_entries.SOURCE_DISCOVERY
         ):
diff --git a/homeassistant/util/color.py b/homeassistant/util/color.py
index 89d1dcfc4c1..640e5c5540a 100644
--- a/homeassistant/util/color.py
+++ b/homeassistant/util/color.py
@@ -167,8 +167,8 @@ COLORS = {
 class XYPoint:
     """Represents a CIE 1931 XY coordinate pair."""
 
-    x = attr.ib(type=float)
-    y = attr.ib(type=float)
+    x = attr.ib(type=float)  # pylint: disable=invalid-name
+    y = attr.ib(type=float)  # pylint: disable=invalid-name
 
 
 @attr.s()
diff --git a/homeassistant/util/dt.py b/homeassistant/util/dt.py
index a948c4407ae..1abb4294398 100644
--- a/homeassistant/util/dt.py
+++ b/homeassistant/util/dt.py
@@ -220,7 +220,7 @@ def get_age(date: dt.datetime) -> str:
 def parse_time_expression(parameter: Any, min_value: int, max_value: int) -> List[int]:
     """Parse the time expression part and return a list of times to match."""
     if parameter is None or parameter == MATCH_ALL:
-        res = [x for x in range(min_value, max_value + 1)]
+        res = list(range(min_value, max_value + 1))
     elif isinstance(parameter, str) and parameter.startswith("/"):
         parameter = int(parameter[1:])
         res = [x for x in range(min_value, max_value + 1) if x % parameter == 0]
diff --git a/pylintrc b/pylintrc
index bb4f1fe96d0..3d69800e5c3 100644
--- a/pylintrc
+++ b/pylintrc
@@ -2,7 +2,7 @@
 ignore=tests
 
 [BASIC]
-good-names=i,j,k,ex,Run,_,fp
+good-names=id,i,j,k,ex,Run,_,fp
 
 [MESSAGES CONTROL]
 # Reasons disabled:
@@ -18,8 +18,8 @@ good-names=i,j,k,ex,Run,_,fp
 # too-few-* - same as too-many-*
 # abstract-method - with intro of async there are always methods missing
 # inconsistent-return-statements - doesn't handle raise
-# not-an-iterable - https://github.com/PyCQA/pylint/issues/2311
 # unnecessary-pass - readability for functions which only contain pass
+# import-outside-toplevel - TODO
 disable=
   format,
   abstract-class-little-used,
@@ -27,9 +27,9 @@ disable=
   cyclic-import,
   duplicate-code,
   global-statement,
+  import-outside-toplevel,
   inconsistent-return-statements,
   locally-disabled,
-  not-an-iterable,
   not-context-manager,
   redefined-variable-type,
   too-few-public-methods,
diff --git a/requirements_test.txt b/requirements_test.txt
index 9da375b33c8..d0b7880d78d 100644
--- a/requirements_test.txt
+++ b/requirements_test.txt
@@ -12,8 +12,8 @@ mock-open==1.3.1
 mypy==0.730
 pre-commit==1.18.3
 pydocstyle==4.0.1
-pylint==2.3.1
-astroid==2.2.5
+pylint==2.4.2
+astroid==2.3.1
 pytest-aiohttp==0.3.0
 pytest-cov==2.7.1
 pytest-sugar==0.9.2
diff --git a/requirements_test_all.txt b/requirements_test_all.txt
index 62be2f035a5..425170d168d 100644
--- a/requirements_test_all.txt
+++ b/requirements_test_all.txt
@@ -13,8 +13,8 @@ mock-open==1.3.1
 mypy==0.730
 pre-commit==1.18.3
 pydocstyle==4.0.1
-pylint==2.3.1
-astroid==2.2.5
+pylint==2.4.2
+astroid==2.3.1
 pytest-aiohttp==0.3.0
 pytest-cov==2.7.1
 pytest-sugar==0.9.2
-- 
GitLab