Enable RUF021 (#135832)

This commit is contained in:
Joost Lekkerkerker
2025-01-17 10:20:45 +01:00
committed by GitHub
parent 85b4be2f16
commit b4f4b06f29
52 changed files with 166 additions and 218 deletions

View File

@@ -239,20 +239,13 @@ def execute(
if name.startswith("async_"):
raise ScriptError("Not allowed to access async methods")
if (
obj is hass
and name not in ALLOWED_HASS
or obj is hass.bus
and name not in ALLOWED_EVENTBUS
or obj is hass.states
and name not in ALLOWED_STATEMACHINE
or obj is hass.services
and name not in ALLOWED_SERVICEREGISTRY
or obj is dt_util
and name not in ALLOWED_DT_UTIL
or obj is datetime
and name not in ALLOWED_DATETIME
or isinstance(obj, TimeWrapper)
and name not in ALLOWED_TIME
(obj is hass and name not in ALLOWED_HASS)
or (obj is hass.bus and name not in ALLOWED_EVENTBUS)
or (obj is hass.states and name not in ALLOWED_STATEMACHINE)
or (obj is hass.services and name not in ALLOWED_SERVICEREGISTRY)
or (obj is dt_util and name not in ALLOWED_DT_UTIL)
or (obj is datetime and name not in ALLOWED_DATETIME)
or (isinstance(obj, TimeWrapper) and name not in ALLOWED_TIME)
):
raise ScriptError(f"Not allowed to access {obj.__class__.__name__}.{name}")