Merge of nested IF-IF cases - Core (#48364)
This commit is contained in:
parent
ad13a9295e
commit
45f77ccccf
4 changed files with 16 additions and 25 deletions
|
@ -77,17 +77,11 @@ class InsecureExampleModule(MultiFactorAuthModule):
|
||||||
|
|
||||||
async def async_is_user_setup(self, user_id: str) -> bool:
|
async def async_is_user_setup(self, user_id: str) -> bool:
|
||||||
"""Return whether user is setup."""
|
"""Return whether user is setup."""
|
||||||
for data in self._data:
|
return any(data["user_id"] == user_id for data in self._data)
|
||||||
if data["user_id"] == user_id:
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
async def async_validate(self, user_id: str, user_input: dict[str, Any]) -> bool:
|
async def async_validate(self, user_id: str, user_input: dict[str, Any]) -> bool:
|
||||||
"""Return True if validation passed."""
|
"""Return True if validation passed."""
|
||||||
for data in self._data:
|
return any(
|
||||||
if data["user_id"] == user_id:
|
data["user_id"] == user_id and data["pin"] == user_input["pin"]
|
||||||
# user_input has been validate in caller
|
for data in self._data
|
||||||
if data["pin"] == user_input["pin"]:
|
)
|
||||||
return True
|
|
||||||
|
|
||||||
return False
|
|
||||||
|
|
|
@ -134,11 +134,8 @@ class AreaRegistry:
|
||||||
|
|
||||||
normalized_name = normalize_area_name(name)
|
normalized_name = normalize_area_name(name)
|
||||||
|
|
||||||
if normalized_name != old.normalized_name:
|
if normalized_name != old.normalized_name and self.async_get_area_by_name(name):
|
||||||
if self.async_get_area_by_name(name):
|
raise ValueError(f"The name {name} ({normalized_name}) is already in use")
|
||||||
raise ValueError(
|
|
||||||
f"The name {name} ({normalized_name}) is already in use"
|
|
||||||
)
|
|
||||||
|
|
||||||
changes["name"] = name
|
changes["name"] = name
|
||||||
changes["normalized_name"] = normalized_name
|
changes["normalized_name"] = normalized_name
|
||||||
|
|
|
@ -315,10 +315,11 @@ async def async_prepare_setup_platform(
|
||||||
log_error(f"Unable to import the component ({exc}).")
|
log_error(f"Unable to import the component ({exc}).")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if hasattr(component, "setup") or hasattr(component, "async_setup"):
|
if (
|
||||||
if not await async_setup_component(hass, integration.domain, hass_config):
|
hasattr(component, "setup") or hasattr(component, "async_setup")
|
||||||
log_error("Unable to set up component.")
|
) and not await async_setup_component(hass, integration.domain, hass_config):
|
||||||
return None
|
log_error("Unable to set up component.")
|
||||||
|
return None
|
||||||
|
|
||||||
return platform
|
return platform
|
||||||
|
|
||||||
|
|
|
@ -261,11 +261,10 @@ def color_xy_brightness_to_RGB(
|
||||||
vX: float, vY: float, ibrightness: int, Gamut: GamutType | None = None
|
vX: float, vY: float, ibrightness: int, Gamut: GamutType | None = None
|
||||||
) -> tuple[int, int, int]:
|
) -> tuple[int, int, int]:
|
||||||
"""Convert from XYZ to RGB."""
|
"""Convert from XYZ to RGB."""
|
||||||
if Gamut:
|
if Gamut and not check_point_in_lamps_reach((vX, vY), Gamut):
|
||||||
if not check_point_in_lamps_reach((vX, vY), Gamut):
|
xy_closest = get_closest_point_to_point((vX, vY), Gamut)
|
||||||
xy_closest = get_closest_point_to_point((vX, vY), Gamut)
|
vX = xy_closest[0]
|
||||||
vX = xy_closest[0]
|
vY = xy_closest[1]
|
||||||
vY = xy_closest[1]
|
|
||||||
|
|
||||||
brightness = ibrightness / 255.0
|
brightness = ibrightness / 255.0
|
||||||
if brightness == 0.0:
|
if brightness == 0.0:
|
||||||
|
|
Loading…
Add table
Reference in a new issue