diff --git a/custom_components/anthropic/__init__.py b/custom_components/anthropic/__init__.py index aa6cf50..df6ea42 100644 --- a/custom_components/anthropic/__init__.py +++ b/custom_components/anthropic/__init__.py @@ -3,7 +3,6 @@ from __future__ import annotations import anthropic - from homeassistant.config_entries import ConfigEntry from homeassistant.const import CONF_API_KEY, Platform from homeassistant.core import HomeAssistant diff --git a/custom_components/anthropic/config_flow.py b/custom_components/anthropic/config_flow.py index 01e16ec..4288b09 100644 --- a/custom_components/anthropic/config_flow.py +++ b/custom_components/anthropic/config_flow.py @@ -8,7 +8,6 @@ import anthropic import voluptuous as vol - from homeassistant.config_entries import ( ConfigEntry, ConfigFlow, diff --git a/custom_components/anthropic/conversation.py b/custom_components/anthropic/conversation.py index 8233a0b..b9c27cb 100644 --- a/custom_components/anthropic/conversation.py +++ b/custom_components/anthropic/conversation.py @@ -1,10 +1,11 @@ """Conversation support for Anthropic.""" -from collections.abc import Callable import json +from collections.abc import Callable from typing import Any, Literal, cast import anthropic +import voluptuous as vol from anthropic._types import NOT_GIVEN from anthropic.types import ( Message, @@ -16,9 +17,6 @@ ToolUseBlock, ToolUseBlockParam, ) -import voluptuous as vol -from voluptuous_openapi import convert - from homeassistant.components import assist_pipeline, conversation from homeassistant.components.conversation import trace from homeassistant.const import CONF_LLM_HASS_API, MATCH_ALL @@ -27,6 +25,7 @@ from homeassistant.helpers import device_registry as dr, intent, llm, template from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.util import ulid +from voluptuous_openapi import convert from . import AnthropicConfigEntry from .const import ( diff --git a/tests/conftest.py b/tests/conftest.py index 59e3a12..3af5c78 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -3,15 +3,12 @@ from unittest.mock import AsyncMock, patch import pytest - from homeassistant.const import CONF_LLM_HASS_API from homeassistant.core import HomeAssistant from homeassistant.helpers import llm from homeassistant.setup import async_setup_component - from pytest_homeassistant_custom_component.common import MockConfigEntry - pytest_plugins = "pytest_homeassistant_custom_component" diff --git a/tests/test_config_flow.py b/tests/test_config_flow.py index 714ca9b..6acb030 100644 --- a/tests/test_config_flow.py +++ b/tests/test_config_flow.py @@ -2,6 +2,7 @@ from unittest.mock import AsyncMock, patch +import pytest from anthropic import ( APIConnectionError, APIResponseValidationError, @@ -10,10 +11,13 @@ BadRequestError, InternalServerError, ) +from homeassistant import config_entries +from homeassistant.const import CONF_LLM_HASS_API +from homeassistant.core import HomeAssistant +from homeassistant.data_entry_flow import FlowResultType from httpx import URL, Request, Response -import pytest +from pytest_homeassistant_custom_component.common import MockConfigEntry -from homeassistant import config_entries from custom_components.anthropic.config_flow import RECOMMENDED_OPTIONS from custom_components.anthropic.const import ( CONF_CHAT_MODEL, @@ -25,11 +29,6 @@ RECOMMENDED_CHAT_MODEL, RECOMMENDED_MAX_TOKENS, ) -from homeassistant.const import CONF_LLM_HASS_API -from homeassistant.core import HomeAssistant -from homeassistant.data_entry_flow import FlowResultType - -from pytest_homeassistant_custom_component.common import MockConfigEntry def test_test(hass): diff --git a/tests/test_conversation.py b/tests/test_conversation.py index 1818194..d138a86 100644 --- a/tests/test_conversation.py +++ b/tests/test_conversation.py @@ -2,13 +2,10 @@ from unittest.mock import AsyncMock, Mock, patch +import voluptuous as vol from anthropic import RateLimitError from anthropic.types import Message, TextBlock, ToolUseBlock, Usage from freezegun import freeze_time -from httpx import URL, Request, Response -from syrupy.assertion import SnapshotAssertion -import voluptuous as vol - from homeassistant.components import conversation from homeassistant.components.conversation import trace from homeassistant.const import CONF_LLM_HASS_API @@ -17,8 +14,9 @@ from homeassistant.helpers import intent, llm from homeassistant.setup import async_setup_component from homeassistant.util import ulid - +from httpx import URL, Request, Response from pytest_homeassistant_custom_component.common import MockConfigEntry +from syrupy.assertion import SnapshotAssertion def test_test(hass): diff --git a/tests/test_init.py b/tests/test_init.py index 69abe32..357e51e 100644 --- a/tests/test_init.py +++ b/tests/test_init.py @@ -2,18 +2,16 @@ from unittest.mock import AsyncMock, patch +import pytest from anthropic import ( APIConnectionError, APITimeoutError, AuthenticationError, BadRequestError, ) -from httpx import URL, Request, Response -import pytest - from homeassistant.core import HomeAssistant from homeassistant.setup import async_setup_component - +from httpx import URL, Request, Response from pytest_homeassistant_custom_component.common import MockConfigEntry