mirror of
https://github.com/esphome/esphome.git
synced 2026-09-29 16:00:23 +00:00
[core] Enable ruff B (flake8-bugbear) lint family (#16655)
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
from esphome.components.display import (
|
||||
DisplayMetaData,
|
||||
add_metadata,
|
||||
@@ -74,8 +76,5 @@ def test_add_metadata_overwrites_existing():
|
||||
def test_metadata_is_frozen():
|
||||
"""Test that DisplayMetaData instances are immutable (frozen dataclass)."""
|
||||
meta = DisplayMetaData(320, 240, True, False)
|
||||
try:
|
||||
with pytest.raises(AttributeError):
|
||||
meta.width = 640
|
||||
assert False, "Expected FrozenInstanceError"
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
@@ -510,15 +510,9 @@ def test_package_merge_by_missing_id() -> None:
|
||||
],
|
||||
}
|
||||
|
||||
error_raised = False
|
||||
try:
|
||||
with pytest.raises(cv.Invalid) as exc_info:
|
||||
packages_pass(config)
|
||||
assert False, "Expected validation error for missing ID"
|
||||
except cv.Invalid as err:
|
||||
error_raised = True
|
||||
assert err.path == [CONF_SENSOR, 2]
|
||||
|
||||
assert error_raised
|
||||
assert exc_info.value.path == [CONF_SENSOR, 2]
|
||||
|
||||
|
||||
def test_package_list_remove_by_id() -> None:
|
||||
|
||||
@@ -407,8 +407,10 @@ async def wait_and_connect_api_client(
|
||||
# Wait for connection with timeout
|
||||
try:
|
||||
await asyncio.wait_for(connected_future, timeout=timeout)
|
||||
except TimeoutError:
|
||||
raise TimeoutError(f"Failed to connect to API after {timeout} seconds")
|
||||
except TimeoutError as err:
|
||||
raise TimeoutError(
|
||||
f"Failed to connect to API after {timeout} seconds"
|
||||
) from err
|
||||
|
||||
if return_disconnect_event:
|
||||
yield client, disconnect_event
|
||||
|
||||
@@ -67,7 +67,7 @@ def test_iter_component_configs_with_multi_conf(mock_get_component: Mock) -> Non
|
||||
configs = list(config.iter_component_configs(test_config))
|
||||
assert len(configs) == 2
|
||||
|
||||
for domain, component, conf in configs:
|
||||
for domain, _component, conf in configs:
|
||||
assert domain == "switch"
|
||||
assert "name" in conf
|
||||
|
||||
|
||||
Reference in New Issue
Block a user