chore(typing): add boto3/botocore stubs so basedpyright resolves the AWS SDK - #30815
Conversation
…AWS SDK boto3 lives in the proxy extra, so CI's type-check env (uv sync --frozen, dev group, no extras) never installs it and every boto3 return is Unknown. Add botocore-stubs and types-boto3 (scoped to the services litellm builds: bedrock, bedrock-agent, bedrock-runtime, kms, s3, sagemaker-runtime, sts) to the dev group, next to the existing types-* stubs. Stub-only, no botocore runtime pulled, so prod/Docker is untouched. Net 502 fewer basedpyright errors: ~641 Unknown* resolve on the AWS surface, ~139 genuine type-precision issues become visible. Reconcile the budget surgically for exactly the 11 rules the stubs move (4 down, 7 up), each set to its committed baseline plus the measured stub delta with slack unchanged, so no unrelated drift is absorbed.
Greptile SummaryAdds
Confidence Score: 5/5Safe to merge — changes are confined to dev tooling and have no effect on the installed package or Docker image. The change is purely additive stub packages in the dev group and a budget reconciliation whose per-rule deltas match the PR description exactly. No runtime code is touched, no prod dependency tree changes, and all 11 new lock entries are stub-only packages sourced from PyPI with pinned hashes. No files require special attention.
|
| Filename | Overview |
|---|---|
| pyproject.toml | Adds botocore-stubs and types-boto3 to the dev dependency group alongside existing types-* packages; no prod extras touched. |
| basedpyright-code-budget.json | Adjusts 11 rule baselines consistent with the measured stub delta; slack values are unchanged; arithmetic matches the PR description's per-rule table. |
| uv.lock | Adds 11 new stub-only packages (botocore-stubs, types-awscrt, types-boto3 + 7 service sub-packages, types-s3transfer); all sourced from PyPI with pinned hashes; no runtime packages introduced. |
Reviews (1): Last reviewed commit: "chore(typing): add boto3/botocore stubs ..." | Re-trigger Greptile
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
1bd603d
into
litellm_internal_staging
Relevant issues
Follow-up to the basedpyright-coverage work (the monster-function refactors in #30793, #30802, #30813). Those made basedpyright able to analyze the hottest functions; this one gives it real types for the AWS SDK surface those functions sit on.
Linear ticket
N/A
Pre-Submission checklist
make test-unitWhat and why
litellm's whole AWS surface (bedrock, sagemaker, the STS/KMS/S3 helpers in
base_aws_llm.py,common_utils.py, the secret managers) is built on boto3/botocore, but boto3 lives in theproxyoptional extra, not core ordev. So in CI's type-check env (uv sync --frozen,default-groups = ["dev"], no extras) boto3 is never installed;import boto3is a suppressedreportMissingImports(pyrightconfig setsreportMissingImports: false) and every boto3 return value isUnknown. basedpyright has no types for any of it.This adds
botocore-stubsandtypes-boto3(scoped to the services litellm actually constructs: bedrock, bedrock-agent, bedrock-runtime, kms, s3, sagemaker-runtime, sts) to thedevgroup, right next to the existingtypes-requests/types-redis/types-PyYAMLstubs. They are stub-only (no botocore runtime pulled in), so the prod/Docker install is untouched; they only affect the type-check and local dev envs.Net effect across the repo is 502 fewer basedpyright errors. boto3 return values stop being
Unknown(reportUnknownVariableType-331,reportUnknownMemberType-285,reportUnknownParameterType-24,reportUnknownLambdaType-1, about 641 resolved), and in exchange the now-typed call sites surface about 139 genuine type-precision issues that were previously invisible behindUnknown(reportArgumentType+71,reportAny+35,reportAttributeAccessIssue+11,reportCallIssue+10,reportReturnType+8, a fewreportUnnecessary*). Those are real and worth tracking: e.g.base_aws_llm.pyreturnsassume_role(...)'s preciseAssumeRoleResponseTypeDeffrom functions annotated-> dict, a couple of credential helpers returnCredentials | Nonewhere the annotation promisesCredentials, andboto3.session.Configshould bebotocore.config.Config(it carried a now-disabled# type: ignore). They cannot be fixed inside this PR without importing names that exist only in the dev-only stub packages and are absent in prod, so they are reconciled into the budget as honest, now-visible debt rather than papered over.The budget change is surgical: only the 11 rules the stubs actually move, each set to its committed baseline plus the measured stub delta, slack untouched. Four ratchet down (the resolved
Unknown*), seven ratchet up (the now-visible issues). No other rule is touched, so no unrelated drift is absorbed.Screenshots / Proof of Fix
This PR has no runtime effect (the stubs are dev-only and are not installed in prod), so there is nothing to curl; the proof is the basedpyright delta, measured in an env that reproduces CI exactly. basedpyright resolves its interpreter from the env passed via
--pythonpath, so a throwaway frozen env gives CI-accurate numbers without disturbing the local dev.venv.Before (no stubs, equals
litellm_internal_stagingtoday):After (this PR's
devgroup):Per-rule delta (drift-free, same machine, stubs the only difference):
git diff --stat basedpyright-code-budget.jsonis 11 baseline lines, slack unchanged.Type
🚄 Infrastructure
Changes
Adds
botocore-stubs==1.43.14andtypes-boto3[bedrock,bedrock-agent,bedrock-runtime,kms,s3,sagemaker-runtime,sts]==1.43.30to thedevdependency group (stub-only, no prod impact), regeneratesuv.lock, and reconcilesbasedpyright-code-budget.jsonfor the 11 rules the stubs move: fourreportUnknown*baselines ratchet down as boto3 types resolve, seven ratchet up for the type-precision issues the stubs make visible. No runtime code changes.