diff --git a/homeassistant/components/aussie_broadband/__init__.py b/homeassistant/components/aussie_broadband/__init__.py index 1bdb0579976..6fc4a4dd4d1 100644 --- a/homeassistant/components/aussie_broadband/__init__.py +++ b/homeassistant/components/aussie_broadband/__init__.py @@ -3,11 +3,10 @@ from __future__ import annotations from datetime import timedelta import logging -from typing import Any from aiohttp import ClientError from aussiebb.asyncio import AussieBB -from aussiebb.const import FETCH_TYPES, NBN_TYPES, PHONE_TYPES +from aussiebb.const import FETCH_TYPES from aussiebb.exceptions import AuthenticationException, UnrecognisedServiceType from homeassistant.config_entries import ConfigEntry @@ -23,19 +22,6 @@ _LOGGER = logging.getLogger(__name__) PLATFORMS = [Platform.SENSOR] -# Backport for the pyaussiebb=0.0.15 validate_service_type method -def validate_service_type(service: dict[str, Any]) -> None: - """Check the service types against known types.""" - - if "type" not in service: - raise ValueError("Field 'type' not found in service data") - if service["type"] not in NBN_TYPES + PHONE_TYPES + ["Hardware"]: - raise UnrecognisedServiceType( - f"Service type {service['type']=} {service['name']=} - not recognised - ", - "please report this at https://github.com/yaleman/aussiebb/issues/new", - ) - - async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Set up Aussie Broadband from a config entry.""" # Login to the Aussie Broadband API and retrieve the current service list @@ -44,9 +30,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: entry.data[CONF_PASSWORD], async_get_clientsession(hass), ) - # Overwrite the pyaussiebb=0.0.15 validate_service_type method with backport - # Required until pydantic 2.x is supported - client.validate_service_type = validate_service_type + try: await client.login() services = await client.get_services(drop_types=FETCH_TYPES) diff --git a/tests/components/aussie_broadband/test_init.py b/tests/components/aussie_broadband/test_init.py index dc32212ee87..3eb1972011c 100644 --- a/tests/components/aussie_broadband/test_init.py +++ b/tests/components/aussie_broadband/test_init.py @@ -3,11 +3,8 @@ from unittest.mock import patch from aiohttp import ClientConnectionError from aussiebb.exceptions import AuthenticationException, UnrecognisedServiceType -import pydantic -import pytest from homeassistant import data_entry_flow -from homeassistant.components.aussie_broadband import validate_service_type from homeassistant.config_entries import ConfigEntryState from homeassistant.core import HomeAssistant @@ -22,19 +19,6 @@ async def test_unload(hass: HomeAssistant) -> None: assert entry.state is ConfigEntryState.NOT_LOADED -async def test_validate_service_type() -> None: - """Testing the validation function.""" - test_service = {"type": "Hardware", "name": "test service"} - validate_service_type(test_service) - - with pytest.raises(ValueError): - test_service = {"name": "test service"} - validate_service_type(test_service) - with pytest.raises(UnrecognisedServiceType): - test_service = {"type": "FunkyBob", "name": "test service"} - validate_service_type(test_service) - - async def test_auth_failure(hass: HomeAssistant) -> None: """Test init with an authentication failure.""" with patch( @@ -55,9 +39,3 @@ async def test_service_failure(hass: HomeAssistant) -> None: """Test init with a invalid service.""" entry = await setup_platform(hass, usage_effect=UnrecognisedServiceType()) assert entry.state is ConfigEntryState.SETUP_RETRY - - -async def test_not_pydantic2() -> None: - """Test that Home Assistant still does not support Pydantic 2.""" - """For PR#99077 and validate_service_type backport""" - assert pydantic.__version__ < "2"