mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 01:08:12 +00:00
Add ruff rule PIE800 (#113619)
Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
parent
43652a4ace
commit
69564b1a17
@ -135,4 +135,4 @@ class AccuWeatherDataUpdateCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
||||
) as error:
|
||||
raise UpdateFailed(error) from error
|
||||
_LOGGER.debug("Requests remaining: %d", self.accuweather.requests_remaining)
|
||||
return {**current, **{ATTR_FORECAST: forecast}}
|
||||
return {**current, ATTR_FORECAST: forecast}
|
||||
|
@ -56,7 +56,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
entry,
|
||||
data={
|
||||
**entry.data,
|
||||
**{CONF_DEVICES: serialize_device_list(devices)},
|
||||
CONF_DEVICES: serialize_device_list(devices),
|
||||
},
|
||||
)
|
||||
coordinators = [AnovaCoordinator(hass, device) for device in devices]
|
||||
|
@ -18,7 +18,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
if CONF_DEVICE not in entry.data:
|
||||
config_updates = {
|
||||
**entry.data,
|
||||
**{CONF_DEVICE: DEVICE_TYPE_GOGOGATE2},
|
||||
CONF_DEVICE: DEVICE_TYPE_GOGOGATE2,
|
||||
}
|
||||
|
||||
if config_updates:
|
||||
|
@ -596,14 +596,12 @@ UOM_TO_STATES = {
|
||||
4: "highly polluted",
|
||||
},
|
||||
UOM_BARRIER: { # Barrier Status
|
||||
**{
|
||||
0: STATE_CLOSED,
|
||||
100: STATE_OPEN,
|
||||
101: STATE_UNKNOWN,
|
||||
102: "stopped",
|
||||
103: STATE_CLOSING,
|
||||
104: STATE_OPENING,
|
||||
},
|
||||
0: STATE_CLOSED,
|
||||
100: STATE_OPEN,
|
||||
101: STATE_UNKNOWN,
|
||||
102: "stopped",
|
||||
103: STATE_CLOSING,
|
||||
104: STATE_OPENING,
|
||||
**{
|
||||
b: f"{b} %" for a, b in enumerate(list(range(1, 100)))
|
||||
}, # 1-99 are percentage open
|
||||
|
@ -206,8 +206,8 @@ class RiscoConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
title=info["title"],
|
||||
data={
|
||||
**user_input,
|
||||
**{CONF_TYPE: TYPE_LOCAL},
|
||||
**{CONF_COMMUNICATION_DELAY: info["comm_delay"]},
|
||||
CONF_TYPE: TYPE_LOCAL,
|
||||
CONF_COMMUNICATION_DELAY: info["comm_delay"],
|
||||
},
|
||||
)
|
||||
|
||||
|
@ -161,21 +161,19 @@ class StreamMuxer:
|
||||
mode="w",
|
||||
format=SEGMENT_CONTAINER_FORMAT,
|
||||
container_options={
|
||||
**{
|
||||
# Removed skip_sidx - see:
|
||||
# https://github.com/home-assistant/core/pull/39970
|
||||
# "cmaf" flag replaces several of the movflags used,
|
||||
# but too recent to use for now
|
||||
"movflags": "frag_custom+empty_moov+default_base_moof+frag_discont+negative_cts_offsets+skip_trailer+delay_moov",
|
||||
# Sometimes the first segment begins with negative timestamps,
|
||||
# and this setting just
|
||||
# adjusts the timestamps in the output from that segment to start
|
||||
# from 0. Helps from having to make some adjustments
|
||||
# in test_durations
|
||||
"avoid_negative_ts": "make_non_negative",
|
||||
"fragment_index": str(sequence + 1),
|
||||
"video_track_timescale": str(int(1 / input_vstream.time_base)),
|
||||
},
|
||||
# Removed skip_sidx - see:
|
||||
# https://github.com/home-assistant/core/pull/39970
|
||||
# "cmaf" flag replaces several of the movflags used,
|
||||
# but too recent to use for now
|
||||
"movflags": "frag_custom+empty_moov+default_base_moof+frag_discont+negative_cts_offsets+skip_trailer+delay_moov",
|
||||
# Sometimes the first segment begins with negative timestamps,
|
||||
# and this setting just
|
||||
# adjusts the timestamps in the output from that segment to start
|
||||
# from 0. Helps from having to make some adjustments
|
||||
# in test_durations
|
||||
"avoid_negative_ts": "make_non_negative",
|
||||
"fragment_index": str(sequence + 1),
|
||||
"video_track_timescale": str(int(1 / input_vstream.time_base)),
|
||||
# Only do extra fragmenting if we are using ll_hls
|
||||
# Let ffmpeg do the work using frag_duration
|
||||
# Fragment durations may exceed the 15% allowed variance but it seems ok
|
||||
|
@ -116,15 +116,15 @@ class VeraFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
{
|
||||
**user_input,
|
||||
**options_data(user_input),
|
||||
**{CONF_SOURCE: SOURCE_USER},
|
||||
**{CONF_LEGACY_UNIQUE_ID: False},
|
||||
CONF_SOURCE: SOURCE_USER,
|
||||
CONF_LEGACY_UNIQUE_ID: False,
|
||||
}
|
||||
)
|
||||
|
||||
return self.async_show_form(
|
||||
step_id="user",
|
||||
data_schema=vol.Schema(
|
||||
{**{vol.Required(CONF_CONTROLLER): str}, **options_schema()}
|
||||
{vol.Required(CONF_CONTROLLER): str, **options_schema()}
|
||||
),
|
||||
)
|
||||
|
||||
@ -148,8 +148,8 @@ class VeraFlowHandler(ConfigFlow, domain=DOMAIN):
|
||||
return await self.async_step_finish(
|
||||
{
|
||||
**config,
|
||||
**{CONF_SOURCE: SOURCE_IMPORT},
|
||||
**{CONF_LEGACY_UNIQUE_ID: use_legacy_unique_id},
|
||||
CONF_SOURCE: SOURCE_IMPORT,
|
||||
CONF_LEGACY_UNIQUE_ID: use_legacy_unique_id,
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -1098,7 +1098,7 @@ async def websocket_update_zha_configuration(
|
||||
"""Update the ZHA configuration."""
|
||||
zha_gateway = get_zha_gateway(hass)
|
||||
options = zha_gateway.config_entry.options
|
||||
data_to_save = {**options, **{CUSTOM_CONFIGURATION: msg["data"]}}
|
||||
data_to_save = {**options, CUSTOM_CONFIGURATION: msg["data"]}
|
||||
|
||||
for section, schema in ZHA_CONFIG_SCHEMAS.items():
|
||||
for entry in schema.schema:
|
||||
|
@ -605,6 +605,7 @@ select = [
|
||||
"N815", # Variable {name} in class scope should not be mixedCase
|
||||
"PERF", # Perflint
|
||||
"PGH004", # Use specific rule codes when using noqa
|
||||
"PIE800", # Unnecessary dictionary unpacking operators
|
||||
"PL", # pylint
|
||||
"PIE804", # Unnecessary dict kwargs
|
||||
"PIE790", # Unnecessary pass statement
|
||||
|
@ -116,7 +116,7 @@ async def async_setup_cast(hass, config=None):
|
||||
"""Set up the cast platform."""
|
||||
if config is None:
|
||||
config = {}
|
||||
data = {**{"ignore_cec": [], "known_hosts": [], "uuid": []}, **config}
|
||||
data = {"ignore_cec": [], "known_hosts": [], "uuid": [], **config}
|
||||
with patch(
|
||||
"homeassistant.helpers.entity_platform.EntityPlatform._async_schedule_add_entities_for_entry"
|
||||
) as add_entities:
|
||||
|
@ -425,7 +425,7 @@ async def test_cost_sensor_price_entity_total(
|
||||
hass.states.async_set(
|
||||
usage_sensor_entity_id,
|
||||
initial_energy,
|
||||
{**energy_attributes, **{"last_reset": last_reset}},
|
||||
{**energy_attributes, "last_reset": last_reset},
|
||||
)
|
||||
hass.states.async_set("sensor.energy_price", "1")
|
||||
|
||||
@ -444,7 +444,7 @@ async def test_cost_sensor_price_entity_total(
|
||||
hass.states.async_set(
|
||||
usage_sensor_entity_id,
|
||||
"0",
|
||||
{**energy_attributes, **{"last_reset": last_reset}},
|
||||
{**energy_attributes, "last_reset": last_reset},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
@ -466,7 +466,7 @@ async def test_cost_sensor_price_entity_total(
|
||||
hass.states.async_set(
|
||||
usage_sensor_entity_id,
|
||||
"10",
|
||||
{**energy_attributes, **{"last_reset": last_reset}},
|
||||
{**energy_attributes, "last_reset": last_reset},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get(cost_sensor_entity_id)
|
||||
@ -493,7 +493,7 @@ async def test_cost_sensor_price_entity_total(
|
||||
hass.states.async_set(
|
||||
usage_sensor_entity_id,
|
||||
"14.5",
|
||||
{**energy_attributes, **{"last_reset": last_reset}},
|
||||
{**energy_attributes, "last_reset": last_reset},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get(cost_sensor_entity_id)
|
||||
@ -511,7 +511,7 @@ async def test_cost_sensor_price_entity_total(
|
||||
hass.states.async_set(
|
||||
usage_sensor_entity_id,
|
||||
"14",
|
||||
{**energy_attributes, **{"last_reset": last_reset}},
|
||||
{**energy_attributes, "last_reset": last_reset},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get(cost_sensor_entity_id)
|
||||
@ -524,7 +524,7 @@ async def test_cost_sensor_price_entity_total(
|
||||
hass.states.async_set(
|
||||
usage_sensor_entity_id,
|
||||
"4",
|
||||
{**energy_attributes, **{"last_reset": last_reset}},
|
||||
{**energy_attributes, "last_reset": last_reset},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get(cost_sensor_entity_id)
|
||||
@ -537,7 +537,7 @@ async def test_cost_sensor_price_entity_total(
|
||||
hass.states.async_set(
|
||||
usage_sensor_entity_id,
|
||||
"10",
|
||||
{**energy_attributes, **{"last_reset": last_reset}},
|
||||
{**energy_attributes, "last_reset": last_reset},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
state = hass.states.get(cost_sensor_entity_id)
|
||||
|
@ -249,7 +249,8 @@ async def test_local_form(hass: HomeAssistant) -> None:
|
||||
|
||||
expected_data = {
|
||||
**TEST_LOCAL_DATA,
|
||||
**{"type": "local", CONF_COMMUNICATION_DELAY: 0},
|
||||
"type": "local",
|
||||
CONF_COMMUNICATION_DELAY: 0,
|
||||
}
|
||||
assert result3["type"] == FlowResultType.CREATE_ENTRY
|
||||
assert result3["title"] == TEST_SITE_NAME
|
||||
|
@ -140,7 +140,7 @@ async def test_failed_user_command(
|
||||
setup_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test that when a user sends an invalid command, we raise HomeAssistantError."""
|
||||
data = {ATTR_ENTITY_ID: ENTITY_ID, **{"command": "fake_command"}}
|
||||
data = {ATTR_ENTITY_ID: ENTITY_ID, "command": "fake_command"}
|
||||
with patch(
|
||||
"homeassistant.components.roborock.coordinator.RoborockLocalClient.send_command",
|
||||
side_effect=RoborockException(),
|
||||
|
@ -4140,14 +4140,14 @@ async def test_validate_unit_change_convertible(
|
||||
|
||||
# No statistics, unit in state matching device class - empty response
|
||||
hass.states.async_set(
|
||||
"sensor.test", 10, attributes={**attributes, **{"unit_of_measurement": unit}}
|
||||
"sensor.test", 10, attributes={**attributes, "unit_of_measurement": unit}
|
||||
)
|
||||
await async_recorder_block_till_done(hass)
|
||||
await assert_validation_result(client, {})
|
||||
|
||||
# No statistics, unit in state not matching device class - empty response
|
||||
hass.states.async_set(
|
||||
"sensor.test", 11, attributes={**attributes, **{"unit_of_measurement": "dogs"}}
|
||||
"sensor.test", 11, attributes={**attributes, "unit_of_measurement": "dogs"}
|
||||
)
|
||||
await async_recorder_block_till_done(hass)
|
||||
await assert_validation_result(client, {})
|
||||
@ -4156,7 +4156,7 @@ async def test_validate_unit_change_convertible(
|
||||
await async_recorder_block_till_done(hass)
|
||||
do_adhoc_statistics(hass, start=now)
|
||||
hass.states.async_set(
|
||||
"sensor.test", 12, attributes={**attributes, **{"unit_of_measurement": "dogs"}}
|
||||
"sensor.test", 12, attributes={**attributes, "unit_of_measurement": "dogs"}
|
||||
)
|
||||
await async_recorder_block_till_done(hass)
|
||||
expected = {
|
||||
@ -4176,7 +4176,7 @@ async def test_validate_unit_change_convertible(
|
||||
|
||||
# Valid state - empty response
|
||||
hass.states.async_set(
|
||||
"sensor.test", 13, attributes={**attributes, **{"unit_of_measurement": unit}}
|
||||
"sensor.test", 13, attributes={**attributes, "unit_of_measurement": unit}
|
||||
)
|
||||
await async_recorder_block_till_done(hass)
|
||||
await assert_validation_result(client, {})
|
||||
@ -4188,7 +4188,7 @@ async def test_validate_unit_change_convertible(
|
||||
|
||||
# Valid state in compatible unit - empty response
|
||||
hass.states.async_set(
|
||||
"sensor.test", 13, attributes={**attributes, **{"unit_of_measurement": unit2}}
|
||||
"sensor.test", 13, attributes={**attributes, "unit_of_measurement": unit2}
|
||||
)
|
||||
await async_recorder_block_till_done(hass)
|
||||
await assert_validation_result(client, {})
|
||||
@ -4263,7 +4263,7 @@ async def test_validate_statistics_unit_ignore_device_class(
|
||||
do_adhoc_statistics(hass, start=now)
|
||||
await async_recorder_block_till_done(hass)
|
||||
hass.states.async_set(
|
||||
"sensor.test", 12, attributes={**attributes, **{"unit_of_measurement": "dogs"}}
|
||||
"sensor.test", 12, attributes={**attributes, "unit_of_measurement": "dogs"}
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
await assert_validation_result(client, {})
|
||||
@ -4350,14 +4350,14 @@ async def test_validate_statistics_unit_change_no_device_class(
|
||||
|
||||
# No statistics, sensor state set - empty response
|
||||
hass.states.async_set(
|
||||
"sensor.test", 10, attributes={**attributes, **{"unit_of_measurement": unit}}
|
||||
"sensor.test", 10, attributes={**attributes, "unit_of_measurement": unit}
|
||||
)
|
||||
await async_recorder_block_till_done(hass)
|
||||
await assert_validation_result(client, {})
|
||||
|
||||
# No statistics, sensor state set to an incompatible unit - empty response
|
||||
hass.states.async_set(
|
||||
"sensor.test", 11, attributes={**attributes, **{"unit_of_measurement": "dogs"}}
|
||||
"sensor.test", 11, attributes={**attributes, "unit_of_measurement": "dogs"}
|
||||
)
|
||||
await async_recorder_block_till_done(hass)
|
||||
await assert_validation_result(client, {})
|
||||
@ -4366,7 +4366,7 @@ async def test_validate_statistics_unit_change_no_device_class(
|
||||
await async_recorder_block_till_done(hass)
|
||||
do_adhoc_statistics(hass, start=now)
|
||||
hass.states.async_set(
|
||||
"sensor.test", 12, attributes={**attributes, **{"unit_of_measurement": "dogs"}}
|
||||
"sensor.test", 12, attributes={**attributes, "unit_of_measurement": "dogs"}
|
||||
)
|
||||
await async_recorder_block_till_done(hass)
|
||||
expected = {
|
||||
@ -4386,7 +4386,7 @@ async def test_validate_statistics_unit_change_no_device_class(
|
||||
|
||||
# Valid state - empty response
|
||||
hass.states.async_set(
|
||||
"sensor.test", 13, attributes={**attributes, **{"unit_of_measurement": unit}}
|
||||
"sensor.test", 13, attributes={**attributes, "unit_of_measurement": unit}
|
||||
)
|
||||
await async_recorder_block_till_done(hass)
|
||||
await assert_validation_result(client, {})
|
||||
@ -4398,7 +4398,7 @@ async def test_validate_statistics_unit_change_no_device_class(
|
||||
|
||||
# Valid state in compatible unit - empty response
|
||||
hass.states.async_set(
|
||||
"sensor.test", 13, attributes={**attributes, **{"unit_of_measurement": unit2}}
|
||||
"sensor.test", 13, attributes={**attributes, "unit_of_measurement": unit2}
|
||||
)
|
||||
await async_recorder_block_till_done(hass)
|
||||
await assert_validation_result(client, {})
|
||||
@ -4739,13 +4739,13 @@ async def test_validate_statistics_unit_change_no_conversion(
|
||||
|
||||
# No statistics, original unit - empty response
|
||||
hass.states.async_set(
|
||||
"sensor.test", 10, attributes={**attributes, **{"unit_of_measurement": unit1}}
|
||||
"sensor.test", 10, attributes={**attributes, "unit_of_measurement": unit1}
|
||||
)
|
||||
await assert_validation_result(client, {})
|
||||
|
||||
# No statistics, changed unit - empty response
|
||||
hass.states.async_set(
|
||||
"sensor.test", 11, attributes={**attributes, **{"unit_of_measurement": unit2}}
|
||||
"sensor.test", 11, attributes={**attributes, "unit_of_measurement": unit2}
|
||||
)
|
||||
await assert_validation_result(client, {})
|
||||
|
||||
@ -4757,7 +4757,7 @@ async def test_validate_statistics_unit_change_no_conversion(
|
||||
|
||||
# No statistics, original unit - empty response
|
||||
hass.states.async_set(
|
||||
"sensor.test", 12, attributes={**attributes, **{"unit_of_measurement": unit1}}
|
||||
"sensor.test", 12, attributes={**attributes, "unit_of_measurement": unit1}
|
||||
)
|
||||
await assert_validation_result(client, {})
|
||||
|
||||
@ -4772,7 +4772,7 @@ async def test_validate_statistics_unit_change_no_conversion(
|
||||
|
||||
# Change unit - expect error
|
||||
hass.states.async_set(
|
||||
"sensor.test", 13, attributes={**attributes, **{"unit_of_measurement": unit2}}
|
||||
"sensor.test", 13, attributes={**attributes, "unit_of_measurement": unit2}
|
||||
)
|
||||
await async_recorder_block_till_done(hass)
|
||||
expected = {
|
||||
@ -4792,7 +4792,7 @@ async def test_validate_statistics_unit_change_no_conversion(
|
||||
|
||||
# Original unit - empty response
|
||||
hass.states.async_set(
|
||||
"sensor.test", 14, attributes={**attributes, **{"unit_of_measurement": unit1}}
|
||||
"sensor.test", 14, attributes={**attributes, "unit_of_measurement": unit1}
|
||||
)
|
||||
await async_recorder_block_till_done(hass)
|
||||
await assert_validation_result(client, {})
|
||||
@ -4874,7 +4874,7 @@ async def test_validate_statistics_unit_change_equivalent_units(
|
||||
|
||||
# No statistics, original unit - empty response
|
||||
hass.states.async_set(
|
||||
"sensor.test", 10, attributes={**attributes, **{"unit_of_measurement": unit1}}
|
||||
"sensor.test", 10, attributes={**attributes, "unit_of_measurement": unit1}
|
||||
)
|
||||
await assert_validation_result(client, {})
|
||||
|
||||
@ -4888,7 +4888,7 @@ async def test_validate_statistics_unit_change_equivalent_units(
|
||||
|
||||
# Units changed to an equivalent unit - empty response
|
||||
hass.states.async_set(
|
||||
"sensor.test", 12, attributes={**attributes, **{"unit_of_measurement": unit2}}
|
||||
"sensor.test", 12, attributes={**attributes, "unit_of_measurement": unit2}
|
||||
)
|
||||
await assert_validation_result(client, {})
|
||||
|
||||
@ -4960,7 +4960,7 @@ async def test_validate_statistics_unit_change_equivalent_units_2(
|
||||
|
||||
# No statistics, original unit - empty response
|
||||
hass.states.async_set(
|
||||
"sensor.test", 10, attributes={**attributes, **{"unit_of_measurement": unit1}}
|
||||
"sensor.test", 10, attributes={**attributes, "unit_of_measurement": unit1}
|
||||
)
|
||||
await assert_validation_result(client, {})
|
||||
|
||||
@ -4974,7 +4974,7 @@ async def test_validate_statistics_unit_change_equivalent_units_2(
|
||||
|
||||
# Units changed to an equivalent unit which is not known by the unit converters
|
||||
hass.states.async_set(
|
||||
"sensor.test", 12, attributes={**attributes, **{"unit_of_measurement": unit2}}
|
||||
"sensor.test", 12, attributes={**attributes, "unit_of_measurement": unit2}
|
||||
)
|
||||
expected = {
|
||||
"sensor.test": [
|
||||
|
@ -229,7 +229,7 @@ async def test_exclude_and_light_ids(
|
||||
controller_config=new_simple_controller_config(
|
||||
config_source=ConfigSource.CONFIG_ENTRY,
|
||||
devices=(vera_device1, vera_device2, vera_device3, vera_device4),
|
||||
config={**{CONF_CONTROLLER: "http://127.0.0.1:123"}, **options},
|
||||
config={CONF_CONTROLLER: "http://127.0.0.1:123", **options},
|
||||
),
|
||||
)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user