Repository navigation
fix(models): parse supports_tools cleanly and eliminate duplicate dict keys - #21
Open
Nitro-Builds-Yash wants to merge 1 commit into
Conversation
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
In
routes/model_routes.py,update_model_endpointparsedsupports_toolsusing a dict literal with duplicate keys{True: True, False: False, 'true': True, 'false': False, 1: True, 0: False}(since in PythonTrue == 1andFalse == 0). This triggered linter warnings and caused case-insensitive or alternate truthy/falsy representations ("True","False","yes","no") to be evaluated asNone. Add a shared_parse_optional_boolhelper used in bothcreate_model_endpointandupdate_model_endpoint, and add test coverage intests/test_model_routes.py.Target branch
dev, notmain. (Note: targetingmainasdevbranch is not present on upstream)Linked Issue
Fixes #4454
Type of Change
Checklist
maindocker compose uporuvicorn app:app) and verified the change works end-to-end. Type-checks and unit tests are not enough.How to Test
Verify syntax compilation passes with
python -m compileall -q routes/model_routes.py tests/test_model_routes.py. Run unit tests for_parse_optional_boolwith pytest (pytest tests/test_model_routes.py -k test_parse_optional_bool). Check that boolean, integer (1/0), string variations ("true", "false", "yes", "no"), and None inputs are correctly parsed.