litellm/ruff-tests.toml
ryan-crabbe-berri 21e9632713
test: add six ruff rules that catch tests which cannot fail (#37709)
`assert False` inside a `try:` raises AssertionError, which the `except
Exception` right below it catches, so several tests reported green no matter
what the code did. `pytest.fail` raises Failed, a BaseException, and escapes.

A bare `a == b` statement is evaluated and discarded. Nine of those sat in
tests, and one was comparing against a model name the router never produces.

Selects B011, B015, B018, PT015, PLR0133 and PLW0127 in ruff-tests.toml
alongside F821, with all 50 existing violations fixed, so no budget file or
ratchet is needed. CI already runs this config over tests/.
2026-08-20 14:21:26 -07:00

24 lines
1.3 KiB
TOML

# Lint config for the test tree, which ruff.toml excludes from `ruff check`.
#
# Every rule here catches a test that cannot fail. Rules land one at a time, each
# with its existing violations already fixed, so this list never needs a budget
# file or a ratchet.
#
# F821 a name that does not exist raises NameError, and a test body wrapped in
# `except Exception: pass` swallows that NameError and reports green
# B011 `assert False` inside `try:` raises AssertionError, which the `except
# Exception` below it catches. `pytest.fail` raises BaseException and escapes
# PT015 same site as B011, from the pytest ruleset
# B015 a bare `a == b` statement is evaluated and thrown away; the missing `assert`
# means the test checks nothing
# B018 a bare attribute access or literal, usually a call missing its parens
# PLW0127 `x = x` self-assignment, dead code that reads like a narrowing or a fixup
# PLR0133 comparison of two constants, e.g. `assert True == True`
#
# No target-version here on purpose: it resolves from requires-python (>=3.10), so
# 3.11-only builtins like BaseExceptionGroup are correctly flagged in a tree that
# still has to run on 3.10.
line-length = 120
lint.select = ["F821", "B011", "B015", "B018", "PT015", "PLR0133", "PLW0127"]