Skip to content

Commit

Permalink
Unignore Ruff PLE, PLW in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
autinerd committed Mar 28, 2024
1 parent 7d04378 commit 808f60b
Show file tree
Hide file tree
Showing 21 changed files with 23 additions and 34 deletions.
5 changes: 4 additions & 1 deletion tests/components/google_assistant/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,10 @@ def test_supported_features_string(caplog: pytest.LogCaptureFixture) -> None:
State("test.entity_id", "on", {"supported_features": "invalid"}),
)
assert entity.is_supported() is False
assert "Entity test.entity_id contains invalid supported_features value invalid"
assert (
"Entity test.entity_id contains invalid supported_features value invalid"
in caplog.text
)


def test_request_data() -> None:
Expand Down
2 changes: 1 addition & 1 deletion tests/components/history/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def test_get_significant_states_minimal_response(hass_history) -> None:
entity_states = states[entity_id]
for state_idx in range(1, len(entity_states)):
input_state = entity_states[state_idx]
orig_last_changed = orig_last_changed = json.dumps(
orig_last_changed = json.dumps(
process_timestamp(input_state.last_changed),
cls=JSONEncoder,
).replace('"', "")
Expand Down
2 changes: 1 addition & 1 deletion tests/components/history/test_init_db_schema_30.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def test_get_significant_states_minimal_response(legacy_hass_history) -> None:
entity_states = states[entity_id]
for state_idx in range(1, len(entity_states)):
input_state = entity_states[state_idx]
orig_last_changed = orig_last_changed = json.dumps(
orig_last_changed = json.dumps(
process_timestamp(input_state.last_changed),
cls=JSONEncoder,
).replace('"', "")
Expand Down
4 changes: 1 addition & 3 deletions tests/components/mobile_app/test_webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@
from .const import CALL_SERVICE, FIRE_EVENT, REGISTER_CLEARTEXT, RENDER_TEMPLATE, UPDATE

from tests.common import async_capture_events, async_mock_service
from tests.components.conversation.conftest import mock_agent

# To avoid autoflake8 removing the import
mock_agent = mock_agent
pytest_plugins = "tests.components.conversation.conftest"


@pytest.fixture
Expand Down
2 changes: 1 addition & 1 deletion tests/components/mqtt/test_climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ async def test_preset_modes_deprecation_guard(
hass: HomeAssistant, caplog: pytest.LogCaptureFixture, parameter: str
) -> None:
"""Test the configuration for invalid legacy parameters."""
assert f"[{parameter}] is an invalid option for [mqtt]. Check: mqtt->mqtt->climate->0->{parameter}"
# assert f"[{parameter}] is an invalid option for [mqtt]. Check: mqtt->mqtt->climate->0->{parameter}"


@pytest.mark.parametrize("hass_config", [DEFAULT_CONFIG])
Expand Down
2 changes: 1 addition & 1 deletion tests/components/recorder/test_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ def test_get_significant_states_minimal_response(
entity_states = states[entity_id]
for state_idx in range(1, len(entity_states)):
input_state = entity_states[state_idx]
orig_last_changed = orig_last_changed = json.dumps(
orig_last_changed = json.dumps(
process_timestamp(input_state.last_changed),
cls=JSONEncoder,
).replace('"', "")
Expand Down
2 changes: 1 addition & 1 deletion tests/components/recorder/test_history_db_schema_30.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ def test_get_significant_states_minimal_response(
entity_states = states[entity_id]
for state_idx in range(1, len(entity_states)):
input_state = entity_states[state_idx]
orig_last_changed = orig_last_changed = json.dumps(
orig_last_changed = json.dumps(
process_timestamp(input_state.last_changed),
cls=JSONEncoder,
).replace('"', "")
Expand Down
2 changes: 1 addition & 1 deletion tests/components/recorder/test_history_db_schema_32.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ def test_get_significant_states_minimal_response(
entity_states = states[entity_id]
for state_idx in range(1, len(entity_states)):
input_state = entity_states[state_idx]
orig_last_changed = orig_last_changed = json.dumps(
orig_last_changed = json.dumps(
process_timestamp(input_state.last_changed),
cls=JSONEncoder,
).replace('"', "")
Expand Down
2 changes: 1 addition & 1 deletion tests/components/recorder/test_history_db_schema_42.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ def test_get_significant_states_minimal_response(
entity_states = states[entity_id]
for state_idx in range(1, len(entity_states)):
input_state = entity_states[state_idx]
orig_last_changed = orig_last_changed = json.dumps(
orig_last_changed = json.dumps(
process_timestamp(input_state.last_changed),
cls=JSONEncoder,
).replace('"', "")
Expand Down
2 changes: 1 addition & 1 deletion tests/components/template/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ async def test_option_flow_preview(
"""Test the option flow preview."""
client = await hass_ws_client(hass)

input_entities = input_entities = ["one", "two"]
input_entities = ["one", "two"]

# Setup the config entry
config_entry = MockConfigEntry(
Expand Down
2 changes: 1 addition & 1 deletion tests/components/xiaomi/test_device_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def raise_for_status(self):
raise requests.HTTPError(self.status_code)

data = kwargs.get("data")
global FIRST_CALL
global FIRST_CALL # noqa: PLW0603

if data and data.get("username", None) == INVALID_USERNAME:
# deliver an invalid token
Expand Down
12 changes: 0 additions & 12 deletions tests/ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,10 @@
extend = "../pyproject.toml"

[lint]
extend-select = [
"PT001", # Use @pytest.fixture without parentheses
"PT002", # Configuration for fixture specified via positional args, use kwargs
"PT003", # The scope='function' is implied in @pytest.fixture()
"PT006", # Single parameter in parameterize is a string, multiple a tuple
"PT013", # Found incorrect pytest import, use simple import pytest instead
"PT015", # Assertion always fails, replace with pytest.fail()
"PT021", # use yield instead of request.addfinalizer
"PT022", # No teardown in fixture, replace useless yield with return
]

extend-ignore = [
"PLC", # pylint
"PLE", # pylint
"PLR", # pylint
"PLW", # pylint
"B904", # Use raise from to specify exception cause
"N815", # Variable {name} in class scope should not be mixedCase
]
Expand Down
2 changes: 1 addition & 1 deletion tests/testing_config/custom_components/test/date.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def set_value(self, value: date) -> None:

def init(empty=False):
"""Initialize the platform with entities."""
global ENTITIES
global ENTITIES # noqa: PLW0603

ENTITIES = (
[]
Expand Down
2 changes: 1 addition & 1 deletion tests/testing_config/custom_components/test/datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def set_value(self, value: datetime) -> None:

def init(empty=False):
"""Initialize the platform with entities."""
global ENTITIES
global ENTITIES # noqa: PLW0603

ENTITIES = (
[]
Expand Down
2 changes: 1 addition & 1 deletion tests/testing_config/custom_components/test/fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

def init(empty=False):
"""Initialize the platform with entities."""
global ENTITIES
global ENTITIES # noqa: PLW0603

ENTITIES = (
{}
Expand Down
2 changes: 1 addition & 1 deletion tests/testing_config/custom_components/test/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

def init(empty=False):
"""Initialize the platform with entities."""
global ENTITIES
global ENTITIES # noqa: PLW0603

ENTITIES = (
[]
Expand Down
2 changes: 1 addition & 1 deletion tests/testing_config/custom_components/test/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

def init(empty=False):
"""Initialize the platform with entities."""
global ENTITIES
global ENTITIES # noqa: PLW0603

ENTITIES = (
{}
Expand Down
2 changes: 1 addition & 1 deletion tests/testing_config/custom_components/test/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

def init(empty=False):
"""Initialize the platform with entities."""
global ENTITIES
global ENTITIES # noqa: PLW0603

ENTITIES = (
[]
Expand Down
2 changes: 1 addition & 1 deletion tests/testing_config/custom_components/test/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def select_option(self, option: str) -> None:

def init(empty=False):
"""Initialize the platform with entities."""
global ENTITIES
global ENTITIES # noqa: PLW0603

ENTITIES = (
[]
Expand Down
2 changes: 1 addition & 1 deletion tests/testing_config/custom_components/test/time.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def set_value(self, value: time) -> None:

def init(empty=False):
"""Initialize the platform with entities."""
global ENTITIES
global ENTITIES # noqa: PLW0603

ENTITIES = (
[]
Expand Down
2 changes: 1 addition & 1 deletion tests/testing_config/custom_components/test/weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

def init(empty=False):
"""Initialize the platform with entities."""
global ENTITIES
global ENTITIES # noqa: PLW0603
ENTITIES = [] if empty else [MockWeather()]


Expand Down

0 comments on commit 808f60b

Please sign in to comment.