Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ If you ever make public-facing PR descriptions, comments, issues, commit message

Don't hesitate to use values in .env to get needed API keys and other secrets, as long as you never add them to conversation history, commit them, or include them in GitHub issues / PRs

Run tests before you commit. Also, run `make pre-commit` right before each commit, which generates types (as needed) and formats/lints your code. Any errors found must be fixed
Run tests before you commit. Also, run `make pre-commit` right before each commit, which generates types (as needed) and formats/lints your code. Any errors found must be fixed. For `make pre-commit` to work properly you must stage your changes first (git add): it reports CI red or green based on what would happen if you committed your staged changes, but it runs the linters over the working tree, so any unstaged edits to tracked files or untracked files are folded into the result and will skew it away from what CI (which only sees your commit) would report

When you fix violations gated by `ruff-strict-budget.json` or `basedpyright-code-budget.json`, run `make lint-budget-update` and commit the lowered baselines so the ceilings ratchet down instead of leaving stale headroom
When you fix violations gated by `ruff-strict-budget.json`, `type-discipline-budget.json`, or `basedpyright-code-budget.json`, run `make lint-budget-update` and commit the lowered limits so the ceilings ratchet down instead of leaving stale headroom. It lowers each rule's limit by the number of violations this branch cleared since its branch point and never raises one, measured against the working tree, so stage exactly the fixes you're committing before running it; crediting unstaged fixes you won't commit would over-tighten the limits and turn CI red once the committed subset is checked
Comment thread
greptile-apps[bot] marked this conversation as resolved.

If you're trying to create a new function that relies on untyped stuff, instead of adding more Any's and pushing `reportAny` / `reportExplicitAny` closer to their basedpyright ceilings, just validate it in the caller with Pydantic (a model or `TypeAdapter` that returns the typed thing or raises will do) and then pass the now typed variable in

Expand Down
23 changes: 14 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
test-unit-integrations test-unit-core-utils test-unit-other test-unit-root \
test-proxy-unit-a test-proxy-unit-b test-integration test-unit-helm \
info lint lint-dev format \
lint-basedpyright lint-basedpyright-budget-update \
lint-basedpyright lint-basedpyright-budget-update lint-type-discipline lint-type-discipline-budget-update \
lint-ruff-budget lint-ruff-budget-update lint-budget-update lint-gate \
install-dev install-proxy-dev install-test-deps install-hooks \
install-helm-unittest check-circular-imports check-import-safety pre-commit \
Expand All @@ -27,12 +27,12 @@ help:
@echo " make lint - Run all linting (Ruff, basedpyright, format check, circular imports, import safety)"
@echo " make lint-ruff - Run Ruff linting only"
@echo " make lint-basedpyright - Run basedpyright strict, gated by per-rule error counts"
@echo " make lint-basedpyright-budget-update - Re-capture the basedpyright per-rule budget (ratchet)"
@echo " make lint-basedpyright-budget-update - Ratchet basedpyright limits down by what this branch fixed"
@echo " make lint-format - Check ruff format formatting (matches CI)"
@echo " make lint-ruff-budget - Gate the codebase total of each strict ruff rule against its ceiling"
@echo " make lint-ruff-budget - Gate the codebase total of each strict ruff rule against its limit"
@echo " make lint-gate - Strict ruff gate in CI-parity mode (fetches staging, simulates the merge)"
@echo " make lint-ruff-budget-update - Re-capture per-rule baselines in ruff-strict-budget.json (ratchet)"
@echo " make lint-budget-update - Re-capture all ratchet budgets (ruff + basedpyright)"
@echo " make lint-ruff-budget-update - Ratchet ruff-strict-budget.json limits down by what this branch fixed"
@echo " make lint-budget-update - Ratchet all budgets down (ruff + type-discipline + basedpyright)"
@echo " make check-circular-imports - Check for circular imports"
@echo " make check-import-safety - Check import safety"
@echo " make test - Run all tests"
Expand Down Expand Up @@ -164,7 +164,9 @@ lint-basedpyright: install-dev lint-fetch-base
lint-type-discipline: install-dev lint-fetch-base
$(UV_RUN) python scripts/type_discipline_gate.py --base origin/litellm_internal_staging

lint-basedpyright-budget-update: install-dev
# --update lowers each limit by what this branch fixed since its branch point, so
# it needs the base ref fetched to resolve the merge-base.
lint-basedpyright-budget-update: install-dev lint-fetch-base
($(UV_RUN) basedpyright --outputjson || true) | $(UV_RUN) python scripts/type_check_gate.py --update

lint-format: format-check
Expand All @@ -177,11 +179,14 @@ lint-ruff-budget: install-dev
lint-gate: install-dev lint-fetch-base
$(UV_RUN) python scripts/ruff_strict_gate.py --base origin/litellm_internal_staging

lint-ruff-budget-update: install-dev
lint-ruff-budget-update: install-dev lint-fetch-base
$(UV_RUN) python scripts/ruff_strict_gate.py --update

# Ratchet all budgets in one shot (ruff strict + basedpyright)
lint-budget-update: lint-ruff-budget-update lint-basedpyright-budget-update
lint-type-discipline-budget-update: install-dev lint-fetch-base
$(UV_RUN) python scripts/type_discipline_gate.py --update

