feat: Solver.__call__ accepts legacy 'format=' as deprecated alias#33
Closed
hozblok wants to merge 1 commit into
Closed
feat: Solver.__call__ accepts legacy 'format=' as deprecated alias#33hozblok wants to merge 1 commit into
hozblok wants to merge 1 commit into
Conversation
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>
c1c817e to
2da01f4
Compare
Owner
Author
|
not relevant |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes item #25 from
ai/improvements_2026-05-09.md.Problem.
Formula.get(the C++ binding) takes the keywordformat=;Solver.__call__tookformat_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, 191vsSolver(...)(format_flags=...)).Fix.
src/formula/formula.py— addformat=Noneas an explicit kwarg onSolver.__call__. When supplied, emit aDeprecationWarningnaming the replacement and overrideformat_flags. New callers useformat_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.pycovers:format_flags=works silentlyformat=emitsDeprecationWarningand still produces correct outputformat=wins (legacy intent) and the warning still firesFull suite 319/319.