Enable Ruff B007 (#88356)

* Enable Ruff B007

* Adjust existing cases
This commit is contained in:
Franck Nijhof 2023-02-18 03:08:18 +01:00 committed by GitHub
parent 9fd35d53e7
commit 1e05697080
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 13 additions and 14 deletions

View File

@ -139,7 +139,7 @@ async def async_setup_legacy_entry(
]
structures_has_camera = {}
for structure, device in nest.cameras():
for structure, _ in nest.cameras():
structures_has_camera[structure] = True
for structure in structures_has_camera:
all_sensors += [

View File

@ -140,7 +140,7 @@ async def async_browse_media(
# Check if caller is requesting the root nodes
if media_content_type is None and media_content_id is None:
children = []
for config_entry_id, info in hass.data[DOMAIN].items():
for config_entry_id in hass.data[DOMAIN]:
config_entry = hass.config_entries.async_get_entry(config_entry_id)
assert config_entry is not None
children.append(

View File

@ -240,6 +240,7 @@ filterwarnings = ["error::sqlalchemy.exc.SAWarning"]
target-version = "py310"
select = [
"B007", # Loop control variable {name} not used within loop body
"C", # complexity
"D", # docstrings
"E", # pycodestyle

View File

@ -46,9 +46,7 @@ async def test_exclude_attributes(recorder_mock: Recorder, hass: HomeAssistant)
attr_ids[
db_state_attributes.attributes_id
] = db_state_attributes.to_native()
for db_state, db_state_attributes in session.query(
States, StateAttributes
).outerjoin(
for db_state, _ in session.query(States, StateAttributes).outerjoin(
StateAttributes, States.attributes_id == StateAttributes.attributes_id
):
state = db_state.to_native()

View File

@ -111,7 +111,7 @@ async def test_sensor_entity_migration(
}
# create entities with V1 schema in registry for Hue motion sensor
for dev_class, platform, new_id in sensor_mappings:
for dev_class, platform, _ in sensor_mappings:
ent_reg.async_get_or_create(
platform,
hue.DOMAIN,

View File

@ -888,7 +888,7 @@ async def test_integration_reload(
with mock.patch.object(hass_config, "YAML_CONFIG_FILE", yaml_path):
await hass.services.async_call(DOMAIN, SERVICE_RELOAD, blocking=True)
await hass.async_block_till_done()
for i in range(4):
for _ in range(4):
freezer.tick(timedelta(seconds=1))
async_fire_time_changed(hass)
await hass.async_block_till_done()

View File

@ -3278,7 +3278,7 @@ def test_compile_statistics_hourly_daily_monthly_summary(
# Generate 5-minute statistics for two hours
start = zero
for i in range(24):
for _ in range(24):
do_adhoc_statistics(hass, start=start)
wait_recording_done(hass)
start += timedelta(minutes=5)

View File

@ -87,7 +87,7 @@ async def test_lock_failing(hass: HomeAssistant, surepetcare) -> None:
surepetcare.lock_out.side_effect = SurePetcareError
surepetcare.lock.side_effect = SurePetcareError
for entity_id, unique_id in EXPECTED_ENTITY_IDS.items():
for entity_id in EXPECTED_ENTITY_IDS:
with pytest.raises(SurePetcareError):
await hass.services.async_call(
"lock", "lock", {"entity_id": entity_id}, blocking=True

View File

@ -89,7 +89,7 @@ async def test_diagnostics_for_device(
)
assert diagnostics_data
device_info: dict = zha_device.zha_device_info
for key, value in device_info.items():
for key in device_info:
assert key in diagnostics_data
if key not in KEYS_TO_REDACT:
assert key in diagnostics_data

View File

@ -226,7 +226,7 @@ async def test_old_entity_migration(
assert entity_entry.unique_id == old_unique_id
# Do this twice to make sure re-interview doesn't do anything weird
for i in range(0, 2):
for _ in range(2):
# Add a ready node, unique ID should be migrated
event = {"node": node}
driver.controller.emit("node added", event)
@ -274,7 +274,7 @@ async def test_different_endpoint_migration_status_sensor(
assert entity_entry.unique_id == old_unique_id
# Do this twice to make sure re-interview doesn't do anything weird
for i in range(0, 2):
for _ in range(0, 2):
# Add a ready node, unique ID should be migrated
event = {"node": node}
driver.controller.emit("node added", event)

View File

@ -437,7 +437,7 @@ async def test_async_remove_with_platform_update_finishes(hass: HomeAssistant) -
# Add, remove, add, remove and make sure no updates
# cause the entity to reappear after removal
for i in range(2):
for _ in range(2):
await component.async_add_entities([entity1])
assert len(hass.states.async_entity_ids()) == 1
entity1.async_write_ha_state()

View File

@ -724,7 +724,7 @@ def test_find_next_time_expression_tenth_second_pattern_does_not_drift_entering_
)
assert next_time == datetime(2021, 3, 15, 2, 30, 10, tzinfo=tz)
prev_target = next_time
for i in range(1000):
for _ in range(1000):
next_target = dt_util.find_next_time_expression_time(
prev_target.replace(microsecond=999999) + timedelta(seconds=1),
matching_seconds,