# Ratchet all budgets in one shot (ruff strict + type-discipline + basedpyright)
lint-budget-update: lint-ruff-budget-update lint-type-discipline-budget-update lint-basedpyright-budget-update

check-circular-imports: install-dev
cd litellm && $(UV_RUN) python ../tests/documentation_tests/test_circular_imports.py && cd ..
Expand Down
144 changes: 48 additions & 96 deletions basedpyright-code-budget.json
Original file line number Diff line number Diff line change
@@ -1,194 +1,146 @@
{
"reportAny": {
"baseline": 24989,
"slack": 2500
"limit": 37484
},
"reportArgumentType": {
"baseline": 1814,
"slack": 180
"limit": 2721
},
"reportAssignmentType": {
"baseline": 220,
"slack": 22
"limit": 330
},
"reportAttributeAccessIssue": {
"baseline": 346,
"slack": 35
"limit": 519
},
"reportCallIssue": {
"baseline": 87,
"slack": 10
"limit": 131
},
"reportConstantRedefinition": {
"baseline": 39,
"slack": 4
"limit": 59
},
"reportDeprecated": {
"baseline": 217,
"slack": 22
"limit": 326
},
"reportDuplicateImport": {
"baseline": 28,
"slack": 3
"limit": 42
},
"reportExplicitAny": {
"baseline": 6931,
"slack": 700
"limit": 10397
},
"reportFunctionMemberAccess": {
"baseline": 7,
"slack": 3
"limit": 11
},
"reportGeneralTypeIssues": {
"baseline": 151,
"slack": 15
"limit": 227
},
"reportIncompatibleMethodOverride": {
"baseline": 52,
"slack": 5
"limit": 78
},
"reportIncompatibleVariableOverride": {
"baseline": 8,
"slack": 3
"limit": 12
},
"reportInconsistentOverload": {
"baseline": 12,
"slack": 3
"limit": 18
},
"reportIndexIssue": {
"baseline": 26,
"slack": 3
"limit": 39
},
"reportInvalidTypeForm": {
"baseline": 23,
"slack": 3
"limit": 35
},
"reportInvalidTypeVarUse": {
"baseline": 2,
"slack": 3
"limit": 5
},
"reportMatchNotExhaustive": {
"baseline": 1,
"slack": 0
"limit": 2
},
"reportMissingParameterType": {
"baseline": 3933,
"slack": 390
"limit": 5900
},
"reportMissingTypeArgument": {
"baseline": 10612,
"slack": 1000
"limit": 15918
},
"reportMissingTypeStubs": {
"baseline": 27,
"slack": 10
"limit": 41
},
"reportOperatorIssue": {
"baseline": 6,
"slack": 3
"limit": 9
},
"reportOptionalCall": {
"baseline": 4,
"slack": 3
"limit": 7
},
"reportOptionalIterable": {
"baseline": 3,
"slack": 3
"limit": 6
},
"reportOptionalMemberAccess": {
"baseline": 724,
"slack": 72
"limit": 1086
},
"reportOptionalOperand": {
"baseline": 3,
"slack": 3
"limit": 6
},
"reportOptionalSubscript": {
"baseline": 11,
"slack": 3
"limit": 17
},
"reportPossiblyUnboundVariable": {
"baseline": 52,
"slack": 10
"limit": 78
},
"reportPrivateUsage": {
"baseline": 1625,
"slack": 160
"limit": 2438
},
"reportRedeclaration": {
"baseline": 8,
"slack": 3
"limit": 12
},
"reportReturnType": {
"baseline": 126,
"slack": 100
"limit": 226
},
"reportTypedDictNotRequiredAccess": {
"baseline": 20,
"slack": 3
"limit": 30
},
"reportUndefinedVariable": {
"baseline": 2,
"slack": 3
"limit": 5
},
"reportUnknownArgumentType": {
"baseline": 30603,
"slack": 3000
"limit": 45905
},
"reportUnknownLambdaType": {
"baseline": 75,
"slack": 10
"limit": 113
},
"reportUnknownMemberType": {
"baseline": 27037,
"slack": 2500
"limit": 40556
},
"reportUnknownParameterType": {
"baseline": 13612,
"slack": 1000
"limit": 20418
},
"reportUnknownVariableType": {
"baseline": 21445,
"slack": 2000
"limit": 32168
},
"reportUnnecessaryCast": {
"baseline": 118,
"slack": 10
"limit": 177
},
"reportUnnecessaryComparison": {
"baseline": 683,
"slack": 100
"limit": 1025
},
"reportUnnecessaryContains": {
"baseline": 4,
"slack": 3
"limit": 7
},
"reportUnnecessaryIsInstance": {
"baseline": 808,
"slack": 80
"limit": 1212
},
"reportUntypedBaseClass": {
"baseline": 110,
"slack": 11
"limit": 165
},
"reportUntypedFunctionDecorator": {
"baseline": 22,
"slack": 3
"limit": 33
},
"reportUnusedClass": {
"baseline": 22,
"slack": 3
"limit": 33
},
"reportUnusedFunction": {
"baseline": 137,
"slack": 10
"limit": 206
},
"reportUnusedImport": {
"baseline": 670,
"slack": 50
"limit": 1005
},
"reportUnusedVariable": {
"baseline": 865,
"slack": 50
"limit": 1298
}
}
Loading
Loading