mirror of
https://github.com/home-assistant/core.git
synced 2025-11-09 02:49:40 +00:00
Deprecate optional script context (#39034)
Co-authored-by: Phil Bruckner <pnbruckner@gmail.com>
This commit is contained in:
@@ -859,6 +859,12 @@ class Script:
|
||||
self, variables: Optional[_VarsType] = None, context: Optional[Context] = None
|
||||
) -> None:
|
||||
"""Run script."""
|
||||
if context is None:
|
||||
self._log(
|
||||
"Running script requires passing in a context", level=logging.WARNING
|
||||
)
|
||||
context = Context()
|
||||
|
||||
if self.is_running:
|
||||
if self.script_mode == SCRIPT_MODE_SINGLE:
|
||||
self._log("Already running", level=logging.WARNING)
|
||||
@@ -875,6 +881,7 @@ class Script:
|
||||
# during the run back to the caller.
|
||||
if self._top_level:
|
||||
variables = dict(variables) if variables is not None else {}
|
||||
variables["context"] = context
|
||||
|
||||
if self.script_mode != SCRIPT_MODE_QUEUED:
|
||||
cls = _ScriptRun
|
||||
|
||||
Reference in New Issue
Block a user