Add type ignore error codes [auth] (#66774)
parent
ec67dcb620
commit
1ad023a63f
|
@ -354,7 +354,7 @@ class AuthManager:
|
|||
|
||||
if provider is not None and hasattr(provider, "async_will_remove_credentials"):
|
||||
# https://github.com/python/mypy/issues/1424
|
||||
await provider.async_will_remove_credentials(credentials) # type: ignore
|
||||
await provider.async_will_remove_credentials(credentials) # type: ignore[attr-defined]
|
||||
|
||||
await self._store.async_remove_credentials(credentials)
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ class MultiFactorAuthModule:
|
|||
@property
|
||||
def type(self) -> str:
|
||||
"""Return type of the module."""
|
||||
return self.config[CONF_TYPE] # type: ignore
|
||||
return self.config[CONF_TYPE] # type: ignore[no-any-return]
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
|
@ -142,7 +142,7 @@ async def auth_mfa_module_from_config(
|
|||
)
|
||||
raise
|
||||
|
||||
return MULTI_FACTOR_AUTH_MODULES[module_name](hass, config) # type: ignore
|
||||
return MULTI_FACTOR_AUTH_MODULES[module_name](hass, config) # type: ignore[no-any-return]
|
||||
|
||||
|
||||
async def _load_mfa_module(hass: HomeAssistant, module_name: str) -> types.ModuleType:
|
||||
|
|
|
@ -251,7 +251,7 @@ class NotifyAuthModule(MultiFactorAuthModule):
|
|||
|
||||
await self.async_notify(
|
||||
code,
|
||||
notify_setting.notify_service, # type: ignore
|
||||
notify_setting.notify_service, # type: ignore[arg-type]
|
||||
notify_setting.target,
|
||||
)
|
||||
|
||||
|
|
|
@ -107,7 +107,7 @@ class TotpAuthModule(MultiFactorAuthModule):
|
|||
|
||||
ota_secret: str = secret or pyotp.random_base32()
|
||||
|
||||
self._users[user_id] = ota_secret # type: ignore
|
||||
self._users[user_id] = ota_secret # type: ignore[index]
|
||||
return ota_secret
|
||||
|
||||
async def async_setup_flow(self, user_id: str) -> SetupFlow:
|
||||
|
@ -136,7 +136,7 @@ class TotpAuthModule(MultiFactorAuthModule):
|
|||
if self._users is None:
|
||||
await self._async_load()
|
||||
|
||||
if self._users.pop(user_id, None): # type: ignore
|
||||
if self._users.pop(user_id, None): # type: ignore[union-attr]
|
||||
await self._async_save()
|
||||
|
||||
async def async_is_user_setup(self, user_id: str) -> bool:
|
||||
|
@ -144,7 +144,7 @@ class TotpAuthModule(MultiFactorAuthModule):
|
|||
if self._users is None:
|
||||
await self._async_load()
|
||||
|
||||
return user_id in self._users # type: ignore
|
||||
return user_id in self._users # type: ignore[operator]
|
||||
|
||||
async def async_validate(self, user_id: str, user_input: dict[str, Any]) -> bool:
|
||||
"""Return True if validation passed."""
|
||||
|
@ -161,7 +161,7 @@ class TotpAuthModule(MultiFactorAuthModule):
|
|||
"""Validate two factor authentication code."""
|
||||
import pyotp # pylint: disable=import-outside-toplevel
|
||||
|
||||
if (ota_secret := self._users.get(user_id)) is None: # type: ignore
|
||||
if (ota_secret := self._users.get(user_id)) is None: # type: ignore[union-attr]
|
||||
# even we cannot find user, we still do verify
|
||||
# to make timing the same as if user was found.
|
||||
pyotp.TOTP(DUMMY_SECRET).verify(code, valid_window=1)
|
||||
|
|
|
@ -62,7 +62,7 @@ class AuthProvider:
|
|||
@property
|
||||
def type(self) -> str:
|
||||
"""Return type of the provider."""
|
||||
return self.config[CONF_TYPE] # type: ignore
|
||||
return self.config[CONF_TYPE] # type: ignore[no-any-return]
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
|
@ -149,7 +149,7 @@ async def auth_provider_from_config(
|
|||
)
|
||||
raise
|
||||
|
||||
return AUTH_PROVIDERS[provider_name](hass, store, config) # type: ignore
|
||||
return AUTH_PROVIDERS[provider_name](hass, store, config) # type: ignore[no-any-return]
|
||||
|
||||
|
||||
async def load_auth_provider_module(
|
||||
|
@ -250,7 +250,7 @@ class LoginFlow(data_entry_flow.FlowHandler):
|
|||
auth_module, "async_initialize_login_mfa_step"
|
||||
):
|
||||
try:
|
||||
await auth_module.async_initialize_login_mfa_step( # type: ignore
|
||||
await auth_module.async_initialize_login_mfa_step( # type: ignore[attr-defined]
|
||||
self.user.id
|
||||
)
|
||||
except HomeAssistantError:
|
||||
|
|
|
@ -120,7 +120,7 @@ class Data:
|
|||
@property
|
||||
def users(self) -> list[dict[str, str]]:
|
||||
"""Return users."""
|
||||
return self._data["users"] # type: ignore
|
||||
return self._data["users"] # type: ignore[index,no-any-return]
|
||||
|
||||
def validate_login(self, username: str, password: str) -> None:
|
||||
"""Validate a username and password.
|
||||
|
|
Loading…
Reference in New Issue