fix: use Mapping for dict params, Any for ValidatedParameters#289
Merged
Abhijeet Prasad (AbhiPrasad) merged 1 commit intobraintrustdata:mainfrom Apr 14, 2026
Conversation
- choice_scores: dict[str, float] → Mapping[str, float] in ScorerBuilder.create() — input parameter, dict invariance means dict[str, int] was rejected even though int is compatible with float - CodeParameters.metadata and ParametersBuilder.create(metadata=...): dict[str, Any] → Mapping[str, Any] — input parameter, same invariance issue; other metadata parameters already use the Metadata alias which is being changed to Mapping in a separate PR - ValidatedParameters: dict[str, object] → dict[str, Any] — values are Pydantic models, strings, Prompt objects, etc. Using object forces callers to narrow every retrieved value; Any is the practical type for this heterogeneous container
Abhijeet Prasad (AbhiPrasad)
approved these changes
Apr 14, 2026
553ac76
into
braintrustdata:main
84 checks passed
Member
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.
Summary
Three type annotation fixes in
framework2.pyandparameters.py:choice_scores: dict[str, float]→Mapping[str, float]inScorerBuilder.create()(all 3 overloads). Input parameter — dict invariance meansdict[str, int]was rejected even thoughintis compatible withfloat.metadata: dict[str, Any]→Mapping[str, Any]inCodeParametersdataclass field andParametersBuilder.create(). Input parameter — same invariance class as theMetadataalias change in PR fix: use Mapping for Metadata and ParametersSchema type aliases #285. Other metadata params in this file already use theMetadataalias.ValidatedParameters = dict[str, object]→dict[str, Any]. Values are Pydantic models, strings,Promptobjects, etc. Usingobjectforces every caller to narrow;Anyis the practical type for this heterogeneous container.Test plan
dict[str, int]is now accepted forchoice_scoresby type checkersValidatedParametersvalues no longer require narrowing fromobject