Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split long strings in components #135263

Merged
merged 1 commit into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions homeassistant/components/bayesian/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,10 @@ class NumericConfig(NamedTuple):
for i, tup in enumerate(intervals):
if len(intervals) > i + 1 and tup.below > intervals[i + 1].above:
raise vol.Invalid(
f"Ranges for bayesian numeric state entities must not overlap, but {ent_id} has overlapping ranges, above:{tup.above}, below:{tup.below} overlaps with above:{intervals[i+1].above}, below:{intervals[i+1].below}."
"Ranges for bayesian numeric state entities must not overlap, "
f"but {ent_id} has overlapping ranges, above:{tup.above}, "
f"below:{tup.below} overlaps with above:{intervals[i + 1].above}, "
f"below:{intervals[i + 1].below}."
)
return configs

Expand Down Expand Up @@ -206,7 +209,10 @@ async def async_setup_platform(
broken_observations: list[dict[str, Any]] = []
for observation in observations:
if CONF_P_GIVEN_F not in observation:
text: str = f"{name}/{observation.get(CONF_ENTITY_ID,'')}{observation.get(CONF_VALUE_TEMPLATE,'')}"
text = (
f"{name}/{observation.get(CONF_ENTITY_ID, '')}"
f"{observation.get(CONF_VALUE_TEMPLATE, '')}"
)
raise_no_prob_given_false(hass, text)
_LOGGER.error("Missing prob_given_false YAML entry for %s", text)
broken_observations.append(observation)
Expand Down
4 changes: 3 additions & 1 deletion homeassistant/components/frontier_silicon/browse_media.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ def _item_preset_payload(preset: Preset, player_mode: str) -> BrowseMedia:
media_content_type=MediaType.CHANNEL,
# We add 1 to the preset key to keep it in sync with the numbering shown
# on the interface of the device
media_content_id=f"{player_mode}/{MEDIA_CONTENT_ID_PRESET}/{int(preset.key)+1}",
media_content_id=(
f"{player_mode}/{MEDIA_CONTENT_ID_PRESET}/{int(preset.key) + 1}"
),
can_play=True,
can_expand=False,
)
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/ista_ecotrend/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,12 @@ def __init__(
self.consumption_unit = consumption_unit
self.entity_description = entity_description
self._attr_unique_id = f"{consumption_unit}_{entity_description.key}"
address = coordinator.details[consumption_unit]["address"]
self._attr_device_info = DeviceInfo(
entry_type=DeviceEntryType.SERVICE,
manufacturer="ista SE",
model="ista EcoTrend",
name=f"{coordinator.details[consumption_unit]["address"]["street"]} "
f"{coordinator.details[consumption_unit]["address"]["houseNumber"]}".strip(),
name=f"{address['street']} {address['houseNumber']}".strip(),
configuration_url="https://ecotrend.ista.de/",
identifiers={(DOMAIN, consumption_unit)},
)
Expand Down
5 changes: 4 additions & 1 deletion homeassistant/components/mqtt/discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,10 @@ def get_origin_log_string(
support_url_log = ""
if include_url and (support_url := get_origin_support_url(discovery_payload)):
support_url_log = f", support URL: {support_url}"
return f" from external application {origin_info["name"]}{sw_version_log}{support_url_log}"
return (
" from external application "
f"{origin_info['name']}{sw_version_log}{support_url_log}"
)


@callback
Expand Down
5 changes: 4 additions & 1 deletion homeassistant/components/picnic/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ def _get_address(self):
"""Get the address that identifies the Picnic service."""
if self._user_address is None:
address = self.picnic_api_client.get_user()["address"]
self._user_address = f'{address["street"]} {address["house_number"]}{address["house_number_ext"]}'
self._user_address = (
f"{address['street']} "
f"{address['house_number']}{address['house_number_ext']}"
)

return self._user_address

Expand Down
5 changes: 3 additions & 2 deletions homeassistant/components/sonarr/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def get_queue_attr(queue: SonarrQueue) -> dict[str, str]:
remaining = 1 if item.size == 0 else item.sizeleft / item.size
remaining_pct = 100 * (1 - remaining)
identifier = (
f"S{item.episode.seasonNumber:02d}E{item.episode. episodeNumber:02d}"
f"S{item.episode.seasonNumber:02d}E{item.episode.episodeNumber:02d}"
)
attrs[f"{item.series.title} {identifier}"] = f"{remaining_pct:.2f}%"
return attrs
Expand Down Expand Up @@ -120,7 +120,8 @@ def get_wanted_attr(wanted: SonarrWantedMissing) -> dict[str, str]:
value_fn=len,
attributes_fn=lambda data: {
i.title: (
f"{getattr(i.statistics,'episodeFileCount', 0)}/{getattr(i.statistics, 'episodeCount', 0)} Episodes"
f"{getattr(i.statistics, 'episodeFileCount', 0)}/"
f"{getattr(i.statistics, 'episodeCount', 0)} Episodes"
)
for i in data
},
Expand Down
14 changes: 10 additions & 4 deletions homeassistant/components/stream/hls.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,13 @@ def render(cls, track: HlsStreamOutput) -> str:
if track.stream_settings.ll_hls:
playlist.extend(
[
f"#EXT-X-PART-INF:PART-TARGET={track.stream_settings.part_target_duration:.3f}",
f"#EXT-X-SERVER-CONTROL:CAN-BLOCK-RELOAD=YES,PART-HOLD-BACK={2*track.stream_settings.part_target_duration:.3f}",
f"#EXT-X-START:TIME-OFFSET=-{EXT_X_START_LL_HLS*track.stream_settings.part_target_duration:.3f},PRECISE=YES",
"#EXT-X-PART-INF:PART-TARGET="
f"{track.stream_settings.part_target_duration:.3f}",
"#EXT-X-SERVER-CONTROL:CAN-BLOCK-RELOAD=YES,PART-HOLD-BACK="
f"{2 * track.stream_settings.part_target_duration:.3f}",
"#EXT-X-START:TIME-OFFSET=-"
f"{EXT_X_START_LL_HLS * track.stream_settings.part_target_duration:.3f}"
",PRECISE=YES",
]
)
else:
Expand All @@ -203,7 +207,9 @@ def render(cls, track: HlsStreamOutput) -> str:
# which seems to take precedence for setting target delay. Yet it also
# doesn't seem to hurt, so we can stick with it for now.
playlist.append(
f"#EXT-X-START:TIME-OFFSET=-{EXT_X_START_NON_LL_HLS*track.target_duration:.3f},PRECISE=YES"
"#EXT-X-START:TIME-OFFSET=-"
f"{EXT_X_START_NON_LL_HLS * track.target_duration:.3f}"
",PRECISE=YES"
)

last_stream_id = first_segment.stream_id
Expand Down
3 changes: 2 additions & 1 deletion homeassistant/components/vicare/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ async def async_migrate_devices_and_entities(
# to `<device_identifier>-heating-<circuit_no>`
if entity_entry.domain == DOMAIN_CLIMATE:
unique_id_parts[len(unique_id_parts) - 1] = (
f"{entity_entry.translation_key}-{unique_id_parts[len(unique_id_parts)-1]}"
f"{entity_entry.translation_key}-"
f"{unique_id_parts[len(unique_id_parts) - 1]}"
)
entity_new_unique_id = "-".join(unique_id_parts)

Expand Down
6 changes: 5 additions & 1 deletion homeassistant/components/vicare/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ def __init__(
gateway_serial = device_config.getConfig().serial
device_id = device_config.getId()

identifier = f"{gateway_serial}_{device_serial.replace("zigbee-", "zigbee_") if device_serial is not None else device_id}"
identifier = (
f"{gateway_serial}_{device_serial.replace('zigbee-', 'zigbee_')}"
if device_serial is not None
else f"{gateway_serial}_{device_id}"
)

self._api: PyViCareDevice | PyViCareHeatingDeviceComponent = (
component if component else device
Expand Down