Skip to content

Commit e29ead2

Browse files
authored
Split long strings in components (#135263)
1 parent 5df7092 commit e29ead2

File tree

9 files changed

+41
-15
lines changed

9 files changed

+41
-15
lines changed

homeassistant/components/bayesian/binary_sensor.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,10 @@ class NumericConfig(NamedTuple):
131131
for i, tup in enumerate(intervals):
132132
if len(intervals) > i + 1 and tup.below > intervals[i + 1].above:
133133
raise vol.Invalid(
134-
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}."
134+
"Ranges for bayesian numeric state entities must not overlap, "
135+
f"but {ent_id} has overlapping ranges, above:{tup.above}, "
136+
f"below:{tup.below} overlaps with above:{intervals[i + 1].above}, "
137+
f"below:{intervals[i + 1].below}."
135138
)
136139
return configs
137140

@@ -206,7 +209,10 @@ async def async_setup_platform(
206209
broken_observations: list[dict[str, Any]] = []
207210
for observation in observations:
208211
if CONF_P_GIVEN_F not in observation:
209-
text: str = f"{name}/{observation.get(CONF_ENTITY_ID,'')}{observation.get(CONF_VALUE_TEMPLATE,'')}"
212+
text = (
213+
f"{name}/{observation.get(CONF_ENTITY_ID, '')}"
214+
f"{observation.get(CONF_VALUE_TEMPLATE, '')}"
215+
)
210216
raise_no_prob_given_false(hass, text)
211217
_LOGGER.error("Missing prob_given_false YAML entry for %s", text)
212218
broken_observations.append(observation)

homeassistant/components/frontier_silicon/browse_media.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ def _item_preset_payload(preset: Preset, player_mode: str) -> BrowseMedia:
3838
media_content_type=MediaType.CHANNEL,
3939
# We add 1 to the preset key to keep it in sync with the numbering shown
4040
# on the interface of the device
41-
media_content_id=f"{player_mode}/{MEDIA_CONTENT_ID_PRESET}/{int(preset.key)+1}",
41+
media_content_id=(
42+
f"{player_mode}/{MEDIA_CONTENT_ID_PRESET}/{int(preset.key) + 1}"
43+
),
4244
can_play=True,
4345
can_expand=False,
4446
)

