Add ruff rule PIE800 (#113619)

Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
Sid 2024-03-17 03:31:30 +01:00 committed by GitHub
parent 43652a4ace
commit 69564b1a17
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 63 additions and 65 deletions

View file

@ -135,4 +135,4 @@ class AccuWeatherDataUpdateCoordinator(DataUpdateCoordinator[dict[str, Any]]):
) as error: ) as error:
raise UpdateFailed(error) from error raise UpdateFailed(error) from error
_LOGGER.debug("Requests remaining: %d", self.accuweather.requests_remaining) _LOGGER.debug("Requests remaining: %d", self.accuweather.requests_remaining)
return {**current, **{ATTR_FORECAST: forecast}} return {**current, ATTR_FORECAST: forecast}

View file

@ -56,7 +56,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
entry, entry,
data={ data={
**entry.data, **entry.data,
**{CONF_DEVICES: serialize_device_list(devices)}, CONF_DEVICES: serialize_device_list(devices),
}, },
) )
coordinators = [AnovaCoordinator(hass, device) for device in devices] coordinators = [AnovaCoordinator(hass, device) for device in devices]

View file

@ -18,7 +18,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
if CONF_DEVICE not in entry.data: if CONF_DEVICE not in entry.data:
config_updates = { config_updates = {
**entry.data, **entry.data,
**{CONF_DEVICE: DEVICE_TYPE_GOGOGATE2}, CONF_DEVICE: DEVICE_TYPE_GOGOGATE2,
} }
if config_updates: if config_updates:

View file

@ -596,14 +596,12 @@ UOM_TO_STATES = {
4: "highly polluted", 4: "highly polluted",
}, },
UOM_BARRIER: { # Barrier Status UOM_BARRIER: { # Barrier Status
**{ 0: STATE_CLOSED,
0: STATE_CLOSED, 100: STATE_OPEN,
100: STATE_OPEN, 101: STATE_UNKNOWN,
101: STATE_UNKNOWN, 102: "stopped",
102: "stopped", 103: STATE_CLOSING,
103: STATE_CLOSING, 104: STATE_OPENING,
104: STATE_OPENING,
},
**{ **{
b: f"{b} %" for a, b in enumerate(list(range(1, 100))) b: f"{b} %" for a, b in enumerate(list(range(1, 100)))
}, # 1-99 are percentage open }, # 1-99 are percentage open

View file

@ -206,8 +206,8 @@ class RiscoConfigFlow(ConfigFlow, domain=DOMAIN):
title=info["title"], title=info["title"],
data={ data={
**user_input, **user_input,
**{CONF_TYPE: TYPE_LOCAL}, CONF_TYPE: TYPE_LOCAL,
**{CONF_COMMUNICATION_DELAY: info["comm_delay"]}, CONF_COMMUNICATION_DELAY: info["comm_delay"],
}, },
) )

View file

