Add ruff rule PIE804 (#113620)
Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
parent
d0352ed91d
commit
fe9cc6705c
32 changed files with 64 additions and 91 deletions
|
@ -26,7 +26,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
client = GitHubAPI(
|
client = GitHubAPI(
|
||||||
token=entry.data[CONF_ACCESS_TOKEN],
|
token=entry.data[CONF_ACCESS_TOKEN],
|
||||||
session=async_get_clientsession(hass),
|
session=async_get_clientsession(hass),
|
||||||
**{"client_name": SERVER_SOFTWARE},
|
client_name=SERVER_SOFTWARE,
|
||||||
)
|
)
|
||||||
|
|
||||||
repositories: list[str] = entry.options[CONF_REPOSITORIES]
|
repositories: list[str] = entry.options[CONF_REPOSITORIES]
|
||||||
|
|
|
@ -38,12 +38,12 @@ async def get_repositories(hass: HomeAssistant, access_token: str) -> list[str]:
|
||||||
repositories = set()
|
repositories = set()
|
||||||
|
|
||||||
async def _get_starred_repositories() -> None:
|
async def _get_starred_repositories() -> None:
|
||||||
response = await client.user.starred(**{"params": {"per_page": 100}})
|
response = await client.user.starred(params={"per_page": 100})
|
||||||
if not response.is_last_page:
|
if not response.is_last_page:
|
||||||
results = await asyncio.gather(
|
results = await asyncio.gather(
|
||||||
*(
|
*(
|
||||||
client.user.starred(
|
client.user.starred(
|
||||||
**{"params": {"per_page": 100, "page": page_number}},
|
params={"per_page": 100, "page": page_number},
|
||||||
)
|
)
|
||||||
for page_number in range(
|
for page_number in range(
|
||||||
response.next_page_number, response.last_page_number + 1
|
response.next_page_number, response.last_page_number + 1
|
||||||
|
@ -56,12 +56,12 @@ async def get_repositories(hass: HomeAssistant, access_token: str) -> list[str]:
|
||||||
repositories.update(response.data)
|
repositories.update(response.data)
|
||||||
|
|
||||||
async def _get_personal_repositories() -> None:
|
async def _get_personal_repositories() -> None:
|
||||||
response = await client.user.repos(**{"params": {"per_page": 100}})
|
response = await client.user.repos(params={"per_page": 100})
|
||||||
if not response.is_last_page:
|
if not response.is_last_page:
|
||||||
results = await asyncio.gather(
|
results = await asyncio.gather(
|
||||||
*(
|
*(
|
||||||
client.user.repos(
|
client.user.repos(
|
||||||
**{"params": {"per_page": 100, "page": page_number}},
|
params={"per_page": 100, "page": page_number},
|
||||||
)
|
)
|
||||||
for page_number in range(
|
for page_number in range(
|
||||||
response.next_page_number, response.last_page_number + 1
|
response.next_page_number, response.last_page_number + 1
|
||||||
|
@ -137,7 +137,7 @@ class GitHubConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
self._device = GitHubDeviceAPI(
|
self._device = GitHubDeviceAPI(
|
||||||
client_id=CLIENT_ID,
|
client_id=CLIENT_ID,
|
||||||
session=async_get_clientsession(self.hass),
|
session=async_get_clientsession(self.hass),
|
||||||
**{"client_name": SERVER_SOFTWARE},
|
client_name=SERVER_SOFTWARE,
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -27,7 +27,7 @@ async def async_get_config_entry_diagnostics(
|
||||||
client = GitHubAPI(
|
client = GitHubAPI(
|
||||||
token=config_entry.data[CONF_ACCESS_TOKEN],
|
token=config_entry.data[CONF_ACCESS_TOKEN],
|
||||||
session=async_get_clientsession(hass),
|
session=async_get_clientsession(hass),
|
||||||
**{"client_name": SERVER_SOFTWARE},
|
client_name=SERVER_SOFTWARE,
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -47,7 +47,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
if not entry.unique_id:
|
if not entry.unique_id:
|
||||||
# If the config entry doesn't already have a unique ID, set one:
|
# If the config entry doesn't already have a unique ID, set one:
|
||||||
hass.config_entries.async_update_entry(
|
hass.config_entries.async_update_entry(
|
||||||
entry, **{"unique_id": entry.data[CONF_ZIP_CODE]}
|
entry, unique_id=entry.data[CONF_ZIP_CODE]
|
||||||
)
|
)
|
||||||
|
|
||||||
websession = aiohttp_client.async_get_clientsession(hass)
|
websession = aiohttp_client.async_get_clientsession(hass)
|
||||||
|
|
|
@ -605,6 +605,7 @@ select = [
|
||||||
"N815", # Variable {name} in class scope should not be mixedCase
|
"N815", # Variable {name} in class scope should not be mixedCase
|
||||||
"PERF", # Perflint
|
"PERF", # Perflint
|
||||||
"PGH004", # Use specific rule codes when using noqa
|
"PGH004", # Use specific rule codes when using noqa
|
||||||
|
"PIE804", # Unnecessary dict kwargs
|
||||||
"PIE790", # Unnecessary pass statement
|
"PIE790", # Unnecessary pass statement
|
||||||
"PIE794", # Class field is defined multiple times
|
"PIE794", # Class field is defined multiple times
|
||||||
"PIE807", # Prefer list/dict over useless lambda
|
"PIE807", # Prefer list/dict over useless lambda
|
||||||
|
|
|
@ -53,7 +53,7 @@ async def test_sensors(
|
||||||
assert entry.disabled
|
assert entry.disabled
|
||||||
assert entry.disabled_by is er.RegistryEntryDisabler.INTEGRATION
|
assert entry.disabled_by is er.RegistryEntryDisabler.INTEGRATION
|
||||||
update_entry = entity_registry.async_update_entity(
|
update_entry = entity_registry.async_update_entity(
|
||||||
entry.entity_id, **{"disabled_by": None}
|
entry.entity_id, disabled_by=None
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert update_entry != entry
|
assert update_entry != entry
|
||||||
|
@ -75,7 +75,7 @@ async def test_sensors(
|
||||||
assert entry.disabled
|
assert entry.disabled
|
||||||
assert entry.disabled_by is er.RegistryEntryDisabler.INTEGRATION
|
assert entry.disabled_by is er.RegistryEntryDisabler.INTEGRATION
|
||||||
update_entry = entity_registry.async_update_entity(
|
update_entry = entity_registry.async_update_entity(
|
||||||
entry.entity_id, **{"disabled_by": None}
|
entry.entity_id, disabled_by=None
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert update_entry != entry
|
assert update_entry != entry
|
||||||
|
@ -84,7 +84,7 @@ async def test_sensors(
|
||||||
assert state is None
|
assert state is None
|
||||||
|
|
||||||
update_entry = entity_registry.async_update_entity(
|
update_entry = entity_registry.async_update_entity(
|
||||||
entry.entity_id, **{"disabled_by": None}
|
entry.entity_id, disabled_by=None
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
async_fire_time_changed(
|
async_fire_time_changed(
|
||||||
|
@ -135,7 +135,7 @@ async def test_sensors_model_01(
|
||||||
assert entry.disabled
|
assert entry.disabled
|
||||||
assert entry.disabled_by is er.RegistryEntryDisabler.INTEGRATION
|
assert entry.disabled_by is er.RegistryEntryDisabler.INTEGRATION
|
||||||
update_entry = entity_registry.async_update_entity(
|
update_entry = entity_registry.async_update_entity(
|
||||||
entry.entity_id, **{"disabled_by": None}
|
entry.entity_id, disabled_by=None
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
assert update_entry != entry
|
assert update_entry != entry
|
||||||
|
@ -144,7 +144,7 @@ async def test_sensors_model_01(
|
||||||
assert state is None
|
assert state is None
|
||||||
|
|
||||||
update_entry = entity_registry.async_update_entity(
|
update_entry = entity_registry.async_update_entity(
|
||||||
entry.entity_id, **{"disabled_by": None}
|
entry.entity_id, disabled_by=None
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
async_fire_time_changed(
|
async_fire_time_changed(
|
||||||
|
|
|
@ -134,7 +134,7 @@ async def test_sensor_disabled(
|
||||||
|
|
||||||
# Test enabling entity.
|
# Test enabling entity.
|
||||||
updated_entry = entity_registry.async_update_entity(
|
updated_entry = entity_registry.async_update_entity(
|
||||||
entry.entity_id, **{"disabled_by": None}
|
entry.entity_id, disabled_by=None
|
||||||
)
|
)
|
||||||
|
|
||||||
assert updated_entry != entry
|
assert updated_entry != entry
|
||||||
|
|
|
@ -121,7 +121,7 @@ async def test_apprise_notification(hass: HomeAssistant) -> None:
|
||||||
# Validate calls were made under the hood correctly
|
# Validate calls were made under the hood correctly
|
||||||
obj.add.assert_called_once_with(config[BASE_COMPONENT]["url"])
|
obj.add.assert_called_once_with(config[BASE_COMPONENT]["url"])
|
||||||
obj.notify.assert_called_once_with(
|
obj.notify.assert_called_once_with(
|
||||||
**{"body": data["message"], "title": data["title"], "tag": None}
|
body=data["message"], title=data["title"], tag=None
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -162,7 +162,7 @@ async def test_apprise_multiple_notification(hass: HomeAssistant) -> None:
|
||||||
# Validate 2 calls were made under the hood
|
# Validate 2 calls were made under the hood
|
||||||
assert obj.add.call_count == 2
|
assert obj.add.call_count == 2
|
||||||
obj.notify.assert_called_once_with(
|
obj.notify.assert_called_once_with(
|
||||||
**{"body": data["message"], "title": data["title"], "tag": None}
|
body=data["message"], title=data["title"], tag=None
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -204,5 +204,5 @@ async def test_apprise_notification_with_target(
|
||||||
|
|
||||||
# Validate calls were made under the hood correctly
|
# Validate calls were made under the hood correctly
|
||||||
apprise_obj.notify.assert_called_once_with(
|
apprise_obj.notify.assert_called_once_with(
|
||||||
**{"body": data["message"], "title": data["title"], "tag": data["target"]}
|
body=data["message"], title=data["title"], tag=data["target"]
|
||||||
)
|
)
|
||||||
|
|
|
@ -467,19 +467,17 @@ async def test_register_view_with_location(
|
||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.cloud.http_api.async_detect_location_info",
|
"homeassistant.components.cloud.http_api.async_detect_location_info",
|
||||||
return_value=LocationInfo(
|
return_value=LocationInfo(
|
||||||
**{
|
country_code="XX",
|
||||||
"country_code": "XX",
|
zip_code="12345",
|
||||||
"zip_code": "12345",
|
region_code="GH",
|
||||||
"region_code": "GH",
|
ip="1.2.3.4",
|
||||||
"ip": "1.2.3.4",
|
city="Gotham",
|
||||||
"city": "Gotham",
|
region_name="Gotham",
|
||||||
"region_name": "Gotham",
|
time_zone="Earth/Gotham",
|
||||||
"time_zone": "Earth/Gotham",
|
currency="XXX",
|
||||||
"currency": "XXX",
|
latitude="12.34567",
|
||||||
"latitude": "12.34567",
|
longitude="12.34567",
|
||||||
"longitude": "12.34567",
|
use_metric=True,
|
||||||
"use_metric": True,
|
|
||||||
}
|
|
||||||
),
|
),
|
||||||
):
|
):
|
||||||
req = await cloud_client.post(
|
req = await cloud_client.post(
|
||||||
|
|
|
@ -121,7 +121,7 @@ async def enable_all_entities(hass, freezer, config_entry_id, time_till_next_upd
|
||||||
for entry in entities
|
for entry in entities
|
||||||
if entry.disabled_by is er.RegistryEntryDisabler.INTEGRATION
|
if entry.disabled_by is er.RegistryEntryDisabler.INTEGRATION
|
||||||
]:
|
]:
|
||||||
registry.async_update_entity(entry.entity_id, **{"disabled_by": None})
|
registry.async_update_entity(entry.entity_id, disabled_by=None)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
freezer.tick(time_till_next_update)
|
freezer.tick(time_till_next_update)
|
||||||
async_fire_time_changed(hass)
|
async_fire_time_changed(hass)
|
||||||
|
|
|
@ -86,7 +86,7 @@ async def test_enable_sensor(
|
||||||
|
|
||||||
# enable the entity
|
# enable the entity
|
||||||
updated_entry = entity_registry.async_update_entity(
|
updated_entry = entity_registry.async_update_entity(
|
||||||
entity_entry.entity_id, **{"disabled_by": None}
|
entity_entry.entity_id, disabled_by=None
|
||||||
)
|
)
|
||||||
assert updated_entry != entity_entry
|
assert updated_entry != entity_entry
|
||||||
assert updated_entry.disabled is False
|
assert updated_entry.disabled is False
|
||||||
|
|
|
@ -60,7 +60,7 @@ async def test_rssi_sensor(
|
||||||
|
|
||||||
# Test enabling entity
|
# Test enabling entity
|
||||||
updated_entry = entity_registry.async_update_entity(
|
updated_entry = entity_registry.async_update_entity(
|
||||||
entry.entity_id, **{"disabled_by": None}
|
entry.entity_id, disabled_by=None
|
||||||
)
|
)
|
||||||
|
|
||||||
with _patch_discovery(device=bulb), _patch_config_flow_try_connect(
|
with _patch_discovery(device=bulb), _patch_config_flow_try_connect(
|
||||||
|
@ -112,7 +112,7 @@ async def test_rssi_sensor_old_firmware(
|
||||||
|
|
||||||
# Test enabling entity
|
# Test enabling entity
|
||||||
updated_entry = entity_registry.async_update_entity(
|
updated_entry = entity_registry.async_update_entity(
|
||||||
entry.entity_id, **{"disabled_by": None}
|
entry.entity_id, disabled_by=None
|
||||||
)
|
)
|
||||||
|
|
||||||
with _patch_discovery(device=bulb), _patch_config_flow_try_connect(
|
with _patch_discovery(device=bulb), _patch_config_flow_try_connect(
|
||||||
|
|
|
@ -488,7 +488,7 @@ async def test_sensor_disabled(
|
||||||
|
|
||||||
# Test enabling entity
|
# Test enabling entity
|
||||||
updated_entry = entity_registry.async_update_entity(
|
updated_entry = entity_registry.async_update_entity(
|
||||||
entry.entity_id, **{"disabled_by": None}
|
entry.entity_id, disabled_by=None
|
||||||
)
|
)
|
||||||
|
|
||||||
assert updated_entry != entry
|
assert updated_entry != entry
|
||||||
|
|
|
@ -50,7 +50,7 @@ async def test_binary_sensors(
|
||||||
setup_owproxy_mock_devices(owproxy, Platform.BINARY_SENSOR, [device_id])
|
setup_owproxy_mock_devices(owproxy, Platform.BINARY_SENSOR, [device_id])
|
||||||
# Some entities are disabled, enable them and reload before checking states
|
# Some entities are disabled, enable them and reload before checking states
|
||||||
for ent in entity_entries:
|
for ent in entity_entries:
|
||||||
entity_registry.async_update_entity(ent.entity_id, **{"disabled_by": None})
|
entity_registry.async_update_entity(ent.entity_id, disabled_by=None)
|
||||||
await hass.config_entries.async_reload(config_entry.entry_id)
|
await hass.config_entries.async_reload(config_entry.entry_id)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ async def test_sensors(
|
||||||
setup_owproxy_mock_devices(owproxy, Platform.SENSOR, [device_id])
|
setup_owproxy_mock_devices(owproxy, Platform.SENSOR, [device_id])
|
||||||
# Some entities are disabled, enable them and reload before checking states
|
# Some entities are disabled, enable them and reload before checking states
|
||||||
for ent in entity_entries:
|
for ent in entity_entries:
|
||||||
entity_registry.async_update_entity(ent.entity_id, **{"disabled_by": None})
|
entity_registry.async_update_entity(ent.entity_id, disabled_by=None)
|
||||||
await hass.config_entries.async_reload(config_entry.entry_id)
|
await hass.config_entries.async_reload(config_entry.entry_id)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ async def test_switches(
|
||||||
setup_owproxy_mock_devices(owproxy, Platform.SWITCH, [device_id])
|
setup_owproxy_mock_devices(owproxy, Platform.SWITCH, [device_id])
|
||||||
# Some entities are disabled, enable them and reload before checking states
|
# Some entities are disabled, enable them and reload before checking states
|
||||||
for ent in entity_entries:
|
for ent in entity_entries:
|
||||||
entity_registry.async_update_entity(ent.entity_id, **{"disabled_by": None})
|
entity_registry.async_update_entity(ent.entity_id, disabled_by=None)
|
||||||
await hass.config_entries.async_reload(config_entry.entry_id)
|
await hass.config_entries.async_reload(config_entry.entry_id)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
|
|
|
@ -247,7 +247,7 @@ async def test_media_lookups(
|
||||||
},
|
},
|
||||||
True,
|
True,
|
||||||
)
|
)
|
||||||
search.assert_called_with(**{"title": "Movie 1", "libtype": None})
|
search.assert_called_with(title="Movie 1", libtype=None)
|
||||||
|
|
||||||
with pytest.raises(MediaNotFound) as excinfo:
|
with pytest.raises(MediaNotFound) as excinfo:
|
||||||
payload = '{"title": "Movie 1"}'
|
payload = '{"title": "Movie 1"}'
|
||||||
|
|
|
@ -50,7 +50,7 @@ async def test_sensors(
|
||||||
|
|
||||||
# Some entities are disabled, enable them and reload before checking states
|
# Some entities are disabled, enable them and reload before checking states
|
||||||
for ent in entity_entries:
|
for ent in entity_entries:
|
||||||
entity_registry.async_update_entity(ent.entity_id, **{"disabled_by": None})
|
entity_registry.async_update_entity(ent.entity_id, disabled_by=None)
|
||||||
await hass.config_entries.async_reload(config_entry.entry_id)
|
await hass.config_entries.async_reload(config_entry.entry_id)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ async def test_sensors(
|
||||||
|
|
||||||
# Some entities are disabled, enable them and reload before checking states
|
# Some entities are disabled, enable them and reload before checking states
|
||||||
for ent in entity_entries:
|
for ent in entity_entries:
|
||||||
entity_registry.async_update_entity(ent.entity_id, **{"disabled_by": None})
|
entity_registry.async_update_entity(ent.entity_id, disabled_by=None)
|
||||||
await hass.config_entries.async_reload(config_entry.entry_id)
|
await hass.config_entries.async_reload(config_entry.entry_id)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
|
|
|
@ -92,7 +92,7 @@ def test_send_message_with_bad_data_throws_vol_error(
|
||||||
logging.DEBUG, logger="homeassistant.components.signal_messenger.notify"
|
logging.DEBUG, logger="homeassistant.components.signal_messenger.notify"
|
||||||
), pytest.raises(vol.Invalid) as exc:
|
), pytest.raises(vol.Invalid) as exc:
|
||||||
data = {"test": "test"}
|
data = {"test": "test"}
|
||||||
signal_notification_service.send_message(MESSAGE, **{"data": data})
|
signal_notification_service.send_message(MESSAGE, data=data)
|
||||||
|
|
||||||
assert "Sending signal message" in caplog.text
|
assert "Sending signal message" in caplog.text
|
||||||
assert "extra keys not allowed" in str(exc.value)
|
assert "extra keys not allowed" in str(exc.value)
|
||||||
|
@ -112,7 +112,7 @@ def test_send_message_with_attachment(
|
||||||
) as temp_file:
|
) as temp_file:
|
||||||
temp_file.write("attachment_data")
|
temp_file.write("attachment_data")
|
||||||
data = {"attachments": [temp_file.name]}
|
data = {"attachments": [temp_file.name]}
|
||||||
signal_notification_service.send_message(MESSAGE, **{"data": data})
|
signal_notification_service.send_message(MESSAGE, data=data)
|
||||||
|
|
||||||
assert "Sending signal message" in caplog.text
|
assert "Sending signal message" in caplog.text
|
||||||
assert signal_requests_mock.called
|
assert signal_requests_mock.called
|
||||||
|
@ -131,7 +131,7 @@ def test_send_message_with_attachment_as_url(
|
||||||
logging.DEBUG, logger="homeassistant.components.signal_messenger.notify"
|
logging.DEBUG, logger="homeassistant.components.signal_messenger.notify"
|
||||||
):
|
):
|
||||||
data = {"urls": [URL_ATTACHMENT]}
|
data = {"urls": [URL_ATTACHMENT]}
|
||||||
signal_notification_service.send_message(MESSAGE, **{"data": data})
|
signal_notification_service.send_message(MESSAGE, data=data)
|
||||||
|
|
||||||
assert "Sending signal message" in caplog.text
|
assert "Sending signal message" in caplog.text
|
||||||
assert signal_requests_mock.called
|
assert signal_requests_mock.called
|
||||||
|
|
|
@ -66,9 +66,7 @@ async def test_sensor_disabled(hass: HomeAssistant, mock_bridge) -> None:
|
||||||
assert entry.disabled_by is er.RegistryEntryDisabler.INTEGRATION
|
assert entry.disabled_by is er.RegistryEntryDisabler.INTEGRATION
|
||||||
|
|
||||||
# Test enabling entity
|
# Test enabling entity
|
||||||
updated_entry = registry.async_update_entity(
|
updated_entry = registry.async_update_entity(entry.entity_id, disabled_by=None)
|
||||||
entry.entity_id, **{"disabled_by": None}
|
|
||||||
)
|
|
||||||
|
|
||||||
assert updated_entry != entry
|
assert updated_entry != entry
|
||||||
assert updated_entry.disabled is False
|
assert updated_entry.disabled is False
|
||||||
|
|
|
@ -105,9 +105,7 @@ def _enable_entity(hass: HomeAssistant, entity_name: str) -> None:
|
||||||
"""Enable disabled entity."""
|
"""Enable disabled entity."""
|
||||||
ent_reg = async_get(hass)
|
ent_reg = async_get(hass)
|
||||||
entry = ent_reg.async_get(entity_name)
|
entry = ent_reg.async_get(entity_name)
|
||||||
updated_entry = ent_reg.async_update_entity(
|
updated_entry = ent_reg.async_update_entity(entry.entity_id, disabled_by=None)
|
||||||
entry.entity_id, **{"disabled_by": None}
|
|
||||||
)
|
|
||||||
assert updated_entry != entry
|
assert updated_entry != entry
|
||||||
assert updated_entry.disabled is False
|
assert updated_entry.disabled is False
|
||||||
|
|
||||||
|
|
|
@ -68,9 +68,7 @@ def _enable_entity(hass: HomeAssistant, entity_name: str) -> None:
|
||||||
"""Enable disabled entity."""
|
"""Enable disabled entity."""
|
||||||
ent_reg = async_get(hass)
|
ent_reg = async_get(hass)
|
||||||
entry = ent_reg.async_get(entity_name)
|
entry = ent_reg.async_get(entity_name)
|
||||||
updated_entry = ent_reg.async_update_entity(
|
updated_entry = ent_reg.async_update_entity(entry.entity_id, disabled_by=None)
|
||||||
entry.entity_id, **{"disabled_by": None}
|
|
||||||
)
|
|
||||||
assert updated_entry != entry
|
assert updated_entry != entry
|
||||||
assert updated_entry.disabled is False
|
assert updated_entry.disabled is False
|
||||||
|
|
||||||
|
|
|
@ -372,13 +372,7 @@ async def test_xiaomi_vacuum_services(
|
||||||
"velocity": -0.1,
|
"velocity": -0.1,
|
||||||
},
|
},
|
||||||
"manual_control",
|
"manual_control",
|
||||||
mock.call(
|
mock.call(duration=1000, rotation=-40, velocity=-0.1),
|
||||||
**{
|
|
||||||
"duration": 1000,
|
|
||||||
"rotation": -40,
|
|
||||||
"velocity": -0.1,
|
|
||||||
}
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
SERVICE_STOP_REMOTE_CONTROL,
|
SERVICE_STOP_REMOTE_CONTROL,
|
||||||
|
@ -397,13 +391,7 @@ async def test_xiaomi_vacuum_services(
|
||||||
"velocity": 0.1,
|
"velocity": 0.1,
|
||||||
},
|
},
|
||||||
"manual_control_once",
|
"manual_control_once",
|
||||||
mock.call(
|
mock.call(duration=2000, rotation=120, velocity=0.1),
|
||||||
**{
|
|
||||||
"duration": 2000,
|
|
||||||
"rotation": 120,
|
|
||||||
"velocity": 0.1,
|
|
||||||
}
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
SERVICE_CLEAN_ZONE,
|
SERVICE_CLEAN_ZONE,
|
||||||
|
|
|
@ -119,9 +119,7 @@ async def test_disabled_legacy_sensor(
|
||||||
assert entry.disabled_by is er.RegistryEntryDisabler.INTEGRATION
|
assert entry.disabled_by is er.RegistryEntryDisabler.INTEGRATION
|
||||||
|
|
||||||
# Test enabling legacy entity
|
# Test enabling legacy entity
|
||||||
updated_entry = registry.async_update_entity(
|
updated_entry = registry.async_update_entity(entry.entity_id, disabled_by=None)
|
||||||
entry.entity_id, **{"disabled_by": None}
|
|
||||||
)
|
|
||||||
assert updated_entry != entry
|
assert updated_entry != entry
|
||||||
assert updated_entry.disabled is False
|
assert updated_entry.disabled is False
|
||||||
|
|
||||||
|
@ -274,7 +272,7 @@ async def test_config_parameter_binary_sensor(
|
||||||
assert entity_entry.entity_category == EntityCategory.DIAGNOSTIC
|
assert entity_entry.entity_category == EntityCategory.DIAGNOSTIC
|
||||||
|
|
||||||
updated_entry = ent_reg.async_update_entity(
|
updated_entry = ent_reg.async_update_entity(
|
||||||
binary_sensor_entity_id, **{"disabled_by": None}
|
binary_sensor_entity_id, disabled_by=None
|
||||||
)
|
)
|
||||||
assert updated_entry != entity_entry
|
assert updated_entry != entity_entry
|
||||||
assert updated_entry.disabled is False
|
assert updated_entry.disabled is False
|
||||||
|
|
|
@ -341,7 +341,7 @@ async def test_get_node_status_triggers(
|
||||||
entity_id = async_get_node_status_sensor_entity_id(
|
entity_id = async_get_node_status_sensor_entity_id(
|
||||||
hass, device.id, ent_reg, dev_reg
|
hass, device.id, ent_reg, dev_reg
|
||||||
)
|
)
|
||||||
entity = ent_reg.async_update_entity(entity_id, **{"disabled_by": None})
|
entity = ent_reg.async_update_entity(entity_id, disabled_by=None)
|
||||||
await hass.config_entries.async_reload(integration.entry_id)
|
await hass.config_entries.async_reload(integration.entry_id)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
|
@ -373,7 +373,7 @@ async def test_if_node_status_change_fires(
|
||||||
entity_id = async_get_node_status_sensor_entity_id(
|
entity_id = async_get_node_status_sensor_entity_id(
|
||||||
hass, device.id, ent_reg, dev_reg
|
hass, device.id, ent_reg, dev_reg
|
||||||
)
|
)
|
||||||
entity = ent_reg.async_update_entity(entity_id, **{"disabled_by": None})
|
entity = ent_reg.async_update_entity(entity_id, disabled_by=None)
|
||||||
await hass.config_entries.async_reload(integration.entry_id)
|
await hass.config_entries.async_reload(integration.entry_id)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
|
@ -452,7 +452,7 @@ async def test_if_node_status_change_fires_legacy(
|
||||||
entity_id = async_get_node_status_sensor_entity_id(
|
entity_id = async_get_node_status_sensor_entity_id(
|
||||||
hass, device.id, ent_reg, dev_reg
|
hass, device.id, ent_reg, dev_reg
|
||||||
)
|
)
|
||||||
ent_reg.async_update_entity(entity_id, **{"disabled_by": None})
|
ent_reg.async_update_entity(entity_id, disabled_by=None)
|
||||||
await hass.config_entries.async_reload(integration.entry_id)
|
await hass.config_entries.async_reload(integration.entry_id)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
|
@ -530,7 +530,7 @@ async def test_get_trigger_capabilities_node_status(
|
||||||
entity_id = async_get_node_status_sensor_entity_id(
|
entity_id = async_get_node_status_sensor_entity_id(
|
||||||
hass, device.id, ent_reg, dev_reg
|
hass, device.id, ent_reg, dev_reg
|
||||||
)
|
)
|
||||||
ent_reg.async_update_entity(entity_id, **{"disabled_by": None})
|
ent_reg.async_update_entity(entity_id, disabled_by=None)
|
||||||
await hass.config_entries.async_reload(integration.entry_id)
|
await hass.config_entries.async_reload(integration.entry_id)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
|
|
|
@ -153,9 +153,7 @@ async def test_merten_507801_disabled_enitites(
|
||||||
assert entry.disabled_by is er.RegistryEntryDisabler.INTEGRATION
|
assert entry.disabled_by is er.RegistryEntryDisabler.INTEGRATION
|
||||||
|
|
||||||
# Test enabling entity
|
# Test enabling entity
|
||||||
updated_entry = registry.async_update_entity(
|
updated_entry = registry.async_update_entity(entry.entity_id, disabled_by=None)
|
||||||
entry.entity_id, **{"disabled_by": None}
|
|
||||||
)
|
|
||||||
assert updated_entry != entry
|
assert updated_entry != entry
|
||||||
assert updated_entry.disabled is False
|
assert updated_entry.disabled is False
|
||||||
|
|
||||||
|
|
|
@ -232,7 +232,7 @@ async def test_config_parameter_number(
|
||||||
assert entity_entry.entity_category == EntityCategory.CONFIG
|
assert entity_entry.entity_category == EntityCategory.CONFIG
|
||||||
|
|
||||||
for entity_id in (number_entity_id, number_with_states_entity_id):
|
for entity_id in (number_entity_id, number_with_states_entity_id):
|
||||||
updated_entry = ent_reg.async_update_entity(entity_id, **{"disabled_by": None})
|
updated_entry = ent_reg.async_update_entity(entity_id, disabled_by=None)
|
||||||
assert updated_entry != entity_entry
|
assert updated_entry != entity_entry
|
||||||
assert updated_entry.disabled is False
|
assert updated_entry.disabled is False
|
||||||
|
|
||||||
|
|
|
@ -308,9 +308,7 @@ async def test_config_parameter_select(
|
||||||
assert entity_entry.disabled
|
assert entity_entry.disabled
|
||||||
assert entity_entry.entity_category == EntityCategory.CONFIG
|
assert entity_entry.entity_category == EntityCategory.CONFIG
|
||||||
|
|
||||||
updated_entry = ent_reg.async_update_entity(
|
updated_entry = ent_reg.async_update_entity(select_entity_id, disabled_by=None)
|
||||||
select_entity_id, **{"disabled_by": None}
|
|
||||||
)
|
|
||||||
assert updated_entry != entity_entry
|
assert updated_entry != entity_entry
|
||||||
assert updated_entry.disabled is False
|
assert updated_entry.disabled is False
|
||||||
|
|
||||||
|
|
|
@ -222,7 +222,7 @@ async def test_disabled_notification_sensor(
|
||||||
|
|
||||||
# Test enabling entity
|
# Test enabling entity
|
||||||
updated_entry = ent_reg.async_update_entity(
|
updated_entry = ent_reg.async_update_entity(
|
||||||
entity_entry.entity_id, **{"disabled_by": None}
|
entity_entry.entity_id, disabled_by=None
|
||||||
)
|
)
|
||||||
assert updated_entry != entity_entry
|
assert updated_entry != entity_entry
|
||||||
assert updated_entry.disabled is False
|
assert updated_entry.disabled is False
|
||||||
|
@ -278,7 +278,7 @@ async def test_config_parameter_sensor(
|
||||||
assert entity_entry.entity_category == EntityCategory.DIAGNOSTIC
|
assert entity_entry.entity_category == EntityCategory.DIAGNOSTIC
|
||||||
|
|
||||||
for entity_id in (sensor_entity_id, sensor_with_states_entity_id):
|
for entity_id in (sensor_entity_id, sensor_with_states_entity_id):
|
||||||
updated_entry = ent_reg.async_update_entity(entity_id, **{"disabled_by": None})
|
updated_entry = ent_reg.async_update_entity(entity_id, disabled_by=None)
|
||||||
assert updated_entry != entity_entry
|
assert updated_entry != entity_entry
|
||||||
assert updated_entry.disabled is False
|
assert updated_entry.disabled is False
|
||||||
|
|
||||||
|
@ -295,7 +295,7 @@ async def test_config_parameter_sensor(
|
||||||
assert state.state == "C-Wire"
|
assert state.state == "C-Wire"
|
||||||
|
|
||||||
updated_entry = ent_reg.async_update_entity(
|
updated_entry = ent_reg.async_update_entity(
|
||||||
entity_entry.entity_id, **{"disabled_by": None}
|
entity_entry.entity_id, disabled_by=None
|
||||||
)
|
)
|
||||||
assert updated_entry != entity_entry
|
assert updated_entry != entity_entry
|
||||||
assert updated_entry.disabled is False
|
assert updated_entry.disabled is False
|
||||||
|
@ -753,7 +753,7 @@ async def test_statistics_sensors_no_last_seen(
|
||||||
assert entry.disabled
|
assert entry.disabled
|
||||||
assert entry.disabled_by is er.RegistryEntryDisabler.INTEGRATION
|
assert entry.disabled_by is er.RegistryEntryDisabler.INTEGRATION
|
||||||
|
|
||||||
ent_reg.async_update_entity(entry.entity_id, **{"disabled_by": None})
|
ent_reg.async_update_entity(entry.entity_id, disabled_by=None)
|
||||||
|
|
||||||
# reload integration and check if entity is correctly there
|
# reload integration and check if entity is correctly there
|
||||||
await hass.config_entries.async_reload(integration.entry_id)
|
await hass.config_entries.async_reload(integration.entry_id)
|
||||||
|
|
|
@ -228,9 +228,7 @@ async def test_config_parameter_switch(
|
||||||
assert entity_entry
|
assert entity_entry
|
||||||
assert entity_entry.disabled
|
assert entity_entry.disabled
|
||||||
|
|
||||||
updated_entry = ent_reg.async_update_entity(
|
updated_entry = ent_reg.async_update_entity(switch_entity_id, disabled_by=None)
|
||||||
switch_entity_id, **{"disabled_by": None}
|
|
||||||
)
|
|
||||||
assert updated_entry != entity_entry
|
assert updated_entry != entity_entry
|
||||||
assert updated_entry.disabled is False
|
assert updated_entry.disabled is False
|
||||||
assert entity_entry.entity_category == EntityCategory.CONFIG
|
assert entity_entry.entity_category == EntityCategory.CONFIG
|
||||||
|
|
|
@ -1971,7 +1971,7 @@ async def test_core_store_historic_currency(
|
||||||
assert issue
|
assert issue
|
||||||
assert issue.translation_placeholders == {"currency": "LTT"}
|
assert issue.translation_placeholders == {"currency": "LTT"}
|
||||||
|
|
||||||
await hass.config.async_update(**{"currency": "EUR"})
|
await hass.config.async_update(currency="EUR")
|
||||||
issue = issue_registry.async_get_issue("homeassistant", issue_id)
|
issue = issue_registry.async_get_issue("homeassistant", issue_id)
|
||||||
assert not issue
|
assert not issue
|
||||||
|
|
||||||
|
@ -2027,7 +2027,7 @@ async def test_core_store_no_country(
|
||||||
issue = issue_registry.async_get_issue("homeassistant", issue_id)
|
issue = issue_registry.async_get_issue("homeassistant", issue_id)
|
||||||
assert issue
|
assert issue
|
||||||
|
|
||||||
await hass.config.async_update(**{"country": "SE"})
|
await hass.config.async_update(country="SE")
|
||||||
issue = issue_registry.async_get_issue("homeassistant", issue_id)
|
issue = issue_registry.async_get_issue("homeassistant", issue_id)
|
||||||
assert not issue
|
assert not issue
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue