diff --git a/homeassistant/components/accuweather/__init__.py b/homeassistant/components/accuweather/__init__.py index 25cff4ed4fc..26e0c1331be 100644 --- a/homeassistant/components/accuweather/__init__.py +++ b/homeassistant/components/accuweather/__init__.py @@ -52,7 +52,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: # Remove ozone sensors from registry if they exist ent_reg = er.async_get(hass) - for day in range(0, 5): + for day in range(5): unique_id = f"{coordinator.location_key}-ozone-{day}" if entity_id := ent_reg.async_get_entity_id(SENSOR_PLATFORM, DOMAIN, unique_id): _LOGGER.debug("Removing ozone sensor entity %s", entity_id) diff --git a/homeassistant/components/ddwrt/device_tracker.py b/homeassistant/components/ddwrt/device_tracker.py index 39a7d1ebc0c..21786a292f4 100644 --- a/homeassistant/components/ddwrt/device_tracker.py +++ b/homeassistant/components/ddwrt/device_tracker.py @@ -98,7 +98,7 @@ class DdWrtDeviceScanner(DeviceScanner): elements = cleaned_str.split(",") num_clients = int(len(elements) / 5) self.mac2name = {} - for idx in range(0, num_clients): + for idx in range(num_clients): # The data is a single array # every 5 elements represents one host, the MAC # is the third element and the name is the first. diff --git a/homeassistant/components/demo/mailbox.py b/homeassistant/components/demo/mailbox.py index ca9cbf0bd85..3ec80e47118 100644 --- a/homeassistant/components/demo/mailbox.py +++ b/homeassistant/components/demo/mailbox.py @@ -34,7 +34,7 @@ class DemoMailbox(Mailbox): super().__init__(hass, name) self._messages: dict[str, dict[str, Any]] = {} txt = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. " - for idx in range(0, 10): + for idx in range(10): msgtime = int( dt_util.as_timestamp(dt_util.utcnow()) - 3600 * 24 * (10 - idx) ) diff --git a/homeassistant/components/ecobee/climate.py b/homeassistant/components/ecobee/climate.py index ae076d42e1d..cfb73153f45 100644 --- a/homeassistant/components/ecobee/climate.py +++ b/homeassistant/components/ecobee/climate.py @@ -709,7 +709,7 @@ class Thermostat(ClimateEntity): def set_humidity(self, humidity: int) -> None: """Set the humidity level.""" - if humidity not in range(0, 101): + if humidity not in range(101): raise ValueError( f"Invalid set_humidity value (must be in range 0-100): {humidity}" ) diff --git a/homeassistant/components/ecobee/weather.py b/homeassistant/components/ecobee/weather.py index 53b6b0bb345..743ee12ddc7 100644 --- a/homeassistant/components/ecobee/weather.py +++ b/homeassistant/components/ecobee/weather.py @@ -172,7 +172,7 @@ class EcobeeWeather(WeatherEntity): forecasts: list[Forecast] = [] date = dt_util.utcnow() - for day in range(0, 5): + for day in range(5): forecast = _process_forecast(self.weather["forecasts"][day]) if forecast is None: continue diff --git a/homeassistant/components/enphase_envoy/sensor.py b/homeassistant/components/enphase_envoy/sensor.py index 842c50c6d9d..1b64b3a9b9f 100644 --- a/homeassistant/components/enphase_envoy/sensor.py +++ b/homeassistant/components/enphase_envoy/sensor.py @@ -151,7 +151,7 @@ PRODUCTION_PHASE_SENSORS = { ) for sensor in list(PRODUCTION_SENSORS) ] - for phase in range(0, 3) + for phase in range(3) } @@ -221,7 +221,7 @@ CONSUMPTION_PHASE_SENSORS = { ) for sensor in list(CONSUMPTION_SENSORS) ] - for phase in range(0, 3) + for phase in range(3) } @@ -326,7 +326,7 @@ CT_NET_CONSUMPTION_PHASE_SENSORS = { ) for sensor in list(CT_NET_CONSUMPTION_SENSORS) ] - for phase in range(0, 3) + for phase in range(3) } CT_PRODUCTION_SENSORS = ( @@ -361,7 +361,7 @@ CT_PRODUCTION_PHASE_SENSORS = { ) for sensor in list(CT_PRODUCTION_SENSORS) ] - for phase in range(0, 3) + for phase in range(3) } diff --git a/homeassistant/components/hdmi_cec/__init__.py b/homeassistant/components/hdmi_cec/__init__.py index 7902fa1c33c..43a649ba01a 100644 --- a/homeassistant/components/hdmi_cec/__init__.py +++ b/homeassistant/components/hdmi_cec/__init__.py @@ -253,7 +253,7 @@ def setup(hass: HomeAssistant, base_config: ConfigType) -> bool: # noqa: C901 hdmi_network.send_command(KeyReleaseCommand(dst=ADDR_AUDIOSYSTEM)) else: att = 1 if att == "" else int(att) - for _ in range(0, att): + for _ in range(att): hdmi_network.send_command(KeyPressCommand(cmd, dst=ADDR_AUDIOSYSTEM)) hdmi_network.send_command(KeyReleaseCommand(dst=ADDR_AUDIOSYSTEM)) diff --git a/homeassistant/components/homekit/__init__.py b/homeassistant/components/homekit/__init__.py index ebbb1b9420d..8fc96cff954 100644 --- a/homeassistant/components/homekit/__init__.py +++ b/homeassistant/components/homekit/__init__.py @@ -384,7 +384,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: await homekit.async_stop() logged_shutdown_wait = False - for _ in range(0, SHUTDOWN_TIMEOUT): + for _ in range(SHUTDOWN_TIMEOUT): if async_port_is_available(entry.data[CONF_PORT]): break diff --git a/homeassistant/components/iammeter/sensor.py b/homeassistant/components/iammeter/sensor.py index 2a5d3ed7a81..a3922b06980 100644 --- a/homeassistant/components/iammeter/sensor.py +++ b/homeassistant/components/iammeter/sensor.py @@ -75,8 +75,8 @@ def _migrate_to_new_unique_id( phase_list = ["A", "B", "C", "NET"] id_phase_range = 1 if model == DEVICE_3080 else 4 id_name_range = 5 if model == DEVICE_3080 else 7 - for row in range(0, id_phase_range): - for idx in range(0, id_name_range): + for row in range(id_phase_range): + for idx in range(id_name_range): old_unique_id = f"{serial_number}-{row}-{idx}" new_unique_id = ( f"{serial_number}_{name_list[idx]}" diff --git a/homeassistant/components/insteon/schemas.py b/homeassistant/components/insteon/schemas.py index 7ac627f7be0..e277281c240 100644 --- a/homeassistant/components/insteon/schemas.py +++ b/homeassistant/components/insteon/schemas.py @@ -79,7 +79,7 @@ ADD_DEFAULT_LINKS_SCHEMA = vol.Schema({vol.Required(CONF_ENTITY_ID): cv.entity_i def normalize_byte_entry_to_int(entry: int | bytes | str): """Format a hex entry value.""" if isinstance(entry, int): - if entry in range(0, 256): + if entry in range(256): return entry raise ValueError("Must be single byte") if isinstance(entry, str): diff --git a/homeassistant/components/ld2410_ble/sensor.py b/homeassistant/components/ld2410_ble/sensor.py index d3a2a6e599c..6daa1397161 100644 --- a/homeassistant/components/ld2410_ble/sensor.py +++ b/homeassistant/components/ld2410_ble/sensor.py @@ -92,7 +92,7 @@ MOTION_ENERGY_GATES = [ entity_registry_enabled_default=False, native_unit_of_measurement="Target Energy", ) - for i in range(0, 9) + for i in range(9) ] STATIC_ENERGY_GATES = [ @@ -103,7 +103,7 @@ STATIC_ENERGY_GATES = [ entity_registry_enabled_default=False, native_unit_of_measurement="Target Energy", ) - for i in range(0, 9) + for i in range(9) ] SENSOR_DESCRIPTIONS = [ diff --git a/homeassistant/components/lifx/light.py b/homeassistant/components/lifx/light.py index d1ee5c836eb..90632f82d9e 100644 --- a/homeassistant/components/lifx/light.py +++ b/homeassistant/components/lifx/light.py @@ -418,7 +418,7 @@ class LIFXMultiZone(LIFXColor): await super().set_color(hsbk, kwargs, duration) return - zones = list(range(0, num_zones)) + zones = list(range(num_zones)) else: zones = [x for x in set(zones) if x < num_zones] diff --git a/homeassistant/components/modbus/base_platform.py b/homeassistant/components/modbus/base_platform.py index 6d547e5ea38..c64ef95c163 100644 --- a/homeassistant/components/modbus/base_platform.py +++ b/homeassistant/components/modbus/base_platform.py @@ -185,7 +185,7 @@ class BaseStructPlatform(BasePlatform, RestoreEntity): """Do swap as needed.""" if slave_count: swapped = [] - for i in range(0, self._slave_count + 1): + for i in range(self._slave_count + 1): inx = i * self._slave_size inx2 = inx + self._slave_size swapped.extend(self._swap_registers(registers[inx:inx2], 0)) diff --git a/homeassistant/components/modbus/binary_sensor.py b/homeassistant/components/modbus/binary_sensor.py index 23192244332..314877b7927 100644 --- a/homeassistant/components/modbus/binary_sensor.py +++ b/homeassistant/components/modbus/binary_sensor.py @@ -94,7 +94,7 @@ class ModbusBinarySensor(BasePlatform, RestoreEntity, BinarySensorEntity): ) return [ - SlaveSensor(self._coordinator, idx, entry) for idx in range(0, slave_count) + SlaveSensor(self._coordinator, idx, entry) for idx in range(slave_count) ] async def async_added_to_hass(self) -> None: diff --git a/homeassistant/components/modbus/sensor.py b/homeassistant/components/modbus/sensor.py index f74c4bf4e1b..6c6e1ef1830 100644 --- a/homeassistant/components/modbus/sensor.py +++ b/homeassistant/components/modbus/sensor.py @@ -95,7 +95,7 @@ class ModbusRegisterSensor(BaseStructPlatform, RestoreSensor, SensorEntity): ) return [ - SlaveSensor(self._coordinator, idx, entry) for idx in range(0, slave_count) + SlaveSensor(self._coordinator, idx, entry) for idx in range(slave_count) ] async def async_added_to_hass(self) -> None: diff --git a/homeassistant/components/nina/binary_sensor.py b/homeassistant/components/nina/binary_sensor.py index 8104a52683c..397ced0f5d3 100644 --- a/homeassistant/components/nina/binary_sensor.py +++ b/homeassistant/components/nina/binary_sensor.py @@ -47,7 +47,7 @@ async def async_setup_entry( async_add_entities( NINAMessage(coordinator, ent, regions[ent], i + 1, config_entry) for ent in coordinator.data - for i in range(0, message_slots) + for i in range(message_slots) ) diff --git a/homeassistant/components/nina/config_flow.py b/homeassistant/components/nina/config_flow.py index 8b5bcb72252..07c3f6fe9a1 100644 --- a/homeassistant/components/nina/config_flow.py +++ b/homeassistant/components/nina/config_flow.py @@ -225,7 +225,7 @@ class OptionsFlowHandler(OptionsFlow): removed_entities_slots = [ f"{region}-{slot_id}" for region in self.data[CONF_REGIONS] - for slot_id in range(0, self.data[CONF_MESSAGE_SLOTS] + 1) + for slot_id in range(self.data[CONF_MESSAGE_SLOTS] + 1) if slot_id > user_input[CONF_MESSAGE_SLOTS] ] diff --git a/homeassistant/components/openhardwaremonitor/sensor.py b/homeassistant/components/openhardwaremonitor/sensor.py index a68b9b11678..4e15ca3dd57 100644 --- a/homeassistant/components/openhardwaremonitor/sensor.py +++ b/homeassistant/components/openhardwaremonitor/sensor.py @@ -170,7 +170,7 @@ class OpenHardwareMonitorData: result = devices.copy() if json[OHM_CHILDREN]: - for child_index in range(0, len(json[OHM_CHILDREN])): + for child_index in range(len(json[OHM_CHILDREN])): child_path = path.copy() child_path.append(child_index) diff --git a/homeassistant/components/recorder/util.py b/homeassistant/components/recorder/util.py index 0b9ec0cf68c..e92e287d11a 100644 --- a/homeassistant/components/recorder/util.py +++ b/homeassistant/components/recorder/util.py @@ -160,7 +160,7 @@ def execute( This method also retries a few times in the case of stale connections. """ debug = _LOGGER.isEnabledFor(logging.DEBUG) - for tryno in range(0, RETRIES): + for tryno in range(RETRIES): try: if debug: timer_start = time.perf_counter() diff --git a/homeassistant/components/roomba/irobot_base.py b/homeassistant/components/roomba/irobot_base.py index 73ef5a813b1..4850dc0b7e9 100644 --- a/homeassistant/components/roomba/irobot_base.py +++ b/homeassistant/components/roomba/irobot_base.py @@ -251,7 +251,7 @@ class IRobotVacuum(IRobotEntity, StateVacuumEntity): """Set the vacuum cleaner to return to the dock.""" if self.state == STATE_CLEANING: await self.async_pause() - for _ in range(0, 10): + for _ in range(10): if self.state == STATE_PAUSED: break await asyncio.sleep(1) diff --git a/homeassistant/components/stream/fmp4utils.py b/homeassistant/components/stream/fmp4utils.py index 4175b91fd11..e611e07cd71 100644 --- a/homeassistant/components/stream/fmp4utils.py +++ b/homeassistant/components/stream/fmp4utils.py @@ -92,7 +92,7 @@ def get_codec_string(mp4_bytes: bytes) -> str: stsd_box[112:116], byteorder="big" ) reverse = 0 - for i in range(0, 32): + for i in range(32): reverse |= general_profile_compatibility & 1 if i == 31: break diff --git a/homeassistant/components/syncthru/sensor.py b/homeassistant/components/syncthru/sensor.py index 412fd128577..df2ffd99803 100644 --- a/homeassistant/components/syncthru/sensor.py +++ b/homeassistant/components/syncthru/sensor.py @@ -22,7 +22,7 @@ COLORS = ["black", "cyan", "magenta", "yellow"] DRUM_COLORS = COLORS TONER_COLORS = COLORS TRAYS = range(1, 6) -OUTPUT_TRAYS = range(0, 6) +OUTPUT_TRAYS = range(6) DEFAULT_MONITORED_CONDITIONS = [] DEFAULT_MONITORED_CONDITIONS.extend([f"toner_{key}" for key in TONER_COLORS]) DEFAULT_MONITORED_CONDITIONS.extend([f"drum_{key}" for key in DRUM_COLORS]) diff --git a/homeassistant/components/touchline/climate.py b/homeassistant/components/touchline/climate.py index 83c7839772a..5b1c52534c5 100644 --- a/homeassistant/components/touchline/climate.py +++ b/homeassistant/components/touchline/climate.py @@ -56,10 +56,7 @@ def setup_platform( py_touchline = PyTouchline() number_of_devices = int(py_touchline.get_number_of_devices(host)) add_entities( - ( - Touchline(PyTouchline(device_id)) - for device_id in range(0, number_of_devices) - ), + (Touchline(PyTouchline(device_id)) for device_id in range(number_of_devices)), True, ) diff --git a/homeassistant/components/zwave_js/entity.py b/homeassistant/components/zwave_js/entity.py index 0f594161bb9..4a6f87cc032 100644 --- a/homeassistant/components/zwave_js/entity.py +++ b/homeassistant/components/zwave_js/entity.py @@ -203,7 +203,7 @@ class ZWaveBaseEntity(Entity): property_key=primary_value.property_key, ) in self.info.node.values - for endpoint_idx in range(0, primary_value.endpoint) + for endpoint_idx in range(primary_value.endpoint) ): name += f" ({primary_value.endpoint})" diff --git a/pyproject.toml b/pyproject.toml index c743e3507ba..0bd8e592d86 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -605,13 +605,8 @@ 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 + "PIE", # flake8-pie "PL", # pylint - "PIE804", # Unnecessary dict kwargs - "PIE790", # Unnecessary pass statement - "PIE794", # Class field is defined multiple times - "PIE807", # Prefer list/dict over useless lambda - "PIE810", # Call startswith/endswith once with a tuple "RUF005", # Consider iterable unpacking instead of concatenation "RUF006", # Store a reference to the return value of asyncio.create_task # "RUF100", # Unused `noqa` directive; temporarily every now and then to clean them up diff --git a/tests/components/greeneye_monitor/common.py b/tests/components/greeneye_monitor/common.py index 40562096b53..e4eeca47e60 100644 --- a/tests/components/greeneye_monitor/common.py +++ b/tests/components/greeneye_monitor/common.py @@ -236,9 +236,9 @@ def mock_monitor(serial_number: int) -> MagicMock: monitor = mock_with_listeners() monitor.serial_number = serial_number monitor.voltage_sensor = mock_voltage_sensor() - monitor.pulse_counters = [mock_pulse_counter() for i in range(0, 4)] - monitor.temperature_sensors = [mock_temperature_sensor() for i in range(0, 8)] - monitor.channels = [mock_channel() for i in range(0, 32)] + monitor.pulse_counters = [mock_pulse_counter() for i in range(4)] + monitor.temperature_sensors = [mock_temperature_sensor() for i in range(8)] + monitor.channels = [mock_channel() for i in range(32)] return monitor diff --git a/tests/components/homekit/test_aidmanager.py b/tests/components/homekit/test_aidmanager.py index 9cd618e307c..6dbac422f07 100644 --- a/tests/components/homekit/test_aidmanager.py +++ b/tests/components/homekit/test_aidmanager.py @@ -49,7 +49,7 @@ async def test_aid_generation( aid_storage = AccessoryAidStorage(hass, config_entry) await aid_storage.async_initialize() - for _ in range(0, 2): + for _ in range(2): assert ( aid_storage.get_or_allocate_aid_for_entity_id(light_ent.entity_id) == 1953095294 @@ -72,7 +72,7 @@ async def test_aid_generation( aid_storage.delete_aid(get_system_unique_id(remote_ent, remote_ent.unique_id)) aid_storage.delete_aid("non-existent-one") - for _ in range(0, 2): + for _ in range(2): assert ( aid_storage.get_or_allocate_aid_for_entity_id(light_ent.entity_id) == 1953095294 @@ -112,7 +112,7 @@ async def test_no_aid_collision( seen_aids = set() - for unique_id in range(0, 202): + for unique_id in range(202): ent = entity_registry.async_get_or_create( "light", "device", unique_id, device_id=device_entry.id ) @@ -141,7 +141,7 @@ async def test_aid_generation_no_unique_ids_handles_collision( seen_aids = set() collisions = [] - for light_id in range(0, 220): + for light_id in range(220): entity_id = f"light.light{light_id}" hass.states.async_set(entity_id, "on") expected_aid = fnv1a_32(entity_id.encode("utf-8")) diff --git a/tests/components/hue/test_light_v2.py b/tests/components/hue/test_light_v2.py index b55da314bac..d8d0f4b6e66 100644 --- a/tests/components/hue/test_light_v2.py +++ b/tests/components/hue/test_light_v2.py @@ -550,7 +550,7 @@ async def test_grouped_lights( # PUT request should have been sent to ALL group lights with correct params assert len(mock_bridge_v2.mock_requests) == 3 - for index in range(0, 3): + for index in range(3): assert ( mock_bridge_v2.mock_requests[index]["json"]["identify"]["action"] == "identify" @@ -588,7 +588,7 @@ async def test_grouped_lights( # PUT request should have been sent to ALL group lights with correct params assert len(mock_bridge_v2.mock_requests) == 3 - for index in range(0, 3): + for index in range(3): assert ( mock_bridge_v2.mock_requests[index]["json"]["identify"]["action"] == "identify" diff --git a/tests/components/local_todo/test_todo.py b/tests/components/local_todo/test_todo.py index 760b0260dbb..3074cdcf88f 100644 --- a/tests/components/local_todo/test_todo.py +++ b/tests/components/local_todo/test_todo.py @@ -185,7 +185,7 @@ async def test_bulk_remove( ws_get_items: Callable[[], Awaitable[dict[str, str]]], ) -> None: """Test removing multiple todo items.""" - for i in range(0, 5): + for i in range(5): await hass.services.async_call( TODO_DOMAIN, "add_item", diff --git a/tests/components/mailbox/test_init.py b/tests/components/mailbox/test_init.py index 1af7f2e06b9..8b83f2b0ec7 100644 --- a/tests/components/mailbox/test_init.py +++ b/tests/components/mailbox/test_init.py @@ -49,7 +49,7 @@ class TestMailbox(mailbox.Mailbox): """Initialize Test mailbox.""" super().__init__(hass, name) self._messages: dict[str, dict[str, Any]] = {} - for idx in range(0, 10): + for idx in range(10): msg = _create_message(idx) msgsha = msg["sha"] self._messages[msgsha] = msg diff --git a/tests/components/modbus/test_sensor.py b/tests/components/modbus/test_sensor.py index 1c6b332d391..23347cc56bb 100644 --- a/tests/components/modbus/test_sensor.py +++ b/tests/components/modbus/test_sensor.py @@ -910,7 +910,7 @@ async def test_virtual_sensor( hass: HomeAssistant, entity_registry: er.EntityRegistry, mock_do_cycle, expected ) -> None: """Run test for sensor.""" - for i in range(0, len(expected)): + for i in range(len(expected)): entity_id = f"{SENSOR_DOMAIN}.{TEST_ENTITY_NAME}".replace(" ", "_") unique_id = f"{SLAVE_UNIQUE_ID}" if i: @@ -1080,7 +1080,7 @@ async def test_virtual_swap_sensor( hass: HomeAssistant, mock_do_cycle, expected ) -> None: """Run test for sensor.""" - for i in range(0, len(expected)): + for i in range(len(expected)): entity_id = f"{SENSOR_DOMAIN}.{TEST_ENTITY_NAME}".replace(" ", "_") if i: entity_id = f"{entity_id}_{i}" diff --git a/tests/components/mqtt/test_common.py b/tests/components/mqtt/test_common.py index 8c023848fc4..6d9f56c531e 100644 --- a/tests/components/mqtt/test_common.py +++ b/tests/components/mqtt/test_common.py @@ -1327,7 +1327,7 @@ async def help_test_entity_debug_info_max_messages( start_dt = datetime(2019, 1, 1, 0, 0, 0, tzinfo=dt_util.UTC) with freeze_time(start_dt): - for i in range(0, debug_info.STORED_MESSAGES + 1): + for i in range(debug_info.STORED_MESSAGES + 1): async_fire_mqtt_message(hass, "test-topic", f"{i}") debug_info_data = debug_info.info_for_device(hass, device.id) diff --git a/tests/components/mqtt/test_init.py b/tests/components/mqtt/test_init.py index 0f3069ef1a1..0c3764ce8a8 100644 --- a/tests/components/mqtt/test_init.py +++ b/tests/components/mqtt/test_init.py @@ -4130,7 +4130,7 @@ async def test_multi_platform_discovery( }, } for platform, config in entity_configs.items(): - for set_number in range(0, 2): + for set_number in range(2): set_config = deepcopy(config) set_config["name"] = f"test_{set_number}" topic = f"homeassistant/{platform}/bla_{set_number}/config" @@ -4139,7 +4139,7 @@ async def test_multi_platform_discovery( topic = f"homeassistant/{platform}/bla/config" async_fire_mqtt_message(hass, topic, json.dumps(config)) await hass.async_block_till_done() - for set_number in range(0, 2): + for set_number in range(2): for platform in entity_configs: entity_id = f"{platform}.test_{set_number}" state = hass.states.get(entity_id) diff --git a/tests/components/mqtt/test_light_json.py b/tests/components/mqtt/test_light_json.py index 8adbf05e46c..ff1b308ef70 100644 --- a/tests/components/mqtt/test_light_json.py +++ b/tests/components/mqtt/test_light_json.py @@ -983,7 +983,7 @@ async def test_controlling_the_state_with_legacy_color_handling( assert state.attributes.get("xy_color") is None assert not state.attributes.get(ATTR_ASSUMED_STATE) - for _ in range(0, 2): + for _ in range(2): # Returned state after the light was turned on # Receiving legacy color mode: rgb. async_fire_mqtt_message( diff --git a/tests/components/nest/test_media_source.py b/tests/components/nest/test_media_source.py index 88bef222c89..4810c8e2ff5 100644 --- a/tests/components/nest/test_media_source.py +++ b/tests/components/nest/test_media_source.py @@ -1053,7 +1053,7 @@ async def test_multiple_devices( assert len(browse.children) == 0 # Send events for device #1 - for i in range(0, 5): + for i in range(5): auth.responses = [ aiohttp.web.json_response(GENERATE_IMAGE_URL_RESPONSE), aiohttp.web.Response(body=IMAGE_BYTES_FROM_EVENT), @@ -1078,7 +1078,7 @@ async def test_multiple_devices( assert len(browse.children) == 0 # Send events for device #2 - for i in range(0, 3): + for i in range(3): auth.responses = [ aiohttp.web.json_response(GENERATE_IMAGE_URL_RESPONSE), aiohttp.web.Response(body=IMAGE_BYTES_FROM_EVENT), @@ -1340,7 +1340,7 @@ async def test_camera_event_media_eviction( assert len(browse.children) == 0 event_timestamp = dt_util.now() - for i in range(0, 7): + for i in range(7): auth.responses = [aiohttp.web.Response(body=f"image-bytes-{i}".encode())] ts = event_timestamp + datetime.timedelta(seconds=i) await subscriber.async_receive_event( diff --git a/tests/components/owntracks/test_device_tracker.py b/tests/components/owntracks/test_device_tracker.py index d855c318fb7..4462722bb53 100644 --- a/tests/components/owntracks/test_device_tracker.py +++ b/tests/components/owntracks/test_device_tracker.py @@ -964,7 +964,7 @@ async def test_mobile_exit_move_beacon(hass: HomeAssistant, context) -> None: async def test_mobile_multiple_async_enter_exit(hass: HomeAssistant, context) -> None: """Test the multiple entering.""" # Test race condition - for _ in range(0, 20): + for _ in range(20): async_fire_mqtt_message( hass, EVENT_TOPIC, json.dumps(MOBILE_BEACON_ENTER_EVENT_MESSAGE) ) diff --git a/tests/components/recorder/test_migrate.py b/tests/components/recorder/test_migrate.py index 600570acf66..141ffc31cc0 100644 --- a/tests/components/recorder/test_migrate.py +++ b/tests/components/recorder/test_migrate.py @@ -72,7 +72,7 @@ async def test_schema_update_calls(recorder_db_url: str, hass: HomeAssistant) -> update.assert_has_calls( [ call(instance, hass, engine, session_maker, version + 1, 0) - for version in range(0, db_schema.SCHEMA_VERSION) + for version in range(db_schema.SCHEMA_VERSION) ] ) diff --git a/tests/components/recorder/test_websocket_api.py b/tests/components/recorder/test_websocket_api.py index 2ca386734bb..01514385dd2 100644 --- a/tests/components/recorder/test_websocket_api.py +++ b/tests/components/recorder/test_websocket_api.py @@ -242,7 +242,7 @@ async def test_statistic_during_period( "min": -76 + i * 2, "sum": i, } - for i in range(0, 39) + for i in range(39) ] imported_stats = [] slice_end = 12 - offset @@ -255,7 +255,7 @@ async def test_statistic_during_period( "sum": imported_stats_5min[slice_end - 1]["sum"], } ) - for i in range(0, 2): + for i in range(2): slice_start = i * 12 + (12 - offset) slice_end = (i + 1) * 12 + (12 - offset) assert imported_stats_5min[slice_start]["start"].minute == 0 @@ -664,7 +664,7 @@ async def test_statistic_during_period_hole( "min": -76 + i * 2, "sum": i, } - for i in range(0, 6) + for i in range(6) ] imported_metadata = { diff --git a/tests/components/shopping_list/test_todo.py b/tests/components/shopping_list/test_todo.py index 373c449497c..fb6f61d4edf 100644 --- a/tests/components/shopping_list/test_todo.py +++ b/tests/components/shopping_list/test_todo.py @@ -166,7 +166,7 @@ async def test_bulk_remove( ) -> None: """Test removing a todo item.""" - for _i in range(0, 5): + for _i in range(5): await hass.services.async_call( TODO_DOMAIN, "add_item", diff --git a/tests/components/steam_online/__init__.py b/tests/components/steam_online/__init__.py index 46273a61816..c7d67509489 100644 --- a/tests/components/steam_online/__init__.py +++ b/tests/components/steam_online/__init__.py @@ -71,7 +71,7 @@ class MockedInterface(dict): fake_friends = [{"steamid": ACCOUNT_2}] fake_friends.extend( {"steamid": "".join(random.choices(string.digits, k=len(ACCOUNT_1)))} - for _ in range(0, 4) + for _ in range(4) ) return {"friendslist": {"friends": fake_friends}} diff --git a/tests/components/stream/test_worker.py b/tests/components/stream/test_worker.py index cf61368e12b..92221ebb88d 100644 --- a/tests/components/stream/test_worker.py +++ b/tests/components/stream/test_worker.py @@ -460,7 +460,7 @@ async def test_skip_initial_bad_packets(hass: HomeAssistant) -> None: num_packets = LONGER_TEST_SEQUENCE_LENGTH packets = list(PacketSequence(num_packets)) num_bad_packets = MAX_MISSING_DTS - 1 - for i in range(0, num_bad_packets): + for i in range(num_bad_packets): packets[i].dts = None decoded_stream = await async_decode_stream(hass, packets) @@ -490,7 +490,7 @@ async def test_too_many_initial_bad_packets_fails(hass: HomeAssistant) -> None: num_packets = LONGER_TEST_SEQUENCE_LENGTH packets = list(PacketSequence(num_packets)) num_bad_packets = MAX_MISSING_DTS + 1 - for i in range(0, num_bad_packets): + for i in range(num_bad_packets): packets[i].dts = None py_av = MockPyAv() diff --git a/tests/components/zwave_js/test_migrate.py b/tests/components/zwave_js/test_migrate.py index b5e88a745ef..41fa507a3a0 100644 --- a/tests/components/zwave_js/test_migrate.py +++ b/tests/components/zwave_js/test_migrate.py @@ -278,7 +278,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 _ 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) @@ -387,7 +387,7 @@ async def test_old_entity_migration_notification_binary_sensor( assert entity_entry.unique_id == old_unique_id # Do this twice to make sure re-interview doesn't do anything weird - for _ 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)