Fix host_valid() logic in Vilfo config flow (#49862)

This commit is contained in:
Maciej Bieniek 2021-04-29 17:11:22 +02:00 committed by GitHub
parent a4db35a16e
commit 0379dee47e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View file

@ -32,7 +32,7 @@ RESULT_INVALID_AUTH = "invalid_auth"
def host_valid(host):
"""Return True if hostname or IP address is valid."""
try:
if ipaddress.ip_address(host).version == (4 or 6):
if ipaddress.ip_address(host).version in [4, 6]:
return True
except ValueError:
disallowed = re.compile(r"[^a-zA-Z\d\-]")