mirror of
https://github.com/Electric-Special/ha-core.git
synced 2026-03-21 04:05:20 +01:00
Enable strict typing check for Anthropic (#163013)
This commit is contained in:
@@ -84,6 +84,7 @@ homeassistant.components.androidtv_remote.*
|
|||||||
homeassistant.components.anel_pwrctrl.*
|
homeassistant.components.anel_pwrctrl.*
|
||||||
homeassistant.components.anova.*
|
homeassistant.components.anova.*
|
||||||
homeassistant.components.anthemav.*
|
homeassistant.components.anthemav.*
|
||||||
|
homeassistant.components.anthropic.*
|
||||||
homeassistant.components.apache_kafka.*
|
homeassistant.components.apache_kafka.*
|
||||||
homeassistant.components.apcupsd.*
|
homeassistant.components.apcupsd.*
|
||||||
homeassistant.components.api.*
|
homeassistant.components.api.*
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: AnthropicConfigEntry) ->
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
async def async_unload_entry(hass: HomeAssistant, entry: AnthropicConfigEntry) -> bool:
|
||||||
"""Unload Anthropic."""
|
"""Unload Anthropic."""
|
||||||
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||||
|
|
||||||
@@ -105,7 +105,7 @@ async def async_migrate_integration(hass: HomeAssistant) -> None:
|
|||||||
if not any(entry.version == 1 for entry in entries):
|
if not any(entry.version == 1 for entry in entries):
|
||||||
return
|
return
|
||||||
|
|
||||||
api_keys_entries: dict[str, tuple[ConfigEntry, bool]] = {}
|
api_keys_entries: dict[str, tuple[AnthropicConfigEntry, bool]] = {}
|
||||||
entity_registry = er.async_get(hass)
|
entity_registry = er.async_get(hass)
|
||||||
device_registry = dr.async_get(hass)
|
device_registry = dr.async_get(hass)
|
||||||
|
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from json import JSONDecodeError
|
from json import JSONDecodeError
|
||||||
import logging
|
import logging
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from homeassistant.components import ai_task, conversation
|
from homeassistant.components import ai_task, conversation
|
||||||
from homeassistant.config_entries import ConfigEntry
|
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||||
@@ -14,12 +14,15 @@ from homeassistant.util.json import json_loads
|
|||||||
|
|
||||||
from .entity import AnthropicBaseLLMEntity
|
from .entity import AnthropicBaseLLMEntity
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from . import AnthropicConfigEntry
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
config_entry: ConfigEntry,
|
config_entry: AnthropicConfigEntry,
|
||||||
async_add_entities: AddConfigEntryEntitiesCallback,
|
async_add_entities: AddConfigEntryEntitiesCallback,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up AI Task entities."""
|
"""Set up AI Task entities."""
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ from __future__ import annotations
|
|||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
from typing import Any, cast
|
from typing import TYPE_CHECKING, Any, cast
|
||||||
|
|
||||||
import anthropic
|
import anthropic
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
@@ -13,7 +13,6 @@ from voluptuous_openapi import convert
|
|||||||
|
|
||||||
from homeassistant.components.zone import ENTITY_ID_HOME
|
from homeassistant.components.zone import ENTITY_ID_HOME
|
||||||
from homeassistant.config_entries import (
|
from homeassistant.config_entries import (
|
||||||
ConfigEntry,
|
|
||||||
ConfigEntryState,
|
ConfigEntryState,
|
||||||
ConfigFlow,
|
ConfigFlow,
|
||||||
ConfigFlowResult,
|
ConfigFlowResult,
|
||||||
@@ -65,6 +64,9 @@ from .const import (
|
|||||||
WEB_SEARCH_UNSUPPORTED_MODELS,
|
WEB_SEARCH_UNSUPPORTED_MODELS,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from . import AnthropicConfigEntry
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
STEP_USER_DATA_SCHEMA = vol.Schema(
|
STEP_USER_DATA_SCHEMA = vol.Schema(
|
||||||
@@ -188,7 +190,7 @@ class AnthropicConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
@classmethod
|
@classmethod
|
||||||
@callback
|
@callback
|
||||||
def async_get_supported_subentry_types(
|
def async_get_supported_subentry_types(
|
||||||
cls, config_entry: ConfigEntry
|
cls, config_entry: AnthropicConfigEntry
|
||||||
) -> dict[str, type[ConfigSubentryFlow]]:
|
) -> dict[str, type[ConfigSubentryFlow]]:
|
||||||
"""Return subentries supported by this integration."""
|
"""Return subentries supported by this integration."""
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -3,13 +3,13 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import Iterator
|
from collections.abc import Iterator
|
||||||
from typing import cast
|
from typing import TYPE_CHECKING, cast
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant import data_entry_flow
|
from homeassistant import data_entry_flow
|
||||||
from homeassistant.components.repairs import RepairsFlow
|
from homeassistant.components.repairs import RepairsFlow
|
||||||
from homeassistant.config_entries import ConfigEntry, ConfigEntryState, ConfigSubentry
|
from homeassistant.config_entries import ConfigEntryState, ConfigSubentry
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
from homeassistant.helpers.selector import SelectSelector, SelectSelectorConfig
|
from homeassistant.helpers.selector import SelectSelector, SelectSelectorConfig
|
||||||
@@ -23,6 +23,9 @@ from .const import (
|
|||||||
DOMAIN,
|
DOMAIN,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from . import AnthropicConfigEntry
|
||||||
|
|
||||||
|
|
||||||
class ModelDeprecatedRepairFlow(RepairsFlow):
|
class ModelDeprecatedRepairFlow(RepairsFlow):
|
||||||
"""Handler for an issue fixing flow."""
|
"""Handler for an issue fixing flow."""
|
||||||
@@ -110,7 +113,7 @@ class ModelDeprecatedRepairFlow(RepairsFlow):
|
|||||||
|
|
||||||
async def _async_next_target(
|
async def _async_next_target(
|
||||||
self,
|
self,
|
||||||
) -> tuple[ConfigEntry, ConfigSubentry, str] | None:
|
) -> tuple[AnthropicConfigEntry, ConfigSubentry, str] | None:
|
||||||
"""Return the next deprecated subentry target."""
|
"""Return the next deprecated subentry target."""
|
||||||
if self._subentry_iter is None:
|
if self._subentry_iter is None:
|
||||||
self._subentry_iter = self._iter_deprecated_subentries()
|
self._subentry_iter = self._iter_deprecated_subentries()
|
||||||
|
|||||||
10
mypy.ini
generated
10
mypy.ini
generated
@@ -595,6 +595,16 @@ disallow_untyped_defs = true
|
|||||||
warn_return_any = true
|
warn_return_any = true
|
||||||
warn_unreachable = true
|
warn_unreachable = true
|
||||||
|
|
||||||
|
[mypy-homeassistant.components.anthropic.*]
|
||||||
|
check_untyped_defs = true
|
||||||
|
disallow_incomplete_defs = true
|
||||||
|
disallow_subclassing_any = true
|
||||||
|
disallow_untyped_calls = true
|
||||||
|
disallow_untyped_decorators = true
|
||||||
|
disallow_untyped_defs = true
|
||||||
|
warn_return_any = true
|
||||||
|
warn_unreachable = true
|
||||||
|
|
||||||
[mypy-homeassistant.components.apache_kafka.*]
|
[mypy-homeassistant.components.apache_kafka.*]
|
||||||
check_untyped_defs = true
|
check_untyped_defs = true
|
||||||
disallow_incomplete_defs = true
|
disallow_incomplete_defs = true
|
||||||
|
|||||||
Reference in New Issue
Block a user