Skip to content

feat: Solver.__call__ accepts legacy 'format=' as deprecated alias#33

Closed
hozblok wants to merge 1 commit into
masterfrom
fix/25-solver-format-flags-alias
Closed

feat: Solver.__call__ accepts legacy 'format=' as deprecated alias#33
hozblok wants to merge 1 commit into
masterfrom
fix/25-solver-format-flags-alias

Conversation

@hozblok

@hozblok hozblok commented May 11, 2026

Copy link
Copy Markdown
Owner

Closes item #25 from ai/improvements_2026-05-09.md.

Problem. Formula.get (the C++ binding) takes the keyword format=; Solver.__call__ took format_flags=. Users moving between the two APIs got keyword-argument errors and had to remember which spelling belonged to which class. The same test file uses both forms side-by-side (tests/test_simple.py:103, 122, 128, 191 vs Solver(...)(format_flags=...)).

Fix. src/formula/formula.py — add format=None as an explicit kwarg on Solver.__call__. When supplied, emit a DeprecationWarning naming the replacement and override format_flags. New callers use format_flags; existing code keeps working.

Changing the C++ binding's keyword is out of scope here (a pybind11 signature change with broader downstream impact).

Test. New file tests/test_solver_format_alias.py covers:

  • format_flags= works silently
  • format= emits DeprecationWarning and still produces correct output
  • both supplied: format= wins (legacy intent) and the warning still fires

Full suite 319/319.

Formula.get (C++ binding) takes the keyword `format=`; Solver.__call__
took `format_flags=`. Users moving between the two APIs got
keyword-argument errors and had to memorize which spelling went where.
The two forms are visible side-by-side in the existing tests.

Add `format=` as a deprecated alias on Solver.__call__: when supplied,
emit a DeprecationWarning naming the replacement, then override
format_flags with its value. New callers use format_flags; existing
code keeps working.

(The C++ binding's keyword is out of scope here — changing it requires
a pybind11 signature change with broader downstream impact.)

Regression test in tests/test_solver_format_alias.py covers:
- format_flags= works silently
- format= emits DeprecationWarning and still produces correct output
- both supplied: format= wins (legacy intent) and warning still fires

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

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@hozblok hozblok force-pushed the fix/25-solver-format-flags-alias branch from c1c817e to 2da01f4 Compare June 2, 2026 14:22
@hozblok hozblok closed this Jun 2, 2026
@hozblok

hozblok commented Jun 2, 2026

Copy link
Copy Markdown
Owner Author

not relevant

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