homeassistant/components/ista_ecotrend/sensor.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -184,12 +184,12 @@ def __init__(
184184
self.consumption_unit = consumption_unit
185185
self.entity_description = entity_description
186186
self._attr_unique_id = f"{consumption_unit}_{entity_description.key}"
187+
address = coordinator.details[consumption_unit]["address"]
187188
self._attr_device_info = DeviceInfo(
188189
entry_type=DeviceEntryType.SERVICE,
189190
manufacturer="ista SE",
190191
model="ista EcoTrend",
191-
name=f"{coordinator.details[consumption_unit]["address"]["street"]} "
192-
f"{coordinator.details[consumption_unit]["address"]["houseNumber"]}".strip(),
192+
name=f"{address['street']} {address['houseNumber']}".strip(),
193193
configuration_url="https://ecotrend.ista.de/",
194194
identifiers={(DOMAIN, consumption_unit)},
195195
)

homeassistant/components/mqtt/discovery.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,10 @@ def get_origin_log_string(
138138
support_url_log = ""
139139
if include_url and (support_url := get_origin_support_url(discovery_payload)):
140140
support_url_log = f", support URL: {support_url}"
141-
return f" from external application {origin_info["name"]}{sw_version_log}{support_url_log}"
141+
return (
142+
" from external application "
143+
f"{origin_info['name']}{sw_version_log}{support_url_log}"
144+
)
142145

143146

144147
@callback

homeassistant/components/picnic/coordinator.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,10 @@ def _get_address(self):
7979
"""Get the address that identifies the Picnic service."""
8080
if self._user_address is None:
8181
address = self.picnic_api_client.get_user()["address"]
82-
self._user_address = f'{address["street"]} {address["house_number"]}{address["house_number_ext"]}'
82+
self._user_address = (
83+
f"{address['street']} "
84+
f"{address['house_number']}{address['house_number_ext']}"
85+
)
8386

8487
return self._user_address
8588

homeassistant/components/sonarr/sensor.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def get_queue_attr(queue: SonarrQueue) -> dict[str, str]:
6767
remaining = 1 if item.size == 0 else item.sizeleft / item.size
6868
remaining_pct = 100 * (1 - remaining)
6969
identifier = (
70-
f"S{item.episode.seasonNumber:02d}E{item.episode. episodeNumber:02d}"
70+
f"S{item.episode.seasonNumber:02d}E{item.episode.episodeNumber:02d}"
7171
)
7272
attrs[f"{item.series.title} {identifier}"] = f"{remaining_pct:.2f}%"
7373
return attrs
@@ -120,7 +120,8 @@ def get_wanted_attr(wanted: SonarrWantedMissing) -> dict[str, str]:
120120
value_fn=len,
121121
attributes_fn=lambda data: {
122122
i.title: (
123-
f"{getattr(i.statistics,'episodeFileCount', 0)}/{getattr(i.statistics, 'episodeCount', 0)} Episodes"
123+
f"{getattr(i.statistics, 'episodeFileCount', 0)}/"
124+
f"{getattr(i.statistics, 'episodeCount', 0)} Episodes"
124125
)
125126
for i in data
126127
},

homeassistant/components/stream/hls.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,13 @@ def render(cls, track: HlsStreamOutput) -> str:
188188
if track.stream_settings.ll_hls:
189189
playlist.extend(
190190
[
191-
f"#EXT-X-PART-INF:PART-TARGET={track.stream_settings.part_target_duration:.3f}",
192-
f"#EXT-X-SERVER-CONTROL:CAN-BLOCK-RELOAD=YES,PART-HOLD-BACK={2*track.stream_settings.part_target_duration:.3f}",
193-
f"#EXT-X-START:TIME-OFFSET=-{EXT_X_START_LL_HLS*track.stream_settings.part_target_duration:.3f},PRECISE=YES",
191+
"#EXT-X-PART-INF:PART-TARGET="
192+
f"{track.stream_settings.part_target_duration:.3f}",
193+
"#EXT-X-SERVER-CONTROL:CAN-BLOCK-RELOAD=YES,PART-HOLD-BACK="
194+
f"{2 * track.stream_settings.part_target_duration:.3f}",
195+
"#EXT-X-START:TIME-OFFSET=-"
196+
f"{EXT_X_START_LL_HLS * track.stream_settings.part_target_duration:.3f}"
197+
",PRECISE=YES",
194198
]
195199
)
196200
else:
@@ -203,7 +207,9 @@ def render(cls, track: HlsStreamOutput) -> str:
203207
# which seems to take precedence for setting target delay. Yet it also
204208
# doesn't seem to hurt, so we can stick with it for now.
205209
playlist.append(
206-
f"#EXT-X-START:TIME-OFFSET=-{EXT_X_START_NON_LL_HLS*track.target_duration:.3f},PRECISE=YES"
210+
"#EXT-X-START:TIME-OFFSET=-"
211+
f"{EXT_X_START_NON_LL_HLS * track.target_duration:.3f}"
212+
",PRECISE=YES"
207213
)
208214

209215
last_stream_id = first_segment.stream_id

homeassistant/components/vicare/__init__.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ async def async_migrate_devices_and_entities(
146146
# to `<device_identifier>-heating-<circuit_no>`
147147
if entity_entry.domain == DOMAIN_CLIMATE:
148148
unique_id_parts[len(unique_id_parts) - 1] = (
149-
f"{entity_entry.translation_key}-{unique_id_parts[len(unique_id_parts)-1]}"
149+
f"{entity_entry.translation_key}-"
150+
f"{unique_id_parts[len(unique_id_parts) - 1]}"
150151
)
151152
entity_new_unique_id = "-".join(unique_id_parts)
152153

homeassistant/components/vicare/entity.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ def __init__(
2929
gateway_serial = device_config.getConfig().serial
3030
device_id = device_config.getId()
3131

32-
identifier = f"{gateway_serial}_{device_serial.replace("zigbee-", "zigbee_") if device_serial is not None else device_id}"
32+
identifier = (
33+
f"{gateway_serial}_{device_serial.replace('zigbee-', 'zigbee_')}"
34+
if device_serial is not None
35+
else f"{gateway_serial}_{device_id}"
36+
)
3337

3438
self._api: PyViCareDevice | PyViCareHeatingDeviceComponent = (
3539
component if component else device

0 commit comments

Comments
 (0)