init home-assistant

This commit is contained in:
2026-11-19 15:15:32 -05:00
parent 2e81d9d300
commit feec6ef9fb
19230 changed files with 3335526 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
"""Patch recorder related functions."""
from __future__ import annotations
from contextlib import contextmanager
import sys
# Patch recorder util session scope
from homeassistant.helpers import recorder as recorder_helper # noqa: E402
# Make sure homeassistant.components.recorder.util is not already imported
assert "homeassistant.components.recorder.util" not in sys.modules
real_session_scope = recorder_helper.session_scope
@contextmanager
def _session_scope_wrapper(*args, **kwargs):
"""Make session_scope patchable.
This function will be imported by recorder modules.
"""
with real_session_scope(*args, **kwargs) as ses:
yield ses
recorder_helper.session_scope = _session_scope_wrapper