Replace parse_version with AwesomeVersion (#46329)
This commit is contained in:
parent
dbb98e6cac
commit
917a616ce1
3 changed files with 5 additions and 5 deletions
|
@ -5,7 +5,7 @@ import pathlib
|
||||||
import shutil
|
import shutil
|
||||||
from typing import Any, Dict, List, Optional, Union
|
from typing import Any, Dict, List, Optional, Union
|
||||||
|
|
||||||
from pkg_resources import parse_version
|
from awesomeversion import AwesomeVersion
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
from voluptuous.humanize import humanize_error
|
from voluptuous.humanize import humanize_error
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ class Blueprint:
|
||||||
metadata = self.metadata
|
metadata = self.metadata
|
||||||
min_version = metadata.get(CONF_HOMEASSISTANT, {}).get(CONF_MIN_VERSION)
|
min_version = metadata.get(CONF_HOMEASSISTANT, {}).get(CONF_MIN_VERSION)
|
||||||
|
|
||||||
if min_version is not None and parse_version(__version__) < parse_version(
|
if min_version is not None and AwesomeVersion(__version__) < AwesomeVersion(
|
||||||
min_version
|
min_version
|
||||||
):
|
):
|
||||||
errors.append(f"Requires at least Home Assistant {min_version}")
|
errors.append(f"Requires at least Home Assistant {min_version}")
|
||||||
|
|
|
@ -4,8 +4,8 @@ import asyncio
|
||||||
import logging
|
import logging
|
||||||
from typing import Any, Callable, Dict, List, Optional, Set, Tuple, cast
|
from typing import Any, Callable, Dict, List, Optional, Set, Tuple, cast
|
||||||
|
|
||||||
|
from awesomeversion import AwesomeVersion
|
||||||
from hyperion import client, const as hyperion_const
|
from hyperion import client, const as hyperion_const
|
||||||
from pkg_resources import parse_version
|
|
||||||
|
|
||||||
from homeassistant.components.light import DOMAIN as LIGHT_DOMAIN
|
from homeassistant.components.light import DOMAIN as LIGHT_DOMAIN
|
||||||
from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN
|
from homeassistant.components.switch import DOMAIN as SWITCH_DOMAIN
|
||||||
|
@ -159,7 +159,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
|
||||||
version = await hyperion_client.async_sysinfo_version()
|
version = await hyperion_client.async_sysinfo_version()
|
||||||
if version is not None:
|
if version is not None:
|
||||||
try:
|
try:
|
||||||
if parse_version(version) < parse_version(HYPERION_VERSION_WARN_CUTOFF):
|
if AwesomeVersion(version) < AwesomeVersion(HYPERION_VERSION_WARN_CUTOFF):
|
||||||
_LOGGER.warning(
|
_LOGGER.warning(
|
||||||
"Using a Hyperion server version < %s is not recommended -- "
|
"Using a Hyperion server version < %s is not recommended -- "
|
||||||
"some features may be unavailable or may not function correctly. "
|
"some features may be unavailable or may not function correctly. "
|
||||||
|
|
|
@ -98,7 +98,7 @@ def create_mock_client() -> Mock:
|
||||||
)
|
)
|
||||||
|
|
||||||
mock_client.async_sysinfo_id = AsyncMock(return_value=TEST_SYSINFO_ID)
|
mock_client.async_sysinfo_id = AsyncMock(return_value=TEST_SYSINFO_ID)
|
||||||
mock_client.async_sysinfo_version = AsyncMock(return_value=TEST_SYSINFO_ID)
|
mock_client.async_sysinfo_version = AsyncMock(return_value=TEST_SYSINFO_VERSION)
|
||||||
mock_client.async_client_switch_instance = AsyncMock(return_value=True)
|
mock_client.async_client_switch_instance = AsyncMock(return_value=True)
|
||||||
mock_client.async_client_login = AsyncMock(return_value=True)
|
mock_client.async_client_login = AsyncMock(return_value=True)
|
||||||
mock_client.async_get_serverinfo = AsyncMock(
|
mock_client.async_get_serverinfo = AsyncMock(
|
||||||
|
|
Loading…
Add table
Reference in a new issue