Skip to content

Commit 428d99e

Browse files
committed
remove try/except blocks that swallowed errors in auth
1 parent a8975a0 commit 428d99e

1 file changed

Lines changed: 8 additions & 17 deletions

File tree

src/redfetch/auth.py

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from keyring.errors import NoKeyringError
2323

2424
# Local
25+
from redfetch import config
2526
from redfetch import net
2627

2728
# Constants
@@ -38,21 +39,15 @@
3839

3940

4041
def _get_setting(key: str, default=None):
41-
"""Get a setting from env first, then Dynaconf (if initialized)."""
42+
"""Get a setting from env first, then initialized Dynaconf settings."""
4243
env_key = f"REDFETCH_{key}"
4344
env_val = os.environ.get(env_key)
4445
if env_val not in (None, ""):
4546
return env_val
4647

47-
try:
48-
from redfetch import config
49-
50-
settings = getattr(config, "settings", None)
51-
if settings is not None:
52-
val = settings.get(key, default)
53-
return default if val in ("", None) else val
54-
except Exception:
55-
pass
48+
if config.settings is not None:
49+
val = config.settings.get(key, default)
50+
return default if val in ("", None) else val
5651

5752
return default
5853

@@ -391,12 +386,8 @@ def initialize_keyring():
391386

392387
if __name__ == "__main__":
393388
initialize_keyring()
394-
# Initialize config lazily if invoked directly, so this can be used as a standalone script.
395-
try:
396-
from redfetch import config
397-
398-
if getattr(config, "settings", None) is None:
389+
if not os.environ.get("REDGUIDES_API_KEY"):
390+
# Initialize config lazily if invoked directly, so this can be used as a standalone script.
391+
if config.settings is None:
399392
config.initialize_config()
400-
except Exception:
401-
pass
402393
authorize()

0 commit comments

Comments
 (0)