1
mirror of https://github.com/home-assistant/core synced 2024-09-12 15:16:21 +02:00

Drop unused logger argument for StorageCollection() (#90913)

This commit is contained in:
Erik Montnemery 2023-04-06 13:28:34 +02:00 committed by GitHub
parent 3d426e1e2b
commit fa308d8e10
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 18 additions and 32 deletions

View File

@ -144,7 +144,6 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
id_manager = collection.IDManager()
storage_collection = ApplicationCredentialsStorageCollection(
Store(hass, STORAGE_VERSION, STORAGE_KEY),
logging.getLogger(f"{__name__}.storage_collection"),
id_manager,
)
await storage_collection.async_load()

View File

@ -106,7 +106,6 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
storage_collection = CounterStorageCollection(
Store(hass, STORAGE_VERSION, STORAGE_KEY),
logging.getLogger(f"{__name__}.storage_collection"),
id_manager,
)
collection.sync_entity_lifecycle(

View File

@ -67,7 +67,6 @@ class ImageStorageCollection(collection.StorageCollection):
"""Initialize media storage collection."""
super().__init__(
Store(hass, STORAGE_VERSION, STORAGE_KEY),
logging.getLogger(f"{__name__}.storage_collection"),
)
self.async_add_listener(self._change_listener)
self.image_dir = image_dir

View File

@ -110,7 +110,6 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
storage_collection = InputBooleanStorageCollection(
Store(hass, STORAGE_VERSION, STORAGE_KEY),
logging.getLogger(f"{__name__}.storage_collection"),
id_manager,
)
collection.sync_entity_lifecycle(

View File

@ -95,7 +95,6 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
storage_collection = InputButtonStorageCollection(
Store(hass, STORAGE_VERSION, STORAGE_KEY),
logging.getLogger(f"{__name__}.storage_collection"),
id_manager,
)
collection.sync_entity_lifecycle(

View File

@ -148,7 +148,6 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
storage_collection = DateTimeStorageCollection(
Store(hass, STORAGE_VERSION, STORAGE_KEY),
logging.getLogger(f"{__name__}.storage_collection"),
id_manager,
)
collection.sync_entity_lifecycle(

View File

@ -125,7 +125,6 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
storage_collection = NumberStorageCollection(
Store(hass, STORAGE_VERSION, STORAGE_KEY),
logging.getLogger(f"{__name__}.storage_collection"),
id_manager,
)
collection.sync_entity_lifecycle(

View File

@ -156,7 +156,6 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
InputSelectStore(
hass, STORAGE_VERSION, STORAGE_KEY, minor_version=STORAGE_VERSION_MINOR
),
logging.getLogger(f"{__name__}.storage_collection"),
id_manager,
)
collection.sync_entity_lifecycle(

View File

@ -125,7 +125,6 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
storage_collection = InputTextStorageCollection(
Store(hass, STORAGE_VERSION, STORAGE_KEY),
logging.getLogger(f"{__name__}.storage_collection"),
id_manager,
)
collection.sync_entity_lifecycle(

View File

@ -228,7 +228,6 @@ class DashboardsCollection(collection.StorageCollection):
"""Initialize the dashboards collection."""
super().__init__(
storage.Store(hass, DASHBOARDS_STORAGE_VERSION, DASHBOARDS_STORAGE_KEY),
_LOGGER,
)
async def _async_load_data(self) -> dict | None:

View File

@ -56,7 +56,6 @@ class ResourceStorageCollection(collection.StorageCollection):
"""Initialize the storage collection."""
super().__init__(
storage.Store(hass, RESOURCES_STORAGE_VERSION, RESOURCE_STORAGE_KEY),
_LOGGER,
)
self.ll_config = ll_config

View File

@ -197,12 +197,11 @@ class PersonStorageCollection(collection.StorageCollection):
def __init__(
self,
store: Store,
logger: logging.Logger,
id_manager: collection.IDManager,
yaml_collection: collection.YamlCollection,
) -> None:
"""Initialize a person storage collection."""
super().__init__(store, logger, id_manager)
super().__init__(store, id_manager)
self.yaml_collection = yaml_collection
async def _async_load_data(self) -> dict | None:
@ -337,7 +336,6 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
)
storage_collection = PersonStorageCollection(
PersonStore(hass, STORAGE_VERSION, STORAGE_KEY),
logging.getLogger(f"{__name__}.storage_collection"),
id_manager,
yaml_collection,
)

View File

@ -4,7 +4,6 @@ from __future__ import annotations
from collections.abc import Callable
from datetime import datetime, time, timedelta
import itertools
import logging
from typing import Any, Literal
import voluptuous as vol
@ -173,7 +172,6 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
version=STORAGE_VERSION,
minor_version=STORAGE_VERSION_MINOR,
),
logging.getLogger(f"{__name__}.storage_collection"),
id_manager,
)
sync_entity_lifecycle(hass, DOMAIN, DOMAIN, component, storage_collection, Schedule)

View File

@ -95,7 +95,6 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
id_manager = TagIDManager()
hass.data[DOMAIN][TAGS] = storage_collection = TagStorageCollection(
Store(hass, STORAGE_VERSION, STORAGE_KEY),
logging.getLogger(f"{__name__}.storage_collection"),
id_manager,
)
await storage_collection.async_load()

View File

@ -119,7 +119,6 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
storage_collection = TimerStorageCollection(
Store(hass, STORAGE_VERSION, STORAGE_KEY),
logging.getLogger(f"{__name__}.storage_collection"),
id_manager,
)
collection.sync_entity_lifecycle(

View File

@ -198,7 +198,6 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
storage_collection = ZoneStorageCollection(
storage.Store(hass, STORAGE_VERSION, STORAGE_KEY),
logging.getLogger(f"{__name__}.storage_collection"),
id_manager,
)
collection.sync_entity_lifecycle(

View File

@ -124,11 +124,8 @@ class CollectionEntity(Entity):
class ObservableCollection(ABC):
"""Base collection type that can be observed."""
def __init__(
self, logger: logging.Logger, id_manager: IDManager | None = None
) -> None:
def __init__(self, id_manager: IDManager | None) -> None:
"""Initialize the base collection."""
self.logger = logger
self.id_manager = id_manager or IDManager()
self.data: dict[str, dict] = {}
self.listeners: list[ChangeListener] = []
@ -175,6 +172,15 @@ class ObservableCollection(ABC):
class YamlCollection(ObservableCollection):
"""Offer a collection based on static data."""
def __init__(
self,
logger: logging.Logger,
id_manager: IDManager | None = None,
) -> None:
"""Initialize the storage collection."""
super().__init__(id_manager)
self.logger = logger
@staticmethod
def create_entity(
entity_class: type[CollectionEntity], config: ConfigType
@ -218,11 +224,10 @@ class StorageCollection(ObservableCollection, ABC):
def __init__(
self,
store: Store,
logger: logging.Logger,
id_manager: IDManager | None = None,
) -> None:
"""Initialize the storage collection."""
super().__init__(logger, id_manager)
super().__init__(id_manager)
self.store = store
@staticmethod

View File

@ -35,7 +35,6 @@ def storage_collection(hass):
id_manager = collection.IDManager()
return person.PersonStorageCollection(
person.PersonStore(hass, person.STORAGE_VERSION, person.STORAGE_KEY),
logging.getLogger(f"{person.__name__}.storage_collection"),
id_manager,
collection.YamlCollection(
logging.getLogger(f"{person.__name__}.yaml_collection"), id_manager

View File

@ -116,7 +116,7 @@ def test_id_manager() -> None:
async def test_observable_collection() -> None:
"""Test observerable collection."""
coll = collection.ObservableCollection(_LOGGER)
coll = collection.ObservableCollection(None)
assert coll.async_items() == []
coll.data["bla"] = 1
assert coll.async_items() == [1]
@ -202,7 +202,7 @@ async def test_storage_collection(hass: HomeAssistant) -> None:
}
)
id_manager = collection.IDManager()
coll = MockStorageCollection(store, _LOGGER, id_manager)
coll = MockStorageCollection(store, id_manager)
changes = track_changes(coll)
await coll.async_load()
@ -257,7 +257,7 @@ async def test_attach_entity_component_collection(hass: HomeAssistant) -> None:
"""Test attaching collection to entity component."""
ent_comp = entity_component.EntityComponent(_LOGGER, "test", hass)
await ent_comp.async_setup({})
coll = MockObservableCollection(_LOGGER)
coll = MockObservableCollection(None)
collection.sync_entity_lifecycle(hass, "test", "test", ent_comp, coll, MockEntity)
await coll.notify_changes(
@ -297,7 +297,7 @@ async def test_entity_component_collection_abort(hass: HomeAssistant) -> None:
"""Test aborted entity adding is handled."""
ent_comp = entity_component.EntityComponent(_LOGGER, "test", hass)
await ent_comp.async_setup({})
coll = MockObservableCollection(_LOGGER)
coll = MockObservableCollection(None)
async_update_config_calls = []
async_remove_calls = []
@ -364,7 +364,7 @@ async def test_entity_component_collection_entity_removed(hass: HomeAssistant) -
"""Test entity removal is handled."""
ent_comp = entity_component.EntityComponent(_LOGGER, "test", hass)
await ent_comp.async_setup({})
coll = MockObservableCollection(_LOGGER)
coll = MockObservableCollection(None)
async_update_config_calls = []
async_remove_calls = []
@ -434,7 +434,7 @@ async def test_storage_collection_websocket(
) -> None:
"""Test exposing a storage collection via websockets."""
store = storage.Store(hass, 1, "test-data")
coll = MockStorageCollection(store, _LOGGER)
coll = MockStorageCollection(store)
changes = track_changes(coll)
collection.StorageCollectionWebsocket(
coll,