Skip to content

Commit

Permalink
Unignore Ruff PLR in tests (home-assistant#114470)
Browse files Browse the repository at this point in the history
* Unignore Ruff PLR in tests

* Address review comments

* review comments

* fix import

* Update test_api.py

* Update test_api.py

* Update test_api.py
  • Loading branch information
autinerd authored Apr 1, 2024
1 parent dc59073 commit d5f883f
Show file tree
Hide file tree
Showing 169 changed files with 211 additions and 266 deletions.
2 changes: 1 addition & 1 deletion tests/components/alarm_control_panel/test_device_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import pytest
from pytest_unordered import unordered

from homeassistant.components import automation
from homeassistant.components.alarm_control_panel import (
DOMAIN,
AlarmControlPanelEntityFeature,
)
import homeassistant.components.automation as automation
from homeassistant.components.device_automation import DeviceAutomationType
from homeassistant.const import (
CONF_PLATFORM,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import pytest
from pytest_unordered import unordered

from homeassistant.components import automation
from homeassistant.components.alarm_control_panel import (
DOMAIN,
AlarmControlPanelEntityFeature,
)
import homeassistant.components.automation as automation
from homeassistant.components.device_automation import DeviceAutomationType
from homeassistant.const import (
STATE_ALARM_ARMED_AWAY,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
import pytest
from pytest_unordered import unordered

from homeassistant.components import automation
from homeassistant.components.alarm_control_panel import (
DOMAIN,
AlarmControlPanelEntityFeature,
)
import homeassistant.components.automation as automation
from homeassistant.components.device_automation import DeviceAutomationType
from homeassistant.const import (
STATE_ALARM_ARMED_AWAY,
Expand Down
3 changes: 1 addition & 2 deletions tests/components/alert/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import pytest

import homeassistant.components.alert as alert
from homeassistant.components import alert, notify
from homeassistant.components.alert.const import (
CONF_ALERT_MESSAGE,
CONF_DATA,
Expand All @@ -14,7 +14,6 @@
CONF_TITLE,
DOMAIN,
)
import homeassistant.components.notify as notify
from homeassistant.const import (
ATTR_ENTITY_ID,
CONF_ENTITY_ID,
Expand Down
2 changes: 1 addition & 1 deletion tests/components/alexa/test_smart_home.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

import pytest

from homeassistant.components import camera
from homeassistant.components.alexa import smart_home, state_report
import homeassistant.components.camera as camera
from homeassistant.components.climate import ClimateEntityFeature
from homeassistant.components.cover import CoverDeviceClass, CoverEntityFeature
from homeassistant.components.media_player import MediaPlayerEntityFeature
Expand Down
3 changes: 2 additions & 1 deletion tests/components/androidtv/patchers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from unittest.mock import patch

from androidtv.adb_manager.adb_manager_async import DeviceAsync
from androidtv.constants import CMD_DEVICE_PROPERTIES, CMD_MAC_ETH0, CMD_MAC_WLAN0

from homeassistant.components.androidtv.const import (
Expand Down Expand Up @@ -62,7 +63,7 @@ def __init__(self, host=ADB_SERVER_HOST, port=DEFAULT_ADB_SERVER_PORT) -> None:
"""Initialize a `ClientAsyncFakeFail` instance."""
self._devices = []

async def device(self, serial):
async def device(self, serial) -> DeviceAsync | None:
"""Mock the `ClientAsync.device` method when the device is not connected via ADB."""
self._devices = []
return None
Expand Down
2 changes: 1 addition & 1 deletion tests/components/apache_kafka/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import pytest

import homeassistant.components.apache_kafka as apache_kafka
from homeassistant.components import apache_kafka
from homeassistant.const import STATE_ON
from homeassistant.core import HomeAssistant
from homeassistant.setup import async_setup_component
Expand Down
2 changes: 1 addition & 1 deletion tests/components/aprs/test_device_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from aprslib import IS
import pytest

import homeassistant.components.aprs.device_tracker as device_tracker
from homeassistant.components.aprs import device_tracker
from homeassistant.core import HomeAssistant

DEFAULT_PORT = 14580
Expand Down
2 changes: 1 addition & 1 deletion tests/components/arcam_fmj/test_device_trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import pytest

from homeassistant.components import automation
from homeassistant.components.arcam_fmj.const import DOMAIN
import homeassistant.components.automation as automation
from homeassistant.components.device_automation import DeviceAutomationType
from homeassistant.core import HomeAssistant
from homeassistant.helpers import device_registry as dr, entity_registry as er
Expand Down
2 changes: 1 addition & 1 deletion tests/components/assist_pipeline/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ def event_callback(event):
event_callback=event_callback,
)

assert run_1 == run_1
assert run_1 == run_1 # noqa: PLR0124
assert run_1 != run_2
assert run_1 != 1234

Expand Down
2 changes: 1 addition & 1 deletion tests/components/automation/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import pytest

from homeassistant import config_entries
import homeassistant.components.automation as automation
from homeassistant.components import automation
from homeassistant.components.automation import (
ATTR_SOURCE,
DOMAIN,
Expand Down
1 change: 0 additions & 1 deletion tests/components/baf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ async def async_wait_available(self):
"""Mock async_wait_available."""
if self._async_wait_available_side_effect:
raise self._async_wait_available_side_effect
return

def async_run(self):
"""Mock async_run."""
Expand Down
2 changes: 1 addition & 1 deletion tests/components/binary_sensor/test_device_condition.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import pytest
from pytest_unordered import unordered

import homeassistant.components.automation as automation
from homeassistant.components import automation
from homeassistant.components.binary_sensor import DOMAIN, BinarySensorDeviceClass
from homeassistant.components.binary_sensor.device_condition import ENTITY_CONDITIONS
from homeassistant.components.device_automation import DeviceAutomationType
Expand Down
2 changes: 1 addition & 1 deletion tests/components/binary_sensor/test_device_trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import pytest
from pytest_unordered import unordered

import homeassistant.components.automation as automation
from homeassistant.components import automation
from homeassistant.components.binary_sensor import DOMAIN, BinarySensorDeviceClass
from homeassistant.components.binary_sensor.device_trigger import ENTITY_TRIGGERS
from homeassistant.components.device_automation import DeviceAutomationType
Expand Down
2 changes: 1 addition & 1 deletion tests/components/caldav/test_todo.py
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ async def test_remove_item(
assert state.state == "1"

def lookup(uid: str) -> Mock:
assert uid == "2" or uid == "3"
assert uid in ("2", "3")
if uid == "2":
return item1
return item2
Expand Down
3 changes: 1 addition & 2 deletions tests/components/calendar/test_trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
from freezegun.api import FrozenDateTimeFactory
import pytest

from homeassistant.components import calendar
import homeassistant.components.automation as automation
from homeassistant.components import automation, calendar
from homeassistant.components.calendar.trigger import EVENT_END, EVENT_START
from homeassistant.const import ATTR_ENTITY_ID, SERVICE_TURN_OFF
from homeassistant.core import HomeAssistant
Expand Down
2 changes: 1 addition & 1 deletion tests/components/climate/test_device_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from pytest_unordered import unordered
import voluptuous_serialize

import homeassistant.components.automation as automation
from homeassistant.components import automation
from homeassistant.components.climate import DOMAIN, HVACMode, const, device_action
from homeassistant.components.device_automation import DeviceAutomationType
from homeassistant.const import EntityCategory
Expand Down
2 changes: 1 addition & 1 deletion tests/components/climate/test_device_condition.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from pytest_unordered import unordered
import voluptuous_serialize

import homeassistant.components.automation as automation
from homeassistant.components import automation
from homeassistant.components.climate import DOMAIN, HVACMode, const, device_condition
from homeassistant.components.device_automation import DeviceAutomationType
from homeassistant.const import EntityCategory
Expand Down
2 changes: 1 addition & 1 deletion tests/components/climate/test_device_trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from pytest_unordered import unordered
import voluptuous_serialize

import homeassistant.components.automation as automation
from homeassistant.components import automation
from homeassistant.components.climate import (
DOMAIN,
HVACAction,
Expand Down
2 changes: 1 addition & 1 deletion tests/components/configurator/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from datetime import timedelta

import homeassistant.components.configurator as configurator
from homeassistant.components import configurator
from homeassistant.const import ATTR_FRIENDLY_NAME
from homeassistant.core import HomeAssistant
import homeassistant.util.dt as dt_util
Expand Down
2 changes: 1 addition & 1 deletion tests/components/cover/test_device_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pytest
from pytest_unordered import unordered

import homeassistant.components.automation as automation
from homeassistant.components import automation
from homeassistant.components.cover import DOMAIN, CoverEntityFeature
from homeassistant.components.device_automation import DeviceAutomationType
from homeassistant.const import CONF_PLATFORM, EntityCategory
Expand Down
2 changes: 1 addition & 1 deletion tests/components/cover/test_device_condition.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pytest
from pytest_unordered import unordered

import homeassistant.components.automation as automation
from homeassistant.components import automation
from homeassistant.components.cover import DOMAIN, CoverEntityFeature
from homeassistant.components.device_automation import DeviceAutomationType
from homeassistant.const import (
Expand Down
2 changes: 1 addition & 1 deletion tests/components/cover/test_device_trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import pytest
from pytest_unordered import unordered

import homeassistant.components.automation as automation
from homeassistant.components import automation
from homeassistant.components.cover import DOMAIN, CoverEntityFeature
from homeassistant.components.device_automation import DeviceAutomationType
from homeassistant.const import (
Expand Down
2 changes: 1 addition & 1 deletion tests/components/cover/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import pytest

import homeassistant.components.cover as cover
from homeassistant.components import cover
from homeassistant.const import (
ATTR_ENTITY_ID,
CONF_PLATFORM,
Expand Down
2 changes: 1 addition & 1 deletion tests/components/datadog/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from unittest import mock
from unittest.mock import patch

import homeassistant.components.datadog as datadog
from homeassistant.components import datadog
from homeassistant.const import EVENT_LOGBOOK_ENTRY, STATE_OFF, STATE_ON
from homeassistant.core import HomeAssistant
from homeassistant.setup import async_setup_component
Expand Down
2 changes: 1 addition & 1 deletion tests/components/demo/test_notify.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import pytest
import voluptuous as vol

from homeassistant.components import notify
import homeassistant.components.demo.notify as demo
import homeassistant.components.notify as notify
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import discovery
from homeassistant.setup import async_setup_component
Expand Down
2 changes: 1 addition & 1 deletion tests/components/demo/test_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import pytest

import homeassistant.components.remote as remote
from homeassistant.components import remote
from homeassistant.components.remote import ATTR_COMMAND
from homeassistant.const import (
ATTR_ENTITY_ID,
Expand Down
3 changes: 1 addition & 2 deletions tests/components/device_automation/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
import voluptuous as vol

from homeassistant import config_entries, loader
from homeassistant.components import device_automation
import homeassistant.components.automation as automation
from homeassistant.components import automation, device_automation
from homeassistant.components.device_automation import (
InvalidDeviceAutomationConfig,
toggle_entity,
Expand Down
2 changes: 1 addition & 1 deletion tests/components/device_automation/test_toggle_entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import pytest

import homeassistant.components.automation as automation
from homeassistant.components import automation
from homeassistant.const import STATE_OFF, STATE_ON
from homeassistant.core import HomeAssistant
from homeassistant.helpers import device_registry as dr, entity_registry as er
Expand Down
2 changes: 1 addition & 1 deletion tests/components/device_tracker/test_device_condition.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pytest
from pytest_unordered import unordered

import homeassistant.components.automation as automation
from homeassistant.components import automation
from homeassistant.components.device_automation import DeviceAutomationType
from homeassistant.components.device_tracker import DOMAIN
from homeassistant.const import STATE_HOME, EntityCategory
Expand Down
3 changes: 1 addition & 2 deletions tests/components/device_tracker/test_device_trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
from pytest_unordered import unordered
import voluptuous_serialize

import homeassistant.components.automation as automation
from homeassistant.components import automation, zone
from homeassistant.components.device_automation import DeviceAutomationType
from homeassistant.components.device_tracker import DOMAIN, device_trigger
import homeassistant.components.zone as zone
from homeassistant.const import EntityCategory
from homeassistant.core import HomeAssistant
from homeassistant.helpers import (
Expand Down
3 changes: 1 addition & 2 deletions tests/components/device_tracker/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@

import pytest

from homeassistant.components import zone
import homeassistant.components.device_tracker as device_tracker
from homeassistant.components import device_tracker, zone
from homeassistant.components.device_tracker import SourceType, const, legacy
from homeassistant.const import (
ATTR_ENTITY_PICTURE,
Expand Down
2 changes: 1 addition & 1 deletion tests/components/ecobee/test_climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@

import pytest

from homeassistant import const
from homeassistant.components import climate
from homeassistant.components.climate import ClimateEntityFeature
from homeassistant.components.ecobee.climate import (
ECOBEE_AUX_HEAT_ONLY,
PRESET_AWAY_INDEFINITELY,
Thermostat,
)
import homeassistant.const as const
from homeassistant.const import ATTR_ENTITY_ID, ATTR_SUPPORTED_FEATURES, STATE_OFF
from homeassistant.core import HomeAssistant

Expand Down
2 changes: 1 addition & 1 deletion tests/components/fan/test_device_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pytest
from pytest_unordered import unordered

import homeassistant.components.automation as automation
from homeassistant.components import automation
from homeassistant.components.device_automation import DeviceAutomationType
from homeassistant.components.fan import DOMAIN
from homeassistant.const import EntityCategory
Expand Down
2 changes: 1 addition & 1 deletion tests/components/fan/test_device_condition.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pytest
from pytest_unordered import unordered

import homeassistant.components.automation as automation
from homeassistant.components import automation
from homeassistant.components.device_automation import DeviceAutomationType
from homeassistant.components.fan import DOMAIN
from homeassistant.const import STATE_OFF, STATE_ON, EntityCategory
Expand Down
2 changes: 1 addition & 1 deletion tests/components/fan/test_device_trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import pytest
from pytest_unordered import unordered

import homeassistant.components.automation as automation
from homeassistant.components import automation
from homeassistant.components.device_automation import DeviceAutomationType
from homeassistant.components.fan import DOMAIN
from homeassistant.const import STATE_OFF, STATE_ON, EntityCategory
Expand Down
2 changes: 1 addition & 1 deletion tests/components/foobot/test_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

import pytest

from homeassistant.components import sensor
from homeassistant.components.foobot import sensor as foobot
import homeassistant.components.sensor as sensor
from homeassistant.const import (
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
CONCENTRATION_PARTS_PER_BILLION,
Expand Down
2 changes: 1 addition & 1 deletion tests/components/fully_kiosk/test_button.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from unittest.mock import MagicMock

import homeassistant.components.button as button
from homeassistant.components import button
from homeassistant.components.fully_kiosk.const import DOMAIN
from homeassistant.const import ATTR_ENTITY_ID
from homeassistant.core import HomeAssistant
Expand Down
2 changes: 1 addition & 1 deletion tests/components/fully_kiosk/test_media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

from unittest.mock import MagicMock, Mock, patch

from homeassistant.components import media_player
from homeassistant.components.fully_kiosk.const import DOMAIN, MEDIA_SUPPORT_FULLYKIOSK
import homeassistant.components.media_player as media_player
from homeassistant.components.media_source import DOMAIN as MS_DOMAIN
from homeassistant.const import ATTR_ENTITY_ID
from homeassistant.core import HomeAssistant
Expand Down
Loading

0 comments on commit d5f883f

Please sign in to comment.