Skip to content

Commit

Permalink
Merge pull request #702 from jfly/issue-682
Browse files Browse the repository at this point in the history
Don't log a warning when the `backend` config section is missing
  • Loading branch information
jaraco authored Dec 25, 2024
2 parents edaa964 + bf80b69 commit 21680c6
Show file tree
Hide file tree
Showing 3 changed files with 8 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
1 change: 1 addition & 0 deletions newsfragments/682.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Avoid logging a warning when config does not specify a backend.
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 21680c6

Please sign in to comment.