Skip to content

fix(models): parse supports_tools cleanly and eliminate duplicate dict keys - #21

Open
Nitro-Builds-Yash wants to merge 1 commit into
arcahyadi:mainfrom
Nitro-Builds-Yash:fix/model-endpoint-supports-tools-parsing
Open

Nitro-Builds-Yash wants to merge 1 commit into
arcahyadi:mainfrom
Nitro-Builds-Yash:fix/model-endpoint-supports-tools-parsing

Conversation

@Nitro-Builds-Yash

Copy link
Copy Markdown

Summary

In routes/model_routes.py, update_model_endpoint parsed supports_tools using a dict literal with duplicate keys {True: True, False: False, 'true': True, 'false': False, 1: True, 0: False} (since in Python True == 1 and False == 0). This triggered linter warnings and caused case-insensitive or alternate truthy/falsy representations ("True", "False", "yes", "no") to be evaluated as None. Add a shared _parse_optional_bool helper used in both create_model_endpoint and update_model_endpoint, and add test coverage in tests/test_model_routes.py.

Target branch

  • This PR targets dev, not main. (Note: targeting main as dev branch is not present on upstream)

Linked Issue

Fixes #4454

Type of Change

  • Bug fix (non-breaking — fixes a confirmed issue)
  • New feature (non-breaking — adds new behaviour)
  • Breaking change (changes or removes existing behaviour)
  • Refactor / cleanup (behaviour unchanged)
  • Documentation only
  • CI / tooling / configuration

Checklist

  • I searched open issues and open PRs — this is not a duplicate.
  • This PR targets main
  • My changes are limited to the scope described above — no unrelated refactors or whitespace changes mixed in.
  • I actually ran the app (docker compose up or uvicorn 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_bool with 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.

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.

2 participants