Skip to content

Report unhashable dictionary choices as configuration errors - #218

Open
Imkkey wants to merge 1 commit into
beetbox:mainfrom
Imkkey:fix-choice-unhashable-dict-20261013
Open

Imkkey wants to merge 1 commit into
beetbox:mainfrom
Imkkey:fix-choice-unhashable-dict-20261013

Conversation

@Imkkey

@Imkkey Imkkey commented Oct 13, 2026

Copy link
Copy Markdown

Summary

A dictionary-backed Choice currently raises raw TypeError for list, dict, or set configuration values. Besides losing the setting's name, this prevents OneOf from reaching a later valid collection template.

Normalize TypeError from the dict-dispatch lookup to ValueError, which the existing Choice.convert error handling turns into ConfigValueError. Keep the direct choices[value] lookup and leave the other converters unchanged.

Add regression coverage for rejected unhashable values, valid sequence/mapping fallbacks, nested mapping validation, and rejection when no fallback matches. Include compatibility controls for tuple/custom hashable keys, dict-subclass __missing__, and a custom lookup accepting lists. Verify that errors in sequence and enum converters still propagate directly and through OneOf. Add an unreleased changelog entry.

Validation

On Linux/Python 3.12.14:

  • Before the fix: seven regression failures (three unhashable-value subtests plus four OneOf cases); compatibility controls pass.
  • Afterward: 310 core tests and three subtests pass.
  • Full suite: 311 tests and three subtests pass, with one pre-existing failure in test_bump_version_applies_sequential_changelog_updates. Unchanged upstream reproduces that same failure (300 tests pass): the expected changelog underline does not match the October date heading.
  • Ruff lint and formatting, mypy targeting Python 3.10, strict Sphinx rebuild, changelog formatting/lint, and git diff --check pass.
  • Separate YAML-loaded diagnostics: all 13 pass after the fix.

Prepared and tested with OpenAI Codex assistance. This is a draft for maintainer review.

@Imkkey
Imkkey marked this pull request as ready for review October 14, 2026 06:22

This branch has not been deployed

No deployments
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.

1 participant