Merge of nested IF-IF cases - Core (#48364)

This commit is contained in:
Franck Nijhof
2021-03-27 09:23:32 +01:00
committed by GitHub
parent ad13a9295e
commit 45f77ccccf
4 changed files with 16 additions and 25 deletions

View File

@@ -77,17 +77,11 @@ class InsecureExampleModule(MultiFactorAuthModule):
async def async_is_user_setup(self, user_id: str) -> bool:
"""Return whether user is setup."""
for data in self._data:
if data["user_id"] == user_id:
return True
return False
return any(data["user_id"] == user_id for data in self._data)
async def async_validate(self, user_id: str, user_input: dict[str, Any]) -> bool:
"""Return True if validation passed."""
for data in self._data:
if data["user_id"] == user_id:
# user_input has been validate in caller
if data["pin"] == user_input["pin"]:
return True
return False
return any(
data["user_id"] == user_id and data["pin"] == user_input["pin"]
for data in self._data
)