Replace parse_version with AwesomeVersion (#46329)

This commit is contained in:
Joakim Sørensen 2021-02-10 15:58:26 +01:00 committed by GitHub
parent dbb98e6cac
commit 917a616ce1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 5 deletions

View file

@ -5,7 +5,7 @@ import pathlib
import shutil
from typing import Any, Dict, List, Optional, Union
from pkg_resources import parse_version
from awesomeversion import AwesomeVersion
import voluptuous as vol
from voluptuous.humanize import humanize_error
@ -114,7 +114,7 @@ class Blueprint:
metadata = self.metadata
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
):
errors.append(f"Requires at least Home Assistant {min_version}")

View file

@ -4,8 +4,8 @@ import asyncio
import logging
from typing import Any, Callable, Dict, List, Optional, Set, Tuple, cast
from awesomeversion import AwesomeVersion
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.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()
if version is not None:
try:
if parse_version(version) < parse_version(HYPERION_VERSION_WARN_CUTOFF):
if AwesomeVersion(version) < AwesomeVersion(HYPERION_VERSION_WARN_CUTOFF):
_LOGGER.warning(
"Using a Hyperion server version < %s is not recommended -- "
"some features may be unavailable or may not function correctly. "

View file

@ -98,7 +98,7 @@ def create_mock_client() -> Mock:
)
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_login = AsyncMock(return_value=True)
mock_client.async_get_serverinfo = AsyncMock(