Update black to 23.1.0 (#87188)

This commit is contained in:
Franck Nijhof 2023-02-02 18:35:24 +01:00 committed by GitHub
parent f7666239ff
commit 5e81d28116
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
312 changed files with 299 additions and 475 deletions

View File

@ -20,7 +20,7 @@ repos:
- --remove-all-unused-imports
stages: [manual]
- repo: https://github.com/psf/black
rev: 22.12.0
rev: 23.1.0
hooks:
- id: black
args:

View File

@ -406,7 +406,6 @@ def async_enable_logging(
if (err_path_exists and os.access(err_log_path, os.W_OK)) or (
not err_path_exists and os.access(err_dir, os.W_OK)
):
err_handler: (
logging.handlers.RotatingFileHandler
| logging.handlers.TimedRotatingFileHandler

View File

@ -24,7 +24,6 @@ async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry) ->
# convert title and unique_id to string
if config_entry.version == 1:
if isinstance(config_entry.unique_id, int):
hass.config_entries.async_update_entry(
config_entry,
unique_id=str(config_entry.unique_id),

View File

@ -88,7 +88,6 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
errors["base"] = "cannot_connect"
else:
self.hass.config_entries.async_update_entry(
self.entry,
data={

View File

@ -270,7 +270,6 @@ class Alert(Entity):
await self._send_notification_message(message)
async def _send_notification_message(self, message: Any) -> None:
if not self._notifiers:
return

View File

@ -103,7 +103,6 @@ class Auth:
return dt.utcnow() < preemptive_expire_time
async def _async_request_new_token(self, lwa_params):
try:
session = aiohttp_client.async_get_clientsession(self.hass)
async with async_timeout.timeout(10):

View File

@ -193,7 +193,6 @@ def resolve_slot_synonyms(key, request):
and "resolutionsPerAuthority" in request["resolutions"]
and len(request["resolutions"]["resolutionsPerAuthority"]) >= 1
):
# Extract all of the possible values from each authority with a
# successful match
possible_values = []

View File

@ -274,7 +274,6 @@ class AsusWrtRouter:
entity_reg, self._entry.entry_id
)
for entry in track_entries:
if entry.domain != TRACKER_DOMAIN:
continue
device_mac = format_mac(entry.unique_id)

View File

@ -112,7 +112,6 @@ class AxisBinarySensor(AxisEventEntity, BinarySensorEntity):
self._attr_name = self.device.api.vapix.ports[event.id].name
elif event.group == EventGroup.MOTION:
for event_topic, event_data in (
(EventTopic.FENCE_GUARD, self.device.api.vapix.fence_guard),
(EventTopic.LOITERING_GUARD, self.device.api.vapix.loitering_guard),
@ -120,7 +119,6 @@ class AxisBinarySensor(AxisEventEntity, BinarySensorEntity):
(EventTopic.OBJECT_ANALYTICS, self.device.api.vapix.object_analytics),
(EventTopic.MOTION_DETECTION_4, self.device.api.vapix.vmd4),
):
if (
event.topic_base == event_topic
and event_data

View File

@ -399,7 +399,6 @@ class BayesianBinarySensor(BinarySensorEntity):
observations_by_entity: dict[str, list[Observation]] = {}
for observation in self._observations:
if (key := observation.entity_id) is None:
continue
observations_by_entity.setdefault(key, []).append(observation)

View File

@ -396,7 +396,6 @@ class BluesoundPlayer(MediaPlayerEntity):
_LOGGER.debug("Calling URL: %s", url)
try:
async with async_timeout.timeout(125):
response = await self._polling_session.get(
url, headers={CONNECTION: KEEP_ALIVE}

View File

@ -12,7 +12,6 @@ from home_assistant_bluetooth import BluetoothServiceInfoBleak
from homeassistant.util.dt import monotonic_time_coarse
if TYPE_CHECKING:
from .manager import BluetoothManager

View File

@ -95,7 +95,6 @@ async def async_setup_entry(
session: SHCSession = hass.data[DOMAIN][config_entry.entry_id][DATA_SESSION]
for switch in session.device_helper.smart_plugs:
entities.append(
SHCSwitch(
device=switch,
@ -113,7 +112,6 @@ async def async_setup_entry(
)
for switch in session.device_helper.light_switches:
entities.append(
SHCSwitch(
device=switch,
@ -124,7 +122,6 @@ async def async_setup_entry(
)
for switch in session.device_helper.smart_plugs_compact:
entities.append(
SHCSwitch(
device=switch,
@ -135,7 +132,6 @@ async def async_setup_entry(
)
for switch in session.device_helper.camera_eyes:
entities.append(
SHCSwitch(
device=switch,
@ -146,7 +142,6 @@ async def async_setup_entry(
)
for switch in session.device_helper.camera_360:
entities.append(
SHCSwitch(
device=switch,

View File

@ -231,7 +231,10 @@ SENSOR_DESCRIPTIONS = {
state_class=SensorStateClass.MEASUREMENT,
),
# UV index (-)
(BTHomeSensorDeviceClass.UV_INDEX, None,): SensorEntityDescription(
(
BTHomeSensorDeviceClass.UV_INDEX,
None,
): SensorEntityDescription(
key=f"{BTHomeSensorDeviceClass.UV_INDEX}",
state_class=SensorStateClass.MEASUREMENT,
),
@ -256,7 +259,10 @@ SENSOR_DESCRIPTIONS = {
state_class=SensorStateClass.MEASUREMENT,
),
# Volume (L)
(BTHomeSensorDeviceClass.VOLUME, Units.VOLUME_LITERS,): SensorEntityDescription(
(
BTHomeSensorDeviceClass.VOLUME,
Units.VOLUME_LITERS,
): SensorEntityDescription(
key=f"{BTHomeSensorDeviceClass.VOLUME}_{Units.VOLUME_LITERS}",
device_class=SensorDeviceClass.VOLUME,
native_unit_of_measurement=UnitOfVolume.LITERS,

View File

@ -735,7 +735,6 @@ class BrSensor(SensorEntity):
or sensor_type.endswith("_4d")
or sensor_type.endswith("_5d")
):
# update forecasting sensors:
fcday = 0
if sensor_type.endswith("_2d"):

View File

@ -96,7 +96,6 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
"""Handle the initial step."""
errors = {}
if user_input is not None:
hub = Control4Validator(
user_input[CONF_HOST],
user_input[CONF_USERNAME],

View File

@ -188,6 +188,7 @@ class DarkSkyWeather(WeatherEntity):
@property
def forecast(self):
"""Return the forecast array."""
# Per conversation with Joshua Reyes of Dark Sky, to get the total
# forecasted precipitation, you have to multiple the intensity by
# the hours for the forecast interval

View File

@ -271,7 +271,6 @@ class DeconzBinarySensor(DeconzDevice[SensorResources], BinarySensorEntity):
attr[ATTR_TEMPERATURE] = self._device.internal_temperature
if isinstance(self._device, Presence):
if self._device.dark is not None:
attr[ATTR_DARK] = self._device.dark

View File

@ -87,7 +87,6 @@ class DeconzFlowHandler(ConfigFlow, domain=DOMAIN):
If no bridge is found allow user to manually input configuration.
"""
if user_input is not None:
if user_input[CONF_HOST] == CONF_MANUAL_INPUT:
return await self.async_step_manual_input()

View File

@ -372,7 +372,6 @@ class DeconzSensor(DeconzDevice[SensorResources], SensorEntity):
attr[ATTR_DAYLIGHT] = self._device.daylight
elif isinstance(self._device, LightLevel):
if self._device.dark is not None:
attr[ATTR_DARK] = self._device.dark

View File

@ -186,10 +186,8 @@ async def async_remove_orphaned_entries_service(gateway: DeconzGateway) -> None:
devices_to_be_removed.remove(event.device_id)
for entry in entity_entries:
# Don't remove available entities
if entry.unique_id in gateway.entities[entry.domain]:
# Don't remove devices with available entities
if entry.device_id in devices_to_be_removed:
devices_to_be_removed.remove(entry.device_id)

View File

@ -121,6 +121,6 @@ class DeLijnPublicTransportSensor(SensorEntity):
self._attr_extra_state_attributes["next_passages"] = self.line.passages
self._attr_available = True
except (KeyError) as error:
except KeyError as error:
_LOGGER.error("Invalid data received from De Lijn: %s", error)
self._attr_available = False

View File

@ -245,7 +245,7 @@ class DerivativeSensor(RestoreEntity, SensorEntity):
derivative = new_derivative
else:
derivative = Decimal(0)
for (start, end, value) in self._state_list:
for start, end, value in self._state_list:
weight = calculate_weight(start, end, new_state.last_updated)
derivative = derivative + (value * Decimal(weight))

View File

@ -214,7 +214,6 @@ async def activate_automation( # noqa: C901
elif start_point and start_point < now < get_astral_event_next(
hass, SUN_EVENT_SUNSET
):
# Check for every light if it would be on if someone was home
# when the fading in started and turn it on if so
for index, light_id in enumerate(light_ids):

View File

@ -93,7 +93,6 @@ class DnsIPConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
errors = {}
if user_input:
hostname = user_input[CONF_HOSTNAME]
name = DEFAULT_NAME if hostname == DEFAULT_HOSTNAME else hostname
resolver = user_input.get(CONF_RESOLVER, DEFAULT_RESOLVER)

View File

@ -255,7 +255,6 @@ class Doods(ImageProcessingEntity):
)
for label, values in matches.items():
# Draw custom label regions/areas
if label in self._label_areas and self._label_areas[label] != [0, 0, 1, 1]:
box_label = f"{label.capitalize()} Detection Area"

View File

@ -66,7 +66,6 @@ def setup(hass: HomeAssistant, config: ConfigType) -> bool:
server_address = (conf.get(CONF_HOST), conf.get(CONF_PORT))
try:
ebusdpy.init(server_address)
hass.data[DOMAIN] = EbusdData(server_address, circuit)

View File

@ -160,7 +160,6 @@ class EcovacsVacuum(VacuumEntity):
def set_fan_speed(self, fan_speed: str, **kwargs: Any) -> None:
"""Set fan speed."""
if self.is_on:
self.device.run(sucks.Clean(mode=self.device.clean_status, speed=fan_speed))
def send_command(

View File

@ -87,7 +87,7 @@ class SmartPlugSwitch(SwitchEntity):
self._state = self._pca.get_state(self._device_id)
self._available = True
except (OSError) as ex:
except OSError as ex:
if self._available:
_LOGGER.warning("Could not read state for %s: %s", self.name, ex)
self._available = False

View File

@ -106,7 +106,6 @@ def setup_platform(
sensors = []
for elem in data.data:
if exclude_feeds is not None and int(elem["id"]) in exclude_feeds:
continue

View File

@ -379,7 +379,7 @@ class HueOneLightChangeView(HomeAssistantView):
else:
parsed[STATE_ON] = entity.state != STATE_OFF
for (key, attr) in (
for key, attr in (
(HUE_API_STATE_BRI, STATE_BRIGHTNESS),
(HUE_API_STATE_HUE, STATE_HUE),
(HUE_API_STATE_SAT, STATE_SATURATION),
@ -587,7 +587,7 @@ class HueOneLightChangeView(HomeAssistantView):
)
]
for (key, val) in (
for key, val in (
(STATE_BRIGHTNESS, HUE_API_STATE_BRI),
(STATE_HUE, HUE_API_STATE_HUE),
(STATE_SATURATION, HUE_API_STATE_SAT),
@ -705,7 +705,7 @@ def get_entity_state_dict(config: Config, entity: State) -> dict[str, Any]:
data[STATE_SATURATION] = 0
# Clamp brightness, hue, saturation, and color temp to valid values
for (key, v_min, v_max) in (
for key, v_min, v_max in (
(STATE_BRIGHTNESS, HUE_API_STATE_BRI_MIN, HUE_API_STATE_BRI_MAX),
(STATE_HUE, HUE_API_STATE_HUE_MIN, HUE_API_STATE_HUE_MAX),
(STATE_SATURATION, HUE_API_STATE_SAT_MIN, HUE_API_STATE_SAT_MAX),

View File

@ -21,7 +21,6 @@ _LOGGER = logging.getLogger(__name__)
async def _async_has_devices(hass: HomeAssistant) -> bool:
controller_ready = asyncio.Event()
@callback

View File

@ -66,7 +66,6 @@ async def async_setup_entry(
camera_entities = []
for camera, value in coordinator.data.items():
camera_rtsp_entry = [
item
for item in hass.config_entries.async_entries(DOMAIN)
@ -81,7 +80,6 @@ async def async_setup_entry(
)
if camera_rtsp_entry:
ffmpeg_arguments = camera_rtsp_entry[0].options[CONF_FFMPEG_ARGUMENTS]
camera_username = camera_rtsp_entry[0].data[CONF_USERNAME]
camera_password = camera_rtsp_entry[0].data[CONF_PASSWORD]
@ -96,7 +94,6 @@ async def async_setup_entry(
)
else:
discovery_flow.async_create_flow(
hass,
DOMAIN,

View File

@ -182,7 +182,6 @@ class EzvizConfigFlow(ConfigFlow, domain=DOMAIN):
errors = {}
if user_input is not None:
if user_input[CONF_URL] == CONF_CUSTOMIZE:
self.context["data"] = {
CONF_USERNAME: user_input[CONF_USERNAME],

View File

@ -25,7 +25,6 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
"""Handle the initial step."""
errors = {}
if user_input is not None:
await self.async_set_unique_id(user_input[CONF_ID])
self._abort_if_unique_id_configured()

View File

@ -507,7 +507,6 @@ class RangeFilter(Filter, SensorEntity):
new_state_value = cast(float, new_state.state)
if self._upper_bound is not None and new_state_value > self._upper_bound:
self._stats_internal["erasures_up"] += 1
_LOGGER.debug(
@ -519,7 +518,6 @@ class RangeFilter(Filter, SensorEntity):
new_state.state = self._upper_bound
elif self._lower_bound is not None and new_state_value < self._lower_bound:
self._stats_internal["erasures_low"] += 1
_LOGGER.debug(
@ -564,7 +562,6 @@ class OutlierFilter(Filter, SensorEntity):
len(self.states) == self.states.maxlen
and abs(new_state_value - median) > self._radius
):
self._stats_internal["erasures"] += 1
_LOGGER.debug(

View File

@ -208,7 +208,6 @@ class FinTsClient:
holdings_accounts = []
for account in self.client.get_sepa_accounts():
if self.is_balance_account(account):
balance_accounts.append(account)

View File

@ -213,7 +213,7 @@ async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry) ->
_LOGGER.debug("Closing Firmata board %s", config_entry.data[CONF_NAME])
unload_entries = []
for (conf, platform) in CONF_PLATFORM_MAP.items():
for conf, platform in CONF_PLATFORM_MAP.items():
if conf in config_entry.data:
unload_entries.append(
hass.config_entries.async_forward_entry_unload(config_entry, platform)

View File

@ -86,7 +86,6 @@ class FleetGoDeviceScanner:
for device in devices:
if not self._include or device.license_plate in self._include:
if device.active or device.current_address is None:
device.get_map_details()

View File

@ -74,7 +74,7 @@ class FliprDataUpdateCoordinator(DataUpdateCoordinator):
data = await self.hass.async_add_executor_job(
self.client.get_pool_measure_latest, self.flipr_id
)
except (FliprError) as error:
except FliprError as error:
raise UpdateFailed(error) from error
return data

View File

@ -43,7 +43,7 @@ class FloDeviceDataUpdateCoordinator(DataUpdateCoordinator):
await self.send_presence_ping()
await self._update_device()
await self._update_consumption_data()
except (RequestError) as error:
except RequestError as error:
raise UpdateFailed(error) from error
@property

View File

@ -97,7 +97,6 @@ async def async_setup_entry(
]
flume_entity_list = []
for device in flume_devices:
device_id = device[KEY_DEVICE_ID]
device_timezone = device[KEY_DEVICE_LOCATION][KEY_DEVICE_LOCATION_TIMEZONE]
device_location_name = device[KEY_DEVICE_LOCATION][KEY_DEVICE_LOCATION_NAME]

View File

@ -102,7 +102,6 @@ async def _async_port_entities_list(
_LOGGER.debug("IP source for %s is %s", avm_wrapper.host, local_ip)
for i in range(port_forwards_count):
portmap = await avm_wrapper.async_get_port_mapping(
avm_wrapper.device_conn_type, i
)
@ -406,7 +405,6 @@ class FritzBoxPortSwitch(FritzBoxBaseSwitch, SwitchEntity):
self._attributes[attr] = self.port_mapping[key]
async def _async_switch_on_off_executor(self, turn_on: bool) -> bool:
if self.port_mapping is None:
return False

View File

@ -262,7 +262,6 @@ async def async_setup_entry(
if entity_id := ent_reg.async_get_entity_id(
Platform.SENSOR, DOMAIN, old_unique_id
):
ent_reg.async_update_entity(
entity_id, new_unique_id=f"{config_entry.entry_id}-{new_key}"
)

View File

@ -289,7 +289,6 @@ class AbstractConfig(ABC):
return
for user_agent_id, _ in self._store.agent_user_ids.items():
if (webhook_id := self.get_local_webhook_id(user_agent_id)) is None:
setup_successful = False
break

View File

@ -64,7 +64,6 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
"""Handle the initial step."""
errors = {}
if user_input is not None:
try:
validated = await validate_input(user_input)
except CannotConnect:

View File

@ -316,7 +316,12 @@ class HomematicipHeatingGroup(HomematicipGenericEntity, ClimateEntity):
@property
def _first_radiator_thermostat(
self,
) -> AsyncHeatingThermostat | AsyncHeatingThermostatCompact | AsyncHeatingThermostatEvo | None:
) -> (
AsyncHeatingThermostat
| AsyncHeatingThermostatCompact
| AsyncHeatingThermostatEvo
| None
):
"""Return the first radiator thermostat from the hmip heating group."""
for device in self._device.devices:
if isinstance(

View File

@ -343,7 +343,6 @@ class HoneywellUSThermostat(ClimateEntity):
_LOGGER.error("Can not get system mode")
return
try:
# Set permanent hold
# and Set temperature
if mode in COOLING_MODES:

View File

@ -67,7 +67,6 @@ class HoneywellConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
errors["base"] = "cannot_connect"
else:
self.hass.config_entries.async_update_entry(
self.entry,
data={

View File

@ -92,7 +92,6 @@ async def handle_v2_migration(hass: core.HomeAssistant, entry: ConfigEntry) -> N
# initialize bridge connection just for the migration
async with HueBridgeV2(host, api_key) as api:
sensor_class_mapping = {
SensorDeviceClass.BATTERY.value: ResourceTypes.DEVICE_POWER,
BinarySensorDeviceClass.MOTION.value: ResourceTypes.MOTION,
@ -130,7 +129,6 @@ async def handle_v2_migration(hass: core.HomeAssistant, entry: ConfigEntry) -> N
# loop through all entities for device and find match
for ent in async_entries_for_device(ent_reg, hass_dev_id, True):
if ent.entity_id.startswith("light"):
# migrate light
# should always return one lightid here

View File

@ -48,7 +48,6 @@ async def async_setup_entry(
for partial_station in station_information.get("partialStations", []):
for elevator in partial_station.get("elevators", []):
state = elevator.get("state") != "READY"
available = elevator.get("state") != "UNKNOWN"
label = elevator.get("label")

View File

@ -81,7 +81,6 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
async def async_step_station(self, user_input=None):
"""Handle the step where the user inputs his/her station."""
if user_input is not None:
errors = {}
check_name = await self.hub.gti.checkName(
@ -145,7 +144,6 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
"""Manage the options."""
errors = {}
if not self.departure_filters:
departure_list = {}
hub: GTIHub = self.hass.data[DOMAIN][self.config_entry.entry_id]
@ -172,7 +170,6 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
}
if user_input is not None and not errors:
options = {
CONF_FILTER: [
self.departure_filters[x] for x in user_input[CONF_FILTER]

View File

@ -259,7 +259,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
for device_entry in dr.async_entries_for_config_entry(
device_registry, entry.entry_id
):
for (kind, key) in device_entry.identifiers:
for kind, key in device_entry.identifiers:
if kind == DOMAIN and key in known_devices:
break
else:

View File

@ -77,7 +77,6 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
target_keys[target] = api_keys[target]
try:
for target, key in target_keys.items():
res = pyfttt.send_event(key, event, value1, value2, value3)
if res.status_code != HTTPStatus.OK:

View File

@ -119,7 +119,6 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
)
if user_input is not None:
control_schema = vol.Schema(
{
vol.Required(

View File

@ -33,7 +33,6 @@ class IntellifireDataUpdateCoordinator(DataUpdateCoordinator[IntellifirePollData
self._api = api
async def _async_update_data(self) -> IntellifirePollData:
if not self._api.is_polling_in_background:
LOGGER.info("Starting Intellifire Background Polling Loop")
await self._api.start_background_polling()

View File

@ -95,7 +95,7 @@ async def async_setup_entry(
entities_by_address[node.address] = entity
# Handle some special child node cases for Insteon Devices
for (node, device_class, device_type, device_info) in child_nodes:
for node, device_class, device_type, device_info in child_nodes:
subnode_id = int(node.address.split(" ")[-1], 16)
# Handle Insteon Thermostats
if device_type is not None and device_type.startswith(TYPE_CATEGORY_CLIMATE):

View File

@ -109,7 +109,6 @@ def _check_for_insteon_type(
device_type.startswith(t)
for t in set(NODE_FILTERS[platform][FILTER_INSTEON_TYPE])
):
# Hacky special-cases for certain devices with different platforms
# included as subnodes. Note that special-cases are not necessary
# on ISY 5.x firmware as it uses the superior NodeDefs method

View File

@ -173,6 +173,7 @@ class ControllerDevice(ClimateEntity):
async def async_added_to_hass(self) -> None:
"""Call on adding to hass."""
# Register for connect/disconnect/update events
@callback
def controller_disconnected(ctrl: Controller, ex: Exception) -> None:
@ -290,7 +291,7 @@ class ControllerDevice(ClimateEntity):
return HVACMode.OFF
if (mode := self._controller.mode) == Controller.Mode.FREE_AIR:
return HVACMode.FAN_ONLY
for (key, value) in self._state_to_pizone.items():
for key, value in self._state_to_pizone.items():
if value == mode:
return key
raise RuntimeError("Should be unreachable")
@ -527,7 +528,7 @@ class ZoneDevice(ClimateEntity):
def hvac_mode(self) -> HVACMode | None:
"""Return current operation ie. heat, cool, idle."""
mode = self._zone.mode
for (key, value) in self._state_to_pizone.items():
for key, value in self._state_to_pizone.items():
if value == mode:
return key
return None

View File

@ -17,7 +17,6 @@ _LOGGER = logging.getLogger(__name__)
async def _async_has_devices(hass: HomeAssistant) -> bool:
controller_ready = asyncio.Event()
@callback

View File

@ -46,7 +46,6 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
"""Handle the initial step."""
errors = {}
if user_input is not None:
await self.async_set_unique_id(user_input[CONF_ACCESS_TOKEN])
self._abort_if_unique_id_configured()

View File

@ -17,7 +17,7 @@ class DemoFixFlow(RepairsFlow):
) -> data_entry_flow.FlowResult:
"""Handle the first step of a fix flow."""
return await (self.async_step_confirm())
return await self.async_step_confirm()
async def async_step_confirm(
self, user_input: dict[str, str] | None = None

View File

@ -62,7 +62,6 @@ async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry) ->
# Removing domain name and config entry id from entity unique id's, replacing it with device number
if config_entry.version == 1:
config_entry.version = 2
device_number = config_entry.data["device_number"]

View File

@ -296,7 +296,6 @@ class LIFXManager:
)
elif service == SERVICE_EFFECT_MORPH:
theme_name = kwargs.get(ATTR_THEME, "exciting")
palette = kwargs.get(ATTR_PALETTE, None)
@ -336,7 +335,6 @@ class LIFXManager:
)
elif service == SERVICE_EFFECT_PULSE:
effect = aiolifx_effects.EffectPulse(
power_on=kwargs.get(ATTR_POWER_ON),
period=kwargs.get(ATTR_PERIOD),
@ -347,7 +345,6 @@ class LIFXManager:
await self.effects_conductor.start(effect, bulbs)
elif service == SERVICE_EFFECT_COLORLOOP:
brightness = None
saturation_max = None
saturation_min = None
@ -378,7 +375,6 @@ class LIFXManager:
await self.effects_conductor.start(effect, bulbs)
elif service == SERVICE_EFFECT_STOP:
await self.effects_conductor.stop(bulbs)
for coordinator in coordinators:

View File

@ -218,7 +218,6 @@ def parse_api_response(response):
for authority in AUTHORITIES:
for entry in response["HourlyAirQualityIndex"]["LocalAuthority"]:
if entry["@LocalAuthorityName"] == authority:
if isinstance(entry["Site"], dict):
entry_sites_data = [entry["Site"]]
else:

View File

@ -157,7 +157,6 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
return
if change_type == collection.CHANGE_ADDED:
existing = hass.data[DOMAIN]["dashboards"].get(url_path)
if existing:

View File

@ -31,7 +31,6 @@ def setup_platform(
devices = []
for device in data.lupusec.get_devices(generic_type=CONST.TYPE_SWITCH):
devices.append(LupusecSwitch(data, device))
add_entities(devices)

View File

@ -24,7 +24,7 @@ def setup_platform(
if discovery_info is None:
return
devs = []
for (area_name, device) in hass.data[LUTRON_DEVICES]["binary_sensor"]:
for area_name, device in hass.data[LUTRON_DEVICES]["binary_sensor"]:
dev = LutronOccupancySensor(area_name, device, hass.data[LUTRON_CONTROLLER])
devs.append(dev)

View File

@ -26,7 +26,7 @@ def setup_platform(
) -> None:
"""Set up the Lutron shades."""
devs = []
for (area_name, device) in hass.data[LUTRON_DEVICES]["cover"]:
for area_name, device in hass.data[LUTRON_DEVICES]["cover"]:
dev = LutronCover(area_name, device, hass.data[LUTRON_CONTROLLER])
devs.append(dev)

View File

@ -19,7 +19,7 @@ def setup_platform(
) -> None:
"""Set up the Lutron lights."""
devs = []
for (area_name, device) in hass.data[LUTRON_DEVICES]["light"]:
for area_name, device in hass.data[LUTRON_DEVICES]["light"]:
dev = LutronLight(area_name, device, hass.data[LUTRON_CONTROLLER])
devs.append(dev)

View File

@ -21,7 +21,7 @@ def setup_platform(
devs = []
# Add Lutron Switches
for (area_name, device) in hass.data[LUTRON_DEVICES]["switch"]:
for area_name, device in hass.data[LUTRON_DEVICES]["switch"]:
dev = LutronSwitch(area_name, device, hass.data[LUTRON_CONTROLLER])
devs.append(dev)

View File

@ -256,7 +256,6 @@ def _async_setup_keypads(
leap_to_keypad_button_names: dict[int, dict[int, str]] = {}
for bridge_button in bridge_buttons.values():
parent_device = cast(str, bridge_button["parent_device"])
bridge_keypad = bridge_devices[parent_device]
keypad_lutron_device_id = cast(int, bridge_keypad["device_id"])

View File

@ -29,7 +29,6 @@ async def async_setup_entry(
entities: list[LutronCasetaButton] = []
for device in button_devices.values():
parent_keypad = keypads[device["parent_device"]]
parent_device_info = parent_keypad["device_info"]

View File

@ -93,7 +93,6 @@ async def async_setup_platform(
async_add_entities([new_stb])
if not config[CONF_OPTIMISTIC]:
already_installed = hass.data.get(DISCOVERY_MEDIAROOM)
if not already_installed:
hass.data[DISCOVERY_MEDIAROOM] = await install_mediaroom_protocol(

View File

@ -80,12 +80,10 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
for discovery_info in async_discovered_service_info(
self.hass, connectable=True
):
if discovery_info.manufacturer_id == MANUFACTURER_ID and any(
manufacturer_data.startswith(MANUFACTURER_DATA_START)
for manufacturer_data in discovery_info.manufacturer_data.values()
):
address = discovery_info.address
if (
address not in current_addresses

View File

@ -94,7 +94,7 @@ class MetWeather(CoordinatorEntity[MetDataUpdateCoordinator], WeatherEntity):
self._hourly = hourly
@property
def track_home(self) -> (Any | bool):
def track_home(self) -> Any | bool:
"""Return if we are tracking home."""
return self._config.get(CONF_TRACK_HOME, False)

View File

@ -172,7 +172,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
if hass.data[DOMAIN][entry.entry_id][COORDINATOR_ALERT]:
department = hass.data[DOMAIN][entry.entry_id][
COORDINATOR_FORECAST
].data.position.get("dept")

View File

@ -35,12 +35,10 @@ async def async_setup_entry(
# Restore clients that is not a part of active clients list.
for entity in registry.entities.values():
if (
entity.config_entry_id == config_entry.entry_id
and entity.domain == DEVICE_TRACKER
):
if (
entity.unique_id in coordinator.api.devices
or entity.unique_id not in coordinator.api.all_devices

View File

@ -22,7 +22,7 @@ async def async_check_srv_record(
srv_records = await aiodns.DNSResolver().query(
host=f"{SRV_RECORD_PREFIX}.{host}", qtype="SRV"
)
except (aiodns.error.DNSError):
except aiodns.error.DNSError:
# 'host' is not a SRV record.
pass
else:

View File

@ -249,7 +249,10 @@ CLIMATE_SCHEMA = vol.All(
COVERS_SCHEMA = BASE_COMPONENT_SCHEMA.extend(
{
vol.Optional(CONF_INPUT_TYPE, default=CALL_TYPE_REGISTER_HOLDING,): vol.In(
vol.Optional(
CONF_INPUT_TYPE,
default=CALL_TYPE_REGISTER_HOLDING,
): vol.In(
[
CALL_TYPE_REGISTER_HOLDING,
CALL_TYPE_COIL,

View File

@ -315,7 +315,6 @@ class MoldIndicator(SensorEntity):
def _calc_moldindicator(self):
"""Calculate the humidity at the (cold) calibration point."""
if None in (self._dewpoint, self._calib_factor) or self._calib_factor == 0:
_LOGGER.debug(
"Invalid inputs - dewpoint: %s, calibration-factor: %s",
self._dewpoint,

View File

@ -200,7 +200,6 @@ class MqttBinarySensor(MqttEntity, BinarySensorEntity, RestoreEntity):
"""Handle a new received MQTT state message."""
# auto-expire enabled?
if self._expire_after:
# When expire_after is set, and we receive a message, assume device is
# not expired since it has to be to receive the message
self._expired = False

View File

@ -666,7 +666,6 @@ class MQTT:
subscriptions = self._matching_subscriptions(msg.topic)
for subscription in subscriptions:
payload: SubscribePayloadType = msg.payload
if subscription.encoding is not None:
try:

View File

@ -279,7 +279,7 @@ async def async_start( # noqa: C901
mqtt_data.last_discovery = time.time()
mqtt_integrations = await async_get_mqtt(hass)
for (integration, topics) in mqtt_integrations.items():
for integration, topics in mqtt_integrations.items():
async def async_integration_message_received(
integration: str, msg: ReceiveMessage

View File

@ -64,7 +64,11 @@ class EntitySubscription:
if other is None:
return True
return (self.topic, self.qos, self.encoding,) != (
return (
self.topic,
self.qos,
self.encoding,
) != (
other.topic,
other.qos,
other.encoding,

View File

@ -135,7 +135,6 @@ class NAMFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
_LOGGER.exception("Unexpected exception")
errors["base"] = "unknown"
else:
return self.async_create_entry(
title=self.host,
data={**user_input, CONF_HOST: self.host},

View File

@ -428,7 +428,6 @@ class NestFlowHandler(
_LOGGER.error("Error creating subscription: %s", err)
errors[CONF_CLOUD_PROJECT_ID] = "subscriber_error"
if not errors:
try:
device_manager = await subscriber.async_get_device_manager()
except ApiException as err:

View File

@ -26,7 +26,6 @@ class NFAndroidTVFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
errors = {}
if user_input is not None:
self._async_abort_entries_match(
{CONF_HOST: user_input[CONF_HOST], CONF_NAME: user_input[CONF_NAME]}
)

View File

@ -265,7 +265,6 @@ class Coordinator(ContextCoordinator[dict[int, Coil], int]):
self.task = None
async def _async_update_data_internal(self) -> dict[int, Coil]:
result: dict[int, Coil] = {}
def _get_coils() -> Iterable[Coil]:

View File

@ -99,7 +99,6 @@ class NINADataUpdateCoordinator(
all_filtered_warnings: dict[str, list[Any]] = {}
for region_id, raw_warnings in warnings.items():
filtered_warnings: list[Any] = []
processed_details: list[tuple[str, str]] = []

View File

@ -126,7 +126,6 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
user_input[CONF_REGIONS] += group_input
if user_input[CONF_REGIONS]:
return self.async_create_entry(
title="NINA",
data=prepare_user_input(user_input, self._all_region_codes_sorted),
@ -203,7 +202,6 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
user_input[CONF_REGIONS] += group_input
if user_input[CONF_REGIONS]:
user_input = prepare_user_input(
user_input, self._all_region_codes_sorted
)

View File

@ -52,7 +52,6 @@ def setup_platform(
ports = platform[CONF_PORTS]
for port, port_name in ports.items():
try:
api.setup_input(device_id, port)
api.edge_detect(device_id, port, partial(read_gpio, device_id))

View File

@ -108,7 +108,6 @@ class OnvifFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
If no device is found allow user to manually input configuration.
"""
if user_input:
if user_input[CONF_HOST] == CONF_MANUAL_INPUT:
return await self.async_step_configure()

View File

@ -94,7 +94,6 @@ class OpenMeteoWeatherEntity(
forecasts: list[Forecast] = []
daily = self.coordinator.data.daily
for index, time in enumerate(self.coordinator.data.daily.time):
forecast = Forecast(
datetime=time.isoformat(),
)

View File

@ -189,7 +189,7 @@ class OpenCVImageProcessor(ImageProcessingEntity):
)
regions = []
# pylint: disable=invalid-name
for (x, y, w, h) in detections:
for x, y, w, h in detections:
regions.append((int(x), int(y), int(w), int(h)))
total_matches += 1

View File

@ -79,10 +79,12 @@ async def async_setup_platform(
)
def catch_request_errors() -> Callable[
[Callable[Concatenate[_OpenhomeDeviceT, _P], Awaitable[_R]]],
Callable[Concatenate[_OpenhomeDeviceT, _P], Coroutine[Any, Any, _R | None]],
]:
def catch_request_errors() -> (
Callable[
[Callable[Concatenate[_OpenhomeDeviceT, _P], Awaitable[_R]]],
Callable[Concatenate[_OpenhomeDeviceT, _P], Coroutine[Any, Any, _R | None]],
]
):
"""Catch asyncio.TimeoutError, aiohttp.ClientError, UpnpError errors."""
def call_wrapper(
@ -265,7 +267,7 @@ class OpenhomeDevice(MediaPlayerEntity):
await self._device.invoke_pin(pin)
else:
_LOGGER.error("Pins service not supported")
except (UpnpError):
except UpnpError:
_LOGGER.error("Error invoking pin %s", pin)
@property

View File

@ -251,7 +251,6 @@ class WeatherUpdateCoordinator(DataUpdateCoordinator):
def _get_condition(self, weather_code, timestamp=None):
"""Get weather condition from weather data."""
if weather_code == WEATHER_CODE_SUNNY_OR_CLEAR_NIGHT:
if timestamp:
timestamp = dt.utc_from_timestamp(timestamp)

View File

@ -49,7 +49,6 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
self._pair_state: Any = None
async def _async_create_current(self) -> FlowResult:
system = self._current[CONF_SYSTEM]
return self.async_create_entry(
title=f"{system['name']} ({system['serialnumber']})",

View File

@ -437,7 +437,6 @@ class PhilipsTVMediaPlayer(
@callback
def _update_from_coordinator(self):
if self._tv.on:
if self._tv.powerstate in ("Standby", "StandbyKeep"):
self._attr_state = MediaPlayerState.OFF

View File

@ -178,7 +178,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
def plex_websocket_callback(msgtype, data, error):
"""Handle callbacks from plexwebsocket library."""
if msgtype == SIGNAL_CONNECTION_STATE:
if data == STATE_CONNECTED:
_LOGGER.debug("Websocket to %s successful", entry.data[CONF_SERVER])
hass.async_create_task(plex_server.async_update_platforms())

Some files were not shown because too many files have changed in this diff Show More