Skip to content

Commit

Permalink
Unignore Ruff PLE, PLW in tests (#114406)
Browse files Browse the repository at this point in the history
* Unignore Ruff PLE, PLW in tests

* fix tests
  • Loading branch information
autinerd authored Mar 29, 2024
1 parent 969b027 commit aec7a67
Show file tree
Hide file tree
Showing 14 changed files with 16 additions and 25 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
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/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/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 aec7a67

Please sign in to comment.