Fix mysensors awesomeversion strategy usage (#51627)

* Update awesomeversion strategy use in mysensors

* Remove default version
This commit is contained in:
Martin Hjelmare 2021-06-08 20:24:54 +02:00 committed by GitHub
parent abbd4d1d16
commit 2eb6f16a94
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 19 deletions

View file

@ -1,7 +1,6 @@
"""Config flow for MySensors."""
from __future__ import annotations
from contextlib import suppress
import logging
import os
from typing import Any
@ -55,7 +54,6 @@ def _get_schema_common(user_input: dict[str, str]) -> dict:
schema = {
vol.Required(
CONF_VERSION,
default="",
description={
"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]:
"""Validate a version string from the user."""
version_okay = False
with suppress(AwesomeVersionStrategyException):
version_okay = bool(
AwesomeVersion.ensure_strategy(
version,
[AwesomeVersionStrategy.SIMPLEVER, AwesomeVersionStrategy.SEMVER],
)
version_okay = True
try:
AwesomeVersion(
version,
[AwesomeVersionStrategy.SIMPLEVER, AwesomeVersionStrategy.SEMVER],
)
except AwesomeVersionStrategyException:
version_okay = False
if version_okay:
return {}