Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions hass_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
from __future__ import annotations

import asyncio
import inspect
import logging
import os
import pprint
from collections.abc import Callable
from ssl import SSLContext
from typing import TYPE_CHECKING, Any

import aiohttp
Expand Down Expand Up @@ -53,6 +53,7 @@
)

if TYPE_CHECKING:
from ssl import SSLContext
from types import TracebackType

try:
Expand Down Expand Up @@ -127,7 +128,7 @@ async def subscribe_events(
"""

def handle_message(message: Message):
if asyncio.iscoroutinefunction(cb_func):
if inspect.iscoroutinefunction(cb_func):
self._loop.create_task(cb_func(message["event"]))
else:
self._loop.call_soon(cb_func, message["event"])
Expand All @@ -150,7 +151,7 @@ async def subscribe_entities(
"""

def handle_message(message: Message):
if asyncio.iscoroutinefunction(cb_func):
if inspect.iscoroutinefunction(cb_func):
self._loop.create_task(cb_func(message["event"]))
else:
self._loop.call_soon(cb_func, message["event"])
Expand Down Expand Up @@ -383,7 +384,7 @@ def _handle_incoming_message(self, msg: Message) -> None:
# subscription callback
if msg["id"] in self._subscriptions:
handler = self._subscriptions[msg["id"]][1]
if asyncio.iscoroutinefunction(handler):
if inspect.iscoroutinefunction(handler):
self._loop.create_task(handler(msg))
else:
self._loop.call_soon(handler, msg)
Expand Down
6 changes: 3 additions & 3 deletions hass_client/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ async def get_long_lived_token(
lifespan: int = 365,
) -> str:
"""Request a Long Lived token with a short lived access token."""
# prevent circular import
# pylint: disable-next=import-outside-toplevel
from .client import HomeAssistantClient
from .client import ( # noqa: PLC0415 # pylint: disable=import-outside-toplevel
HomeAssistantClient,
)

ws_url = get_websocket_url(hass_url)
async with HomeAssistantClient(ws_url, access_token) as hass:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ test = [
"pytest==8.3.3",
"pytest-aiohttp==1.0.5",
"pytest-cov==5.0.0",
"ruff==0.6.8",
"ruff==0.15.8",
]

[tool.codespell]
Expand Down
Loading