Skip to content

fix(types): silence pydantic ReadOnly warning on StandardLoggingRoutingDecision - #37949

Merged
mateo-berri merged 1 commit into
litellm_internal_stagingfrom
litellm_fix_pydantic_readonly_warning
Aug 22, 2026
Merged

fix(types): silence pydantic ReadOnly warning on StandardLoggingRoutingDecision#37949
mateo-berri merged 1 commit into
litellm_internal_stagingfrom
litellm_fix_pydantic_readonly_warning

Conversation

@mateo-berri

Copy link
Copy Markdown
Contributor

TLDR

Drops the ReadOnly qualifier from StandardLoggingRoutingDecision.reasoning_override_min_score so importing litellm no longer prints a pydantic UserWarning at startup. Pydantic builds a schema over this TypedDict (it is embedded in the router's pydantic models) and warns on every ReadOnly item it meets, so the warning greeted every CLI user before lite claude even started. The sibling field tier_litellm_params already made the same trade with the same # writable-ok marker; this follows it.

User Flow

Before, every lite invocation greets the user with a pydantic warning about litellm's own types before the tool even starts

  1. With the proxy configured (LITELLM_PROXY_URL=http://localhost:33279), the user runs lite claude in their terminal
  2. Before anything else, the terminal prints pydantic/_internal/_generate_schema.py:1480: UserWarning: Item 'reasoning_override_min_score' on TypedDict class 'StandardLoggingRoutingDecision' is using the ReadOnly qualifier. Pydantic will not protect items from any mutation on dictionary instances. followed by a warnings.warn( source line
  3. Only then does the expected litellm: routing Claude Code through proxy at http://localhost:33279 line appear, Claude Code starts, and requests flow through POST http://localhost:33279/v1/messages normally
  4. The same warning opens every later lite command and any python -c "import litellm", reading like something is wrong when nothing is

After, startup is clean and the only line before Claude Code opens is the routing notice

  1. With the proxy configured (LITELLM_PROXY_URL=http://localhost:33279), the user runs lite claude in their terminal
  2. The terminal prints just litellm: routing Claude Code through proxy at http://localhost:33279, Claude Code starts, and requests flow through POST http://localhost:33279/v1/messages normally
  3. Later lite commands and python -c "import litellm" start silently

Verification

  • python -W always -c "import litellm" on the base branch prints the warning once; with this change it prints nothing
  • tests/test_litellm/router_strategy/test_complexity_router.py passes (the 14 failures in that file are environment-related and identical on the untouched base)
  • make check passes; the type-discipline gate accepts the # writable-ok: <reason> suppression and no other rule fires on the changed line

@greptile-apps

greptile-apps Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR removes the ReadOnly qualifier from StandardLoggingRoutingDecision.reasoning_override_min_score to prevent Pydantic from emitting a startup warning.

  • Retains the field’s float value type and optional TypedDict behavior.
  • Documents the repository-approved writable exception inline.

Confidence Score: 5/5

The PR appears safe to merge, with no actionable correctness, compatibility, or security failures identified.

The change preserves the field’s runtime value type and construction behavior while using the repository-supported writable exception to suppress Pydantic’s warning.

Important Files Changed

Filename Overview
litellm/types/utils.py Reclassifies one routing-decision field as writable to avoid Pydantic schema warnings; no concrete runtime regression or repository-rule violation was identified.

Reviews (1): Last reviewed commit: "fix(types): silence pydantic ReadOnly wa..." | Re-trigger Greptile

@codecov

codecov Bot commented Aug 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@mateo-berri
mateo-berri merged commit 21d30fc into litellm_internal_staging Aug 22, 2026
68 checks passed
@mateo-berri
mateo-berri deleted the litellm_fix_pydantic_readonly_warning branch August 22, 2026 18:39
@codspeed-hq

codspeed-hq Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing litellm_fix_pydantic_readonly_warning (da09e21) with litellm_internal_staging (7a1afa1)1

Open in CodSpeed

Footnotes

  1. No successful run was found on litellm_internal_staging (da09e21) during the generation of this report, so ff20a4b was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

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