Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jaraco/keyring
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v24.0.1
Choose a base ref
...
head repository: jaraco/keyring
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v24.1.0
Choose a head ref
  • 5 commits
  • 5 files changed
  • 1 contributor

Commits on Jun 23, 2023

  1. Copy the full SHA
    0987ce2 View commit details
  2. Copy the full SHA
    560eca8 View commit details
  3. Copy the full SHA
    c1e291b View commit details
  4. Copy the full SHA
    2a91891 View commit details
  5. Finalize

    jaraco committed Jun 23, 2023
    Copy the full SHA
    da2a98b View commit details
Showing with 31 additions and 4 deletions.
  1. +16 −0 NEWS.rst
  2. +1 −1 README.rst
  3. +3 −2 keyring/cli.py
  4. +6 −1 keyring/core.py
  5. +5 −0 tests/test_core.py
16 changes: 16 additions & 0 deletions NEWS.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
v24.1.0
=======

Bugfixes
--------

- Avoid logging warning when no config file is present. (#635)
- Include all operations in the error message if no operation was supplied. (#636)


Improved Documentation
----------------------

- Correct name of macOS backend in README. (#637)


v24.0.1
=======

2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
@@ -153,7 +153,7 @@ Config file content

To specify a keyring backend, set the **default-keyring** option to the
full path of the class for that backend, such as
``keyring.backends.OS_X.Keyring``.
``keyring.backends.macOS.Keyring``.

If **keyring-path** is indicated, keyring will add that path to the Python
module search path before loading the backend.
5 changes: 3 additions & 2 deletions keyring/cli.py
Original file line number Diff line number Diff line change
@@ -37,9 +37,10 @@ def __init__(self):
self.parser.add_argument(
"--disable", action="store_true", help="Disable keyring and exit"
)
self.parser._operations = ["get", "set", "del", "diagnose"]
self.parser.add_argument(
'operation',
choices=["get", "set", "del", "diagnose"],
choices=self.parser._operations,
nargs="?",
)
self.parser.add_argument(
@@ -103,7 +104,7 @@ def diagnose(self):
print("data root:", platform_.data_root())

def invalid_op(self):
self.parser.error("Specify operation 'get', 'del', or 'set'.")
self.parser.error(f"Specify operation ({', '.join(self.parser._operations)}).")

def _load_spec_backend(self):
if self.keyring_backend is None:
7 changes: 6 additions & 1 deletion keyring/core.py
Original file line number Diff line number Diff line change
@@ -150,12 +150,17 @@ def _config_path():
return platform.config_root() / 'keyringrc.cfg'


def _ensure_path(path):
if not path.exists():
raise FileNotFoundError(path)


def load_config() -> typing.Optional[backend.KeyringBackend]:
"""Load a keyring using the config file in the config root."""

config = configparser.RawConfigParser()
try:
config.read(_config_path(), encoding='utf-8')
config.read(_ensure_path(_config_path()), encoding='utf-8')
except FileNotFoundError:
return None
_load_keyring_path(config)
5 changes: 5 additions & 0 deletions tests/test_core.py
Original file line number Diff line number Diff line change
@@ -7,3 +7,8 @@ def test_init_recommended(monkeypatch):
"""
monkeypatch.setattr(keyring.core, 'set_keyring', lambda kr: None)
keyring.core.init_backend(keyring.core.recommended)


def test_load_config_missing(caplog):
assert keyring.core.load_config() is None
assert not caplog.records