diff --git a/homeassistant/auth/providers/homeassistant.py b/homeassistant/auth/providers/homeassistant.py index d8142a2ace2..df38810fc29 100644 --- a/homeassistant/auth/providers/homeassistant.py +++ b/homeassistant/auth/providers/homeassistant.py @@ -144,8 +144,8 @@ class Data: # pylint: disable=no-self-use def hash_password(self, password: str, for_storage: bool = False) -> bytes: """Encode a password.""" - hashed = bcrypt.hashpw(password.encode(), bcrypt.gensalt(rounds=12)) - # type: bytes + hashed: bytes = bcrypt.hashpw(password.encode(), bcrypt.gensalt(rounds=12)) + if for_storage: hashed = base64.b64encode(hashed) return hashed diff --git a/homeassistant/components/cast/media_player.py b/homeassistant/components/cast/media_player.py index 2e61e3111e1..af9f39f8ed4 100644 --- a/homeassistant/components/cast/media_player.py +++ b/homeassistant/components/cast/media_player.py @@ -539,8 +539,7 @@ class CastDevice(MediaPlayerDevice): self.media_status = None self.media_status_received = None self._dynamic_group_cast_info = None # type: ChromecastInfo - self._dynamic_group_cast = None - # type: Optional[pychromecast.Chromecast] + self._dynamic_group_cast = None # type: Optional[pychromecast.Chromecast] self.dynamic_group_media_status = None self.dynamic_group_media_status_received = None self.mz_media_status = {} @@ -549,8 +548,9 @@ class CastDevice(MediaPlayerDevice): self._available = False # type: bool self._dynamic_group_available = False # type: bool self._status_listener = None # type: Optional[CastStatusListener] - self._dynamic_group_status_listener = None - # type: Optional[DynamicGroupCastStatusListener] + self._dynamic_group_status_listener = ( + None + ) # type: Optional[DynamicGroupCastStatusListener] self._add_remove_handler = None self._del_remove_handler = None diff --git a/homeassistant/components/cloud/http_api.py b/homeassistant/components/cloud/http_api.py index c22cb3934d9..d261c9e494c 100644 --- a/homeassistant/components/cloud/http_api.py +++ b/homeassistant/components/cloud/http_api.py @@ -61,11 +61,11 @@ SCHEMA_WS_HOOK_DELETE = websocket_api.BASE_COMMAND_MESSAGE_SCHEMA.extend( _CLOUD_ERRORS = { InvalidTrustedNetworks: ( 500, - "Remote UI not compatible with 127.0.0.1/::1" " as a trusted network.", + "Remote UI not compatible with 127.0.0.1/::1 as a trusted network.", ), InvalidTrustedProxies: ( 500, - "Remote UI not compatible with 127.0.0.1/::1" " as trusted proxies.", + "Remote UI not compatible with 127.0.0.1/::1 as trusted proxies.", ), } diff --git a/homeassistant/components/darksky/sensor.py b/homeassistant/components/darksky/sensor.py index d6bc2db517e..e5886ae5e59 100644 --- a/homeassistant/components/darksky/sensor.py +++ b/homeassistant/components/darksky/sensor.py @@ -678,7 +678,8 @@ class DarkSkySensor(Entity): "temperature_high", "apparent_temperature_high", "temperature_max", - "apparent_temperature_max" "precip_accumulation", + "apparent_temperature_max", + "precip_accumulation", "pressure", "ozone", "uvIndex", diff --git a/homeassistant/components/evohome/__init__.py b/homeassistant/components/evohome/__init__.py index 5fcab599e88..f0e7a26e1f5 100644 --- a/homeassistant/components/evohome/__init__.py +++ b/homeassistant/components/evohome/__init__.py @@ -200,8 +200,10 @@ class EvoBroker: return False self.tcs = ( - client.locations[loc_idx]._gateways[0]._control_systems[0] - ) # noqa: E501; pylint: disable=protected-access + client.locations[loc_idx] # noqa: E501; pylint: disable=protected-access + ._gateways[0] + ._control_systems[0] + ) _LOGGER.debug("Config = %s", self.config) if _LOGGER.isEnabledFor(logging.DEBUG): diff --git a/homeassistant/components/evohome/climate.py b/homeassistant/components/evohome/climate.py index d9789d319da..d1b9d5f54c7 100644 --- a/homeassistant/components/evohome/climate.py +++ b/homeassistant/components/evohome/climate.py @@ -175,9 +175,8 @@ class EvoClimateDevice(EvoDevice, ClimateDevice): def _set_tcs_mode(self, op_mode: str) -> None: """Set the Controller to any of its native EVO_* operating modes.""" try: - self._evo_tcs._set_status( - op_mode - ) # noqa: E501; pylint: disable=protected-access + # noqa: E501; pylint: disable=protected-access + self._evo_tcs._set_status(op_mode) except ( requests.exceptions.RequestException, evohomeclient2.AuthenticationError, diff --git a/homeassistant/components/geniushub/__init__.py b/homeassistant/components/geniushub/__init__.py index 8075c835f37..3bbec4258bc 100644 --- a/homeassistant/components/geniushub/__init__.py +++ b/homeassistant/components/geniushub/__init__.py @@ -49,11 +49,15 @@ async def async_setup(hass, hass_config): return False _LOGGER.debug( - "zones_raw = %s", data._client.hub._zones_raw - ) # noqa; pylint: disable=protected-access + # noqa; pylint: disable=protected-access + "zones_raw = %s", + data._client.hub._zones_raw, + ) _LOGGER.debug( - "devices_raw = %s", data._client.hub._devices_raw - ) # noqa; pylint: disable=protected-access + # noqa; pylint: disable=protected-access + "devices_raw = %s", + data._client.hub._devices_raw, + ) async_track_time_interval(hass, data.async_update, SCAN_INTERVAL) @@ -90,10 +94,14 @@ class GeniusData: return _LOGGER.debug( - "zones_raw = %s", self._client.hub._zones_raw - ) # noqa; pylint: disable=protected-access + # noqa; pylint: disable=protected-access + "zones_raw = %s", + self._client.hub._zones_raw, + ) _LOGGER.debug( - "devices_raw = %s", self._client.hub._devices_raw - ) # noqa; pylint: disable=protected-access + # noqa; pylint: disable=protected-access + "devices_raw = %s", + self._client.hub._devices_raw, + ) async_dispatcher_send(self._hass, DOMAIN) diff --git a/homeassistant/components/geniushub/binary_sensor.py b/homeassistant/components/geniushub/binary_sensor.py index 7e34206531c..afdc0ef5f89 100644 --- a/homeassistant/components/geniushub/binary_sensor.py +++ b/homeassistant/components/geniushub/binary_sensor.py @@ -67,9 +67,8 @@ class GeniusBinarySensor(BinarySensorDevice): attrs = {} attrs["assigned_zone"] = self._device.assignedZones[0]["name"] - last_comms = self._device._raw_json["childValues"]["lastComms"][ - "val" - ] # noqa; pylint: disable=protected-access + # noqa; pylint: disable=protected-access + last_comms = self._device._raw_json["childValues"]["lastComms"]["val"] if last_comms != 0: attrs["last_comms"] = utc_from_timestamp(last_comms).isoformat() diff --git a/homeassistant/components/geniushub/sensor.py b/homeassistant/components/geniushub/sensor.py index 9b1063c6683..f87c957d3da 100644 --- a/homeassistant/components/geniushub/sensor.py +++ b/homeassistant/components/geniushub/sensor.py @@ -62,9 +62,8 @@ class GeniusDevice(Entity): @property def icon(self): """Return the icon of the sensor.""" - values = self._device._raw_json[ - "childValues" - ] # noqa; pylint: disable=protected-access + # noqa; pylint: disable=protected-access + values = self._device._raw_json["childValues"] last_comms = utc_from_timestamp(values["lastComms"]["val"]) if "WakeUp_Interval" in values: @@ -114,9 +113,8 @@ class GeniusDevice(Entity): attrs = {} attrs["assigned_zone"] = self._device.assignedZones[0]["name"] - last_comms = self._device._raw_json["childValues"]["lastComms"][ - "val" - ] # noqa; pylint: disable=protected-access + # noqa; pylint: disable=protected-access + last_comms = self._device._raw_json["childValues"]["lastComms"]["val"] attrs["last_comms"] = utc_from_timestamp(last_comms).isoformat() return {**attrs} diff --git a/homeassistant/components/honeywell/climate.py b/homeassistant/components/honeywell/climate.py index fc6144cfe46..62a370f60fa 100644 --- a/homeassistant/components/honeywell/climate.py +++ b/homeassistant/components/honeywell/climate.py @@ -161,8 +161,10 @@ class HoneywellUSThermostat(ClimateDevice): self._password = password _LOGGER.debug( - "latestData = %s ", device._data - ) # noqa; pylint: disable=protected-access + # noqa; pylint: disable=protected-access + "latestData = %s ", + device._data, + ) # not all honeywell HVACs support all modes mappings = [v for k, v in HVAC_MODE_TO_HW_MODE.items() if device.raw_ui_data[k]] @@ -174,9 +176,8 @@ class HoneywellUSThermostat(ClimateDevice): | SUPPORT_TARGET_TEMPERATURE_RANGE ) - if device._data[ - "canControlHumidification" - ]: # noqa; pylint: disable=protected-access + # noqa; pylint: disable=protected-access + if device._data["canControlHumidification"]: self._supported_features |= SUPPORT_TARGET_HUMIDITY if device.raw_ui_data["SwitchEmergencyHeatAllowed"]: @@ -464,5 +465,7 @@ class HoneywellUSThermostat(ClimateDevice): _LOGGER.error("SomeComfort update failed, Retrying - Error: %s", exp) _LOGGER.debug( - "latestData = %s ", self._device._data - ) # noqa; pylint: disable=protected-access + # noqa; pylint: disable=protected-access + "latestData = %s ", + self._device._data, + ) diff --git a/homeassistant/components/tank_utility/sensor.py b/homeassistant/components/tank_utility/sensor.py index a4e5e888b11..78fcd47099d 100644 --- a/homeassistant/components/tank_utility/sensor.py +++ b/homeassistant/components/tank_utility/sensor.py @@ -51,8 +51,9 @@ def setup_platform(hass, config, add_entities, discovery_info=None): token = auth.get_token(email, password) except requests.exceptions.HTTPError as http_error: if ( - http_error.response.status_code == requests.codes.unauthorized - ): # pylint: disable=no-member + http_error.response.status_code + == requests.codes.unauthorized # pylint: disable=no-member + ): _LOGGER.error("Invalid credentials") return @@ -115,8 +116,9 @@ class TankUtilitySensor(Entity): data = device.get_device_data(self._token, self.device) except requests.exceptions.HTTPError as http_error: if ( - http_error.response.status_code == requests.codes.unauthorized - ): # pylint: disable=no-member + http_error.response.status_code + == requests.codes.unauthorized # pylint: disable=no-member + ): _LOGGER.info("Getting new token") self._token = auth.get_token(self._email, self._password, force=True) data = device.get_device_data(self._token, self.device)