Skip to content

Commit

Permalink
Support Python 3.8 (iMicknl#685)
Browse files Browse the repository at this point in the history
  • Loading branch information
iMicknl authored and egguy committed Jan 7, 2022
1 parent 3044eb5 commit 9c38035
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions custom_components/tahoma/executor.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""Class for helpers and community with the OverKiz API."""
from __future__ import annotations

import logging
from typing import Any, Optional
from typing import Any
from urllib.parse import urlparse

from pyhoma.models import Command, Device
Expand All @@ -24,7 +26,7 @@ def device(self) -> Device:
"""Return Overkiz device linked to this entity."""
return self.coordinator.data[self.device_url]

def select_command(self, *commands: str) -> Optional[str]:
def select_command(self, *commands: str) -> str | None:
"""Select first existing command in a list of commands."""
existing_commands = self.device.definition.commands
return next((c for c in commands if c in existing_commands), None)
Expand All @@ -33,7 +35,7 @@ def has_command(self, *commands: str) -> bool:
"""Return True if a command exists in a list of commands."""
return self.select_command(*commands) is not None

def select_state(self, *states) -> Optional[str]:
def select_state(self, *states) -> str | None:
"""Select first existing active state in a list of states."""
if self.device.states:
return next(
Expand All @@ -50,7 +52,7 @@ def has_state(self, *states: str) -> bool:
"""Return True if a state exists in self."""
return self.select_state(*states) is not None

def select_attribute(self, *attributes) -> Optional[str]:
def select_attribute(self, *attributes) -> str | None:
"""Select first existing active state in a list of states."""
if self.device.attributes:
return next(
Expand Down

0 comments on commit 9c38035

Please sign in to comment.