diff --git a/homeassistant/auth/__init__.py b/homeassistant/auth/__init__.py index b98dc07deb6..b3f57656dd7 100644 --- a/homeassistant/auth/__init__.py +++ b/homeassistant/auth/__init__.py @@ -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) diff --git a/homeassistant/auth/mfa_modules/__init__.py b/homeassistant/auth/mfa_modules/__init__.py index 60f790fa490..bb81d1fb04f 100644 --- a/homeassistant/auth/mfa_modules/__init__.py +++ b/homeassistant/auth/mfa_modules/__init__.py @@ -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: diff --git a/homeassistant/auth/mfa_modules/notify.py b/homeassistant/auth/mfa_modules/notify.py index 71fdbadbb90..37b35a5087d 100644 --- a/homeassistant/auth/mfa_modules/notify.py +++ b/homeassistant/auth/mfa_modules/notify.py @@ -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, ) diff --git a/homeassistant/auth/mfa_modules/totp.py b/homeassistant/auth/mfa_modules/totp.py index a88aa19d742..bb5fc47469f 100644 --- a/homeassistant/auth/mfa_modules/totp.py +++ b/homeassistant/auth/mfa_modules/totp.py @@ -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) diff --git a/homeassistant/auth/providers/__init__.py b/homeassistant/auth/providers/__init__.py index b209f6b2f05..d80d7a5273b 100644 --- a/homeassistant/auth/providers/__init__.py +++ b/homeassistant/auth/providers/__init__.py @@ -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: diff --git a/homeassistant/auth/providers/homeassistant.py b/homeassistant/auth/providers/homeassistant.py index 4fb12e3e764..a4797dd8c10 100644 --- a/homeassistant/auth/providers/homeassistant.py +++ b/homeassistant/auth/providers/homeassistant.py @@ -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.