@ -161,21 +161,19 @@ class StreamMuxer:
mode="w", mode="w",
format=SEGMENT_CONTAINER_FORMAT, format=SEGMENT_CONTAINER_FORMAT,
container_options={ container_options={
**{ # Removed skip_sidx - see:
# Removed skip_sidx - see: # https://github.com/home-assistant/core/pull/39970
# https://github.com/home-assistant/core/pull/39970 # "cmaf" flag replaces several of the movflags used,
# "cmaf" flag replaces several of the movflags used, # but too recent to use for now
# but too recent to use for now "movflags": "frag_custom+empty_moov+default_base_moof+frag_discont+negative_cts_offsets+skip_trailer+delay_moov",
"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,
# Sometimes the first segment begins with negative timestamps, # and this setting just
# and this setting just # adjusts the timestamps in the output from that segment to start
# adjusts the timestamps in the output from that segment to start # from 0. Helps from having to make some adjustments
# from 0. Helps from having to make some adjustments # in test_durations
# in test_durations "avoid_negative_ts": "make_non_negative",
"avoid_negative_ts": "make_non_negative", "fragment_index": str(sequence + 1),
"fragment_index": str(sequence + 1), "video_track_timescale": str(int(1 / input_vstream.time_base)),
"video_track_timescale": str(int(1 / input_vstream.time_base)),
},
# Only do extra fragmenting if we are using ll_hls # Only do extra fragmenting if we are using ll_hls
# Let ffmpeg do the work using frag_duration # Let ffmpeg do the work using frag_duration
# Fragment durations may exceed the 15% allowed variance but it seems ok # Fragment durations may exceed the 15% allowed variance but it seems ok

View file

@ -116,15 +116,15 @@ class VeraFlowHandler(ConfigFlow, domain=DOMAIN):
{ {
**user_input, **user_input,
**options_data(user_input), **options_data(user_input),
**{CONF_SOURCE: SOURCE_USER}, CONF_SOURCE: SOURCE_USER,
**{CONF_LEGACY_UNIQUE_ID: False}, CONF_LEGACY_UNIQUE_ID: False,
} }
) )
return self.async_show_form( return self.async_show_form(
step_id="user", step_id="user",
data_schema=vol.Schema( 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( return await self.async_step_finish(
{ {
**config, **config,
**{CONF_SOURCE: SOURCE_IMPORT}, CONF_SOURCE: SOURCE_IMPORT,
**{CONF_LEGACY_UNIQUE_ID: use_legacy_unique_id}, CONF_LEGACY_UNIQUE_ID: use_legacy_unique_id,
} }
) )

View file

@ -1098,7 +1098,7 @@ async def websocket_update_zha_configuration(
"""Update the ZHA configuration.""" """Update the ZHA configuration."""
zha_gateway = get_zha_gateway(hass) zha_gateway = get_zha_gateway(hass)
options = zha_gateway.config_entry.options 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 section, schema in ZHA_CONFIG_SCHEMAS.items():
for entry in schema.schema: for entry in schema.schema:

View file

@ -605,6 +605,7 @@ select = [
"N815", # Variable {name} in class scope should not be mixedCase "N815", # Variable {name} in class scope should not be mixedCase
"PERF", # Perflint "PERF", # Perflint
"PGH004", # Use specific rule codes when using noqa "PGH004", # Use specific rule codes when using noqa
"PIE800", # Unnecessary dictionary unpacking operators
"PL", # pylint "PL", # pylint
"PIE804", # Unnecessary dict kwargs "PIE804", # Unnecessary dict kwargs
"PIE790", # Unnecessary pass statement "PIE790", # Unnecessary pass statement

View file

@ -116,7 +116,7 @@ async def async_setup_cast(hass, config=None):
"""Set up the cast platform.""" """Set up the cast platform."""
if config is None: if config is None:
config = {} config = {}
data = {**{"ignore_cec": [], "known_hosts": [], "uuid": []}, **config} data = {"ignore_cec": [], "known_hosts": [], "uuid": [], **config}
with patch( with patch(
"homeassistant.helpers.entity_platform.EntityPlatform._async_schedule_add_entities_for_entry" "homeassistant.helpers.entity_platform.EntityPlatform._async_schedule_add_entities_for_entry"
) as add_entities: ) as add_entities:

View file

@ -425,7 +425,7 @@ async def test_cost_sensor_price_entity_total(
hass.states.async_set( hass.states.async_set(
usage_sensor_entity_id, usage_sensor_entity_id,
initial_energy, initial_energy,
{**energy_attributes, **{"last_reset": last_reset}}, {**energy_attributes, "last_reset": last_reset},
) )
hass.states.async_set("sensor.energy_price", "1") hass.states.async_set("sensor.energy_price", "1")
@ -444,7 +444,7 @@ async def test_cost_sensor_price_entity_total(
hass.states.async_set( hass.states.async_set(
usage_sensor_entity_id, usage_sensor_entity_id,
"0", "0",
{**energy_attributes, **{"last_reset": last_reset}}, {**energy_attributes, "last_reset": last_reset},
) )
await hass.async_block_till_done() await hass.async_block_till_done()
@ -466,7 +466,7 @@ async def test_cost_sensor_price_entity_total(
hass.states.async_set( hass.states.async_set(
usage_sensor_entity_id, usage_sensor_entity_id,
"10", "10",
{**energy_attributes, **{"last_reset": last_reset}}, {**energy_attributes, "last_reset": last_reset},
) )
await hass.async_block_till_done() await hass.async_block_till_done()
state = hass.states.get(cost_sensor_entity_id) state = hass.states.get(cost_sensor_entity_id)
@ -493,7 +493,7 @@ async def test_cost_sensor_price_entity_total(
hass.states.async_set( hass.states.async_set(
usage_sensor_entity_id, usage_sensor_entity_id,
"14.5", "14.5",
{**energy_attributes, **{"last_reset": last_reset}}, {**energy_attributes, "last_reset": last_reset},
) )
await hass.async_block_till_done() await hass.async_block_till_done()
state = hass.states.get(cost_sensor_entity_id) state = hass.states.get(cost_sensor_entity_id)
@ -511,7 +511,7 @@ async def test_cost_sensor_price_entity_total(
hass.states.async_set( hass.states.async_set(
usage_sensor_entity_id, usage_sensor_entity_id,
"14", "14",
{**energy_attributes, **{"last_reset": last_reset}}, {**energy_attributes, "last_reset": last_reset},
) )
await hass.async_block_till_done() await hass.async_block_till_done()
state = hass.states.get(cost_sensor_entity_id) state = hass.states.get(cost_sensor_entity_id)
@ -524,7 +524,7 @@ async def test_cost_sensor_price_entity_total(
hass.states.async_set( hass.states.async_set(
usage_sensor_entity_id, usage_sensor_entity_id,
"4", "4",
{**energy_attributes, **{"last_reset": last_reset}}, {**energy_attributes, "last_reset": last_reset},
) )
await hass.async_block_till_done() await hass.async_block_till_done()
state = hass.states.get(cost_sensor_entity_id) state = hass.states.get(cost_sensor_entity_id)
@ -537,7 +537,7 @@ async def test_cost_sensor_price_entity_total(
hass.states.async_set( hass.states.async_set(
usage_sensor_entity_id, usage_sensor_entity_id,
"10", "10",
{**energy_attributes, **{"last_reset": last_reset}}, {**energy_attributes, "last_reset": last_reset},
) )
await hass.async_block_till_done() await hass.async_block_till_done()
state = hass.states.get(cost_sensor_entity_id) state = hass.states.get(cost_sensor_entity_id)

View file

@ -249,7 +249,8 @@ async def test_local_form(hass: HomeAssistant) -> None:
expected_data = { expected_data = {
**TEST_LOCAL_DATA, **TEST_LOCAL_DATA,
**{"type": "local", CONF_COMMUNICATION_DELAY: 0}, "type": "local",
CONF_COMMUNICATION_DELAY: 0,
} }
assert result3["type"] == FlowResultType.CREATE_ENTRY assert result3["type"] == FlowResultType.CREATE_ENTRY
assert result3["title"] == TEST_SITE_NAME assert result3["title"] == TEST_SITE_NAME

View file

@ -140,7 +140,7 @@ async def test_failed_user_command(
setup_entry: MockConfigEntry, setup_entry: MockConfigEntry,
) -> None: ) -> None:
"""Test that when a user sends an invalid command, we raise HomeAssistantError.""" """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( with patch(
"homeassistant.components.roborock.coordinator.RoborockLocalClient.send_command", "homeassistant.components.roborock.coordinator.RoborockLocalClient.send_command",
side_effect=RoborockException(), side_effect=RoborockException(),

View file

@ -4140,14 +4140,14 @@ async def test_validate_unit_change_convertible(
# No statistics, unit in state matching device class - empty response # No statistics, unit in state matching device class - empty response
hass.states.async_set( 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 async_recorder_block_till_done(hass)
await assert_validation_result(client, {}) await assert_validation_result(client, {})
# No statistics, unit in state not matching device class - empty response # No statistics, unit in state not matching device class - empty response
hass.states.async_set( 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 async_recorder_block_till_done(hass)
await assert_validation_result(client, {}) await assert_validation_result(client, {})
@ -4156,7 +4156,7 @@ async def test_validate_unit_change_convertible(
await async_recorder_block_till_done(hass) await async_recorder_block_till_done(hass)
do_adhoc_statistics(hass, start=now) do_adhoc_statistics(hass, start=now)
hass.states.async_set( 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) await async_recorder_block_till_done(hass)
expected = { expected = {
@ -4176,7 +4176,7 @@ async def test_validate_unit_change_convertible(
# Valid state - empty response # Valid state - empty response
hass.states.async_set( 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 async_recorder_block_till_done(hass)
await assert_validation_result(client, {}) await assert_validation_result(client, {})
@ -4188,7 +4188,7 @@ async def test_validate_unit_change_convertible(
# Valid state in compatible unit - empty response # Valid state in compatible unit - empty response
hass.states.async_set( 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 async_recorder_block_till_done(hass)
await assert_validation_result(client, {}) await assert_validation_result(client, {})
@ -4263,7 +4263,7 @@ async def test_validate_statistics_unit_ignore_device_class(
do_adhoc_statistics(hass, start=now) do_adhoc_statistics(hass, start=now)
await async_recorder_block_till_done(hass) await async_recorder_block_till_done(hass)
hass.states.async_set( 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 hass.async_block_till_done()
await assert_validation_result(client, {}) 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 # No statistics, sensor state set - empty response
hass.states.async_set( 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 async_recorder_block_till_done(hass)
await assert_validation_result(client, {}) await assert_validation_result(client, {})
# No statistics, sensor state set to an incompatible unit - empty response # No statistics, sensor state set to an incompatible unit - empty response
hass.states.async_set( 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 async_recorder_block_till_done(hass)
await assert_validation_result(client, {}) 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) await async_recorder_block_till_done(hass)
do_adhoc_statistics(hass, start=now) do_adhoc_statistics(hass, start=now)
hass.states.async_set( 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) await async_recorder_block_till_done(hass)
expected = { expected = {
@ -4386,7 +4386,7 @@ async def test_validate_statistics_unit_change_no_device_class(
# Valid state - empty response # Valid state - empty response
hass.states.async_set( 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 async_recorder_block_till_done(hass)
await assert_validation_result(client, {}) 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 # Valid state in compatible unit - empty response
hass.states.async_set( 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 async_recorder_block_till_done(hass)
await assert_validation_result(client, {}) await assert_validation_result(client, {})
@ -4739,13 +4739,13 @@ async def test_validate_statistics_unit_change_no_conversion(
# No statistics, original unit - empty response # No statistics, original unit - empty response
hass.states.async_set( 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, {}) await assert_validation_result(client, {})
# No statistics, changed unit - empty response # No statistics, changed unit - empty response
hass.states.async_set( 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, {}) await assert_validation_result(client, {})
@ -4757,7 +4757,7 @@ async def test_validate_statistics_unit_change_no_conversion(
# No statistics, original unit - empty response # No statistics, original unit - empty response
hass.states.async_set( 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, {}) await assert_validation_result(client, {})
@ -4772,7 +4772,7 @@ async def test_validate_statistics_unit_change_no_conversion(
# Change unit - expect error # Change unit - expect error
hass.states.async_set( 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 async_recorder_block_till_done(hass)
expected = { expected = {
@ -4792,7 +4792,7 @@ async def test_validate_statistics_unit_change_no_conversion(
# Original unit - empty response # Original unit - empty response
hass.states.async_set( 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 async_recorder_block_till_done(hass)
await assert_validation_result(client, {}) await assert_validation_result(client, {})
@ -4874,7 +4874,7 @@ async def test_validate_statistics_unit_change_equivalent_units(
# No statistics, original unit - empty response # No statistics, original unit - empty response
hass.states.async_set( 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, {}) 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 # Units changed to an equivalent unit - empty response
hass.states.async_set( 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, {}) 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 # No statistics, original unit - empty response
hass.states.async_set( 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, {}) 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 # Units changed to an equivalent unit which is not known by the unit converters
hass.states.async_set( hass.states.async_set(
"sensor.test", 12, attributes={**attributes, **{"unit_of_measurement": unit2}} "sensor.test", 12, attributes={**attributes, "unit_of_measurement": unit2}
) )
expected = { expected = {
"sensor.test": [ "sensor.test": [

View file

@ -229,7 +229,7 @@ async def test_exclude_and_light_ids(
controller_config=new_simple_controller_config( controller_config=new_simple_controller_config(
config_source=ConfigSource.CONFIG_ENTRY, config_source=ConfigSource.CONFIG_ENTRY,
devices=(vera_device1, vera_device2, vera_device3, vera_device4), 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},
), ),
) )