Skip to content

Commit

Permalink
Add pylint CodeStyle extension (home-assistant#53147)
Browse files Browse the repository at this point in the history
  • Loading branch information
cdce8p authored Jul 19, 2021
1 parent c35b5a1 commit f6b162b
Show file tree
Hide file tree
Showing 60 changed files with 103 additions and 98 deletions.
4 changes: 2 additions & 2 deletions homeassistant/components/alarmdecoder/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down Expand Up @@ -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])

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/apple_tv/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)]

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/aprs/device_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/arcam_fmj/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down
12 changes: 6 additions & 6 deletions homeassistant/components/bmw_connected_drive/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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}_", "")
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/climacell/weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/configurator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
)
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/daikin/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/deconz/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/devolo_home_control/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/doorbird/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/evohome/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/flunearyou/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/fritz/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)


Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/geniushub/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/guardian/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/guardian/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand All @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/harmony/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/history_stats/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/homekit/type_cameras.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)()
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/hyperion/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,10 +527,10 @@ async def async_turn_on(self, **kwargs: Any) -> None:
# color, effect), but this is not possible due to:
# https://github.com/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: {
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/image_processing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/incomfort/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/insteon/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
4 changes: 2 additions & 2 deletions homeassistant/components/iqvia/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/isy994/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/konnected/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/lifx/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/mqtt/fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/mqtt/humidifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/mvglive/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading

0 comments on commit f6b162b

Please sign in to comment.