Skip to content

Commit

Permalink
Merge pull request #57 from tmonck/bugfix/is_hassio_deprecated
Browse files Browse the repository at this point in the history
Remove deprecated version of `is_hassio` call
  • Loading branch information
tmonck authored Dec 12, 2024
2 parents 44aed46 + 6fa5794 commit 75c0a4a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
- name: Set up Python 3.13
uses: actions/setup-python@v5
with:
python-version: 3.10.11
python-version: 3.13
- name: Install requirements
run: pip install -r requirements.test.txt
- name: Run unittests
Expand Down
9 changes: 5 additions & 4 deletions custom_components/clean_up_snapshots_service/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
import voluptuous as vol
from dateutil.parser import parse
from dateutil.tz import tzutc
from homeassistant.components.hassio import HassioAPIError, is_hassio
from homeassistant.components.hassio import HassioAPIError
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers import aiohttp_client
from homeassistant.helpers.hassio import is_hassio
from homeassistant.helpers.typing import ConfigType

from .const import BACKUPS_URL_PATH, CONF_ATTR_NAME, DEFAULT_NUM, DOMAIN, SUPERVISOR_URL
Expand Down Expand Up @@ -78,7 +79,7 @@ def __init__(self, hass, options):
async def async_get_snapshots(self):
_LOGGER.info("Calling get snapshots")
try:
with async_timeout.timeout(10):
async with async_timeout.timeout(10):
resp = await self._client_session.get(
SUPERVISOR_URL + BACKUPS_URL_PATH, headers=self._headers
)
Expand All @@ -92,7 +93,7 @@ async def async_get_snapshots(self):
raise HassioAPIError("Client timeout on GET /backups")
except Exception as err:
_LOGGER.error(
"Unknown exception thrown when calling GET /backups", exc_info=True
"Unknown exception thrown when calling GET /backups ", exc_info=True
)
raise HassioAPIError(
"Unknown exception thrown when calling GET /backups %s" % err
Expand All @@ -104,7 +105,7 @@ async def async_remove_snapshots(self, stale_snapshots):

# call hassio API deletion
try:
with async_timeout.timeout(10):
async with async_timeout.timeout(10):
resp = await self._client_session.delete(
SUPERVISOR_URL + f"{BACKUPS_URL_PATH}/" + snapshot["slug"],
headers=self._headers,
Expand Down
3 changes: 2 additions & 1 deletion hacs.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"name": "Clean up snapshots service",
"render_readme": true
"render_readme": true,
"homeassistant": "2024.11.0"
}
13 changes: 8 additions & 5 deletions tests/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,14 @@ async def test_async_setup_entry(hass: HomeAssistant, return_value):
num_backups_to_keep = 3
with patch("custom_components.clean_up_snapshots_service.is_hassio", is_hassio):
entry = ConfigEntry(
config_entry_ver,
DOMAIN,
"",
{},
None,
version=config_entry_ver,
minor_version=0,
source=None,
domain=DOMAIN,
title="",
data={},
unique_id=None,
discovery_keys=None,
options={CONF_ATTR_NAME: num_backups_to_keep},
)
result = await async_setup_entry(hass, entry)
Expand Down

0 comments on commit 75c0a4a

Please sign in to comment.