Skip to content

Raise KeyError for missing keys in RepositoryEmpty - #192

Open
hulei22103-gif wants to merge 2 commits into
HBNetwork:masterfrom
hulei22103-gif:fix/empty-repository-keyerror
Open

hulei22103-gif wants to merge 2 commits into
HBNetwork:masterfrom
hulei22103-gif:fix/empty-repository-keyerror

Conversation

@hulei22103-gif

Copy link
Copy Markdown

RepositoryEmpty returns None for every direct lookup even though it reports every key as absent. This differs from the other repositories' missing-key behavior and can hide a missing configuration value when accessing the repository directly.

Raise KeyError(key) instead. Config still checks membership before looking up repository values, so environment lookup, explicit defaults and UndefinedValueError remain unchanged.

Fixes #175.

Tests cover missing keys and the exception's key argument, plus Config's missing-value error, None default, casted default, and empty/nonempty environment values.

Validation on Windows, Python 3.12.5:

  • New tests against the original implementation: 6 failed, 1 passed.
  • Full suite after the fix: python -m pytest -q — 74 passed.
  • git diff --check — passed.

Python 2.7 and the upstream CI matrix were not run locally.

AI disclosure: the fix and regression tests were prepared and verified with Codex assistance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RepositoryEmpty isn't actually empty

1 participant