Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

test: gate the test tree on fifteen assertion and handler rules it already satisfies (#38361)

ryan-crabbe-berri7e7ac69258b1
diff --git a/ruff-tests.toml b/ruff-tests.toml
index e036fb4946c..d75f10b9605 100644
--- a/ruff-tests.toml
+++ b/ruff-tests.toml
@@ -55,6 +55,40 @@
# never fires and a subprocess still reads the real keys the test believes it
# cleared. The manual restore underneath is skipped whenever the body raises,
# so every later test in that worker inherits a plain dict for an environment
+# PGH005 an assertion on a mock attribute the library never defines. `assert
+# m.called_once` and a bare `m.assert_called_once` both read as checks and
+# neither is one: a Mock invents whatever attribute it is asked for, so the
+# first is always truthy and the second is an attribute nobody calls
+# F631 `assert (cond, "message")` asserts a two-element tuple, which is always
+# truthy. The message meant to explain the failure is what stops the assertion
+# from ever having one
+# F634 `if (a, b):` branches on a tuple, so the branch is always taken and the
+# condition it was written to test is never evaluated
+# PT010 `pytest.raises()` with no exception type accepts anything the block raises,
+# including the TypeError a refactor introduced
+# PT030 the `pytest.warns` twin of PT011. `Warning` or `UserWarning` with no `match=`
+# passes on any warning that broad
+# PT031 the `pytest.warns` twin of PT012. Everything after the warning call is dead,
+# so an `assert` sitting there is never checked
+# B012 a `return`, `break` or `continue` inside `finally` discards whatever exception
+# was in flight, so the AssertionError the test just raised is thrown away and
+# the test reports green
+# B013 a one-element tuple where the exception class was meant, which reads as a
+# wider handler than it is
+# B014 an exception named twice in one handler, or a subclass beside its parent. The
+# second name does nothing, and it is usually the one someone meant to change
+# B016 `raise "message"` raises a str, so the failure the test set up is replaced by
+# a TypeError from the raise itself
+# B022 `contextlib.suppress()` with no arguments suppresses nothing, so the call it
+# wraps still raises
+# B029 `except ():` catches nothing, so the recovery or skip written in that handler
+# never happens
+# B030 an `except` naming something that is not an exception class raises TypeError
+# while unwinding, replacing the error under test
+# F707 a bare `except:` ahead of another handler makes every handler below it
+# unreachable
+# PLE0704 a bare `raise` outside an except block raises RuntimeError instead of
+# re-raising anything
#
# 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
@@ -83,4 +117,19 @@ lint.select = [
"B025",
"F632",
"B003",
+ "PGH005",
+ "F631",
+ "F634",
+ "PT010",
+ "PT030",
+ "PT031",
+ "B012",
+ "B013",
+ "B014",
+ "B016",
+ "B022",
+ "B029",
+ "B030",
+ "F707",
+ "PLE0704",
]