From 4a8b5ae61eb0319271fd39e8a5f45bd22f4d6cfa Mon Sep 17 00:00:00 2001 From: Konstantinos Karmas Date: Mon, 21 Jun 2021 17:07:36 +0200 Subject: [PATCH] Fix mypy issue CURA-8332 --- cura/OAuth2/KeyringAttribute.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/cura/OAuth2/KeyringAttribute.py b/cura/OAuth2/KeyringAttribute.py index 817bf9396d..5fc508a4a6 100644 --- a/cura/OAuth2/KeyringAttribute.py +++ b/cura/OAuth2/KeyringAttribute.py @@ -14,17 +14,24 @@ if TYPE_CHECKING: # Need to do some extra workarounds on windows: import sys from UM.Platform import Platform + + +class _KeychainDenied(Exception): + pass + + if Platform.isWindows() and hasattr(sys, "frozen"): import win32timezone from keyring.backends.Windows import WinVaultKeyring keyring.set_keyring(WinVaultKeyring()) if Platform.isOSX() and hasattr(sys, "frozen"): from keyring.backends.macOS import Keyring - from keyring.backends.macOS.api import KeychainDenied + from keyring.backends.macOS.api import KeychainDenied as _KeychainDeniedMacOS + KeychainDenied = _KeychainDeniedMacOS keyring.set_keyring(Keyring()) else: - class KeychainDenied(Exception): - pass + KeychainDenied = _KeychainDenied + # Even if errors happen, we don't want this stored locally: DONT_EVER_STORE_LOCALLY: List[str] = ["refresh_token"]