mirror of
https://github.com/home-assistant/core.git
synced 2025-05-05 22:49:17 +00:00
Fix mysensors awesomeversion strategy usage (#51627)
* Update awesomeversion strategy use in mysensors * Remove default version
This commit is contained in:
parent
abbd4d1d16
commit
2eb6f16a94
@ -1,7 +1,6 @@
|
|||||||
"""Config flow for MySensors."""
|
"""Config flow for MySensors."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from contextlib import suppress
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
from typing import Any
|
from typing import Any
|
||||||
@ -55,7 +54,6 @@ def _get_schema_common(user_input: dict[str, str]) -> dict:
|
|||||||
schema = {
|
schema = {
|
||||||
vol.Required(
|
vol.Required(
|
||||||
CONF_VERSION,
|
CONF_VERSION,
|
||||||
default="",
|
|
||||||
description={
|
description={
|
||||||
"suggested_value": user_input.get(CONF_VERSION, DEFAULT_VERSION)
|
"suggested_value": user_input.get(CONF_VERSION, DEFAULT_VERSION)
|
||||||
},
|
},
|
||||||
@ -67,14 +65,14 @@ def _get_schema_common(user_input: dict[str, str]) -> dict:
|
|||||||
|
|
||||||
def _validate_version(version: str) -> dict[str, str]:
|
def _validate_version(version: str) -> dict[str, str]:
|
||||||
"""Validate a version string from the user."""
|
"""Validate a version string from the user."""
|
||||||
version_okay = False
|
version_okay = True
|
||||||
with suppress(AwesomeVersionStrategyException):
|
try:
|
||||||
version_okay = bool(
|
AwesomeVersion(
|
||||||
AwesomeVersion.ensure_strategy(
|
|
||||||
version,
|
version,
|
||||||
[AwesomeVersionStrategy.SIMPLEVER, AwesomeVersionStrategy.SEMVER],
|
[AwesomeVersionStrategy.SIMPLEVER, AwesomeVersionStrategy.SEMVER],
|
||||||
)
|
)
|
||||||
)
|
except AwesomeVersionStrategyException:
|
||||||
|
version_okay = False
|
||||||
|
|
||||||
if version_okay:
|
if version_okay:
|
||||||
return {}
|
return {}
|
||||||
|
@ -264,16 +264,6 @@ async def test_fail_to_connect(hass: HomeAssistant) -> None:
|
|||||||
CONF_VERSION,
|
CONF_VERSION,
|
||||||
"invalid_version",
|
"invalid_version",
|
||||||
),
|
),
|
||||||
(
|
|
||||||
CONF_GATEWAY_TYPE_TCP,
|
|
||||||
"gw_tcp",
|
|
||||||
{
|
|
||||||
CONF_TCP_PORT: 5003,
|
|
||||||
CONF_DEVICE: "127.0.0.1",
|
|
||||||
},
|
|
||||||
CONF_VERSION,
|
|
||||||
"invalid_version",
|
|
||||||
),
|
|
||||||
(
|
(
|
||||||
CONF_GATEWAY_TYPE_TCP,
|
CONF_GATEWAY_TYPE_TCP,
|
||||||
"gw_tcp",
|
"gw_tcp",
|
||||||
@ -302,6 +292,7 @@ async def test_fail_to_connect(hass: HomeAssistant) -> None:
|
|||||||
{
|
{
|
||||||
CONF_TCP_PORT: 5003,
|
CONF_TCP_PORT: 5003,
|
||||||
CONF_DEVICE: "127.0.0.",
|
CONF_DEVICE: "127.0.0.",
|
||||||
|
CONF_VERSION: "2.4",
|
||||||
},
|
},
|
||||||
CONF_DEVICE,
|
CONF_DEVICE,
|
||||||
"invalid_ip",
|
"invalid_ip",
|
||||||
@ -312,6 +303,7 @@ async def test_fail_to_connect(hass: HomeAssistant) -> None:
|
|||||||
{
|
{
|
||||||
CONF_TCP_PORT: 5003,
|
CONF_TCP_PORT: 5003,
|
||||||
CONF_DEVICE: "abcd",
|
CONF_DEVICE: "abcd",
|
||||||
|
CONF_VERSION: "2.4",
|
||||||
},
|
},
|
||||||
CONF_DEVICE,
|
CONF_DEVICE,
|
||||||
"invalid_ip",
|
"invalid_ip",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user