Cleanup ServiceInfo compatibility (#60540)
Co-authored-by: epenet <epenet@users.noreply.github.com> Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
parent
ddd22398f2
commit
141688e210
10 changed files with 1 additions and 412 deletions
|
@ -30,7 +30,6 @@ from homeassistant.core import Event, HomeAssistant, callback
|
|||
from homeassistant.data_entry_flow import BaseServiceInfo
|
||||
from homeassistant.helpers import discovery_flow
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.frame import report
|
||||
from homeassistant.helpers.network import NoURLAvailableError, get_url
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
from homeassistant.loader import (
|
||||
|
@ -108,36 +107,6 @@ class ZeroconfServiceInfo(BaseServiceInfo):
|
|||
name: str
|
||||
properties: dict[str, Any]
|
||||
|
||||
def __getitem__(self, name: str) -> Any:
|
||||
"""
|
||||
Enable method for compatibility reason.
|
||||
|
||||
Deprecated, and will be removed in version 2022.6.
|
||||
"""
|
||||
report(
|
||||
f"accessed discovery_info['{name}'] instead of discovery_info.{name}; "
|
||||
"this will fail in version 2022.6",
|
||||
exclude_integrations={DOMAIN},
|
||||
error_if_core=False,
|
||||
)
|
||||
return getattr(self, name)
|
||||
|
||||
def get(self, name: str, default: Any = None) -> Any:
|
||||
"""
|
||||
Enable method for compatibility reason.
|
||||
|
||||
Deprecated, and will be removed in version 2022.6.
|
||||
"""
|
||||
report(
|
||||
f"accessed discovery_info.get('{name}') instead of discovery_info.{name}; "
|
||||
"this will fail in version 2022.6",
|
||||
exclude_integrations={DOMAIN},
|
||||
error_if_core=False,
|
||||
)
|
||||
if hasattr(self, name):
|
||||
return getattr(self, name)
|
||||
return default
|
||||
|
||||
|
||||
@bind_hass
|
||||
async def async_get_instance(hass: HomeAssistant) -> HaZeroconf:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue