Skip to content

Commit

Permalink
Don't log a warning when the backend config section is missing
Browse files Browse the repository at this point in the history
This config file is used by third party keyring backends, and setting
one of *their* settings shouldn't give you a warning encouraging you to set `backend`
setting.

This fixes #682
  • Loading branch information
jfly committed Nov 10, 2024
1 parent edaa964 commit 1526c17
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion keyring/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def load_config() -> typing.Optional[backend.KeyringBackend]:
if config.has_section("backend"):
keyring_name = config.get("backend", "default-keyring").strip()
else:
raise configparser.NoOptionError('backend', 'default-keyring')
return None

except (configparser.NoOptionError, ImportError):
logger = logging.getLogger('keyring')
Expand Down
6 changes: 6 additions & 0 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ def test_load_config_missing(caplog, config_path):
assert not caplog.records


def test_load_empty_config(caplog, config_path):
config_path.write_text("", encoding='utf-8')
assert keyring.core.load_config() is None
assert not caplog.records


fail_config = textwrap.dedent(
"""
[backend]
Expand Down

0 comments on commit 1526c17

Please sign in to comment.