Skip to content

fix: clearer ValueError when Solver values are missing or wrong type#21

Merged
hozblok merged 2 commits into
masterfrom
fix/07-solver-missing-values-message
May 16, 2026
Merged

fix: clearer ValueError when Solver values are missing or wrong type#21
hozblok merged 2 commits into
masterfrom
fix/07-solver-missing-values-message

Conversation

@hozblok

@hozblok hozblok commented May 11, 2026

Copy link
Copy Markdown
Owner

Problem. Calling solver() (no arguments) on a multi-variable formula raised ValueError: The value of the 'values' parameter is not a dict! Its type is <class 'NoneType'>.... That framed the problem as a type mismatch when the caller had actually just forgotten to pass anything. New users hit this immediately.

Fix. src/formula/formula.py — split the two cases:

  • values is None + the formula has variables → "Missing values for variables: {...}"
  • values is not None but not a Mapping"Expected a Mapping for 'values' (got <type>); variables to provide: {...}"

Test. New file tests/test_solver_missing_values_message.py covers both messages and confirms the proper-call path still works. All pass; full suite 320/320.

Calling solver() with no arguments on a multi-variable formula raised
'The value of the \"values\" parameter is not a dict! Its type is
<class \"NoneType\">' — which incorrectly framed the problem as a type
mismatch when the caller had actually just forgotten to pass anything.

Split the two cases:
- values is None and the formula has variables → "Missing values for
  variables: {...}"
- values is not None but not a Mapping → "Expected a Mapping for
  'values' (got <type>); variables to provide: {...}"

Regression test in tests/test_solver_missing_values_message.py.

See ai/improvements_2026-05-09.md item #7.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@hozblok hozblok marked this pull request as ready for review May 16, 2026 21:42
@hozblok hozblok merged commit 5a1baba into master May 16, 2026
5 checks passed
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