fix(mypy): fix type: ignore placement for OTEL LogRecord import#20351
Merged
krrishdholakia merged 281 commits intoBerriAI:litellm_oss_staging_01_24_2026from Feb 5, 2026
Merged
Conversation
fix: ensure guardrail patterns persist on edit and mode toggle
[Fix] UI - Redirect to ui/login on expired JWT
…n Info panels (BerriAI#19688) * ui for policy mgmt * test_add_guardrails_from_policy_engine_accepts_dynamic_policies_and_pops_from_data
…19592) Google announced that Gemini 2.0 Flash and Flash Lite models will be discontinued on March 31, 2026. Updated deprecation_date field for all affected model variants across different providers (vertex_ai, gemini, deepinfra, openrouter, vercel_ai_gateway). Models updated: - gemini-2.0-flash (added deprecation date) - gemini-2.0-flash-001 (updated from 2026-02-05) - gemini-2.0-flash-lite (added deprecation date) - gemini-2.0-flash-lite-001 (updated from 2026-02-25) All variants now correctly reflect the March 31, 2026 shutdown date.
[Infra] CI/CD - Fixing UI Build
[Infra] CI/CD - Fixing failing tests
[Infra] Fixing CircleCI Config
[Feature] UI - Models Page: Model Search
[Fix] Team Update with Organization having All Proxy Models
…odel [Feature] UI - Organization Edit Page: Reusable Model Select
[Infra] Build UI for Release
…_usage_report [Feature] UI - Usage Export: Breakdown by Teams and Keys
Add test to check if model map is corretly formatted
Intentional bad model map
Intentional bad model map
…el_map_entry Fix: litellm_fix_robotic_model_map_entry
…28_2026 oss staging 01/28/2026
…_llm_provider2 Add custom_llm_provider as gemini translation
…orting_fix [Fix] Sorting for /v2/model/info
[Feature] Bulk Update Keys Endpoint
The type: ignore[attr-defined] comment was on the import alias line inside parentheses, but mypy reports the error on the `from` line. Collapse to single-line imports so the suppression is on the correct line. Also add no-redef to the fallback branch. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
Greptile OverviewGreptile SummaryFixed mypy type checking errors by correcting the placement of Changes:
Impact:
Confidence Score: 5/5
|
| Filename | Overview |
|---|---|
| litellm/integrations/opentelemetry.py | Collapsed multi-line imports to single-line and moved mypy type ignore comments to correct position; added no-redef suppression for fallback import |
Sequence Diagram
sequenceDiagram
participant MyPy as MyPy Type Checker
participant Code as opentelemetry.py
participant OTEL as OpenTelemetry SDK
Note over MyPy,Code: Before Fix (Multi-line import)
MyPy->>Code: Check import on line 1007-1009
Code->>OTEL: Try: from opentelemetry.sdk._logs<br/>import LogRecord as SdkLogRecord
Note over MyPy: type: ignore on wrong line (1008)<br/>Reports attr-defined error on line 1013
Note over MyPy,Code: After Fix (Single-line import)
MyPy->>Code: Check import on line 1007
Code->>OTEL: Try: from opentelemetry.sdk._logs<br/>import LogRecord as SdkLogRecord
Note over Code: type: ignore[attr-defined] on same line (1007)
MyPy->>Code: Suppresses attr-defined error
alt Import Fails (OTEL >= 1.39.0)
Code->>OTEL: Except: from opentelemetry.sdk._logs._internal<br/>import LogRecord as SdkLogRecord
Note over Code: type: ignore[attr-defined, no-redef] on line 1009
MyPy->>Code: Suppresses attr-defined and no-redef errors
end
1 task
424e1bb
into
BerriAI:litellm_oss_staging_01_24_2026
5 of 8 checks passed
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
attr-definederror onopentelemetry.py:1013caused by# type: ignorebeing placed on the wrong line in a multi-line import# type: ignore[attr-defined]is on thefromline where mypy reports the errorno-redefto the fallbackexcept ImportErrorbranch sinceSdkLogRecordis already defined in thetrybranchType
🐛 Bug Fix
Test plan
cd litellm && poetry run mypy .passes with 0 errors (1657 source files)Changes