mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-11 03:38:38 +00:00
fix(clinepass): satisfy ruff — drop a redundant pass, narrow two raises
Two lint failures, both mine, found by CI rather than locally because I had been running ruff from the repo root while the job runs it from `litellm/` and with `ruff-tests.toml` for the test tree. - PIE790: `ClinePassException` had a `pass` after its docstring. - PT011 x2: `pytest.raises(Exception)` is too broad. Replaced with an explicit try/except that is also more precise about the contract: which exception litellm raises for an unsupported endpoint is its business and may change, whereas "nothing was transmitted" is what the test exists to prove. The fixture's own AssertionError (meaning the network WAS reached) is re-raised rather than swallowed as "some exception happened", which the previous form only caught via an isinstance check afterwards. 43 tests still pass; `ruff check` clean under both of the configurations CI uses. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
51214ed26e
commit
d33e84b6e0
2 changed files with 14 additions and 8 deletions
|
|
@ -3,5 +3,3 @@ from litellm.llms.base_llm.chat.transformation import BaseLLMException
|
|||
|
||||
class ClinePassException(BaseLLMException):
|
||||
"""ClinePass exception handling class"""
|
||||
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -47,12 +47,17 @@ def no_request_allowed(monkeypatch):
|
|||
|
||||
|
||||
def test_speech_makes_no_outbound_request(no_request_allowed):
|
||||
with pytest.raises(Exception) as excinfo:
|
||||
# Which exception litellm raises for an unsupported endpoint is its business
|
||||
# and may change; that nothing is transmitted is the contract under test. The
|
||||
# fixture's AssertionError means the network WAS reached, so it must escape
|
||||
# rather than be swallowed as "some exception happened".
|
||||
try:
|
||||
litellm.speech(model="clinepass/deepseek-v4-flash", input="hi", voice="alloy")
|
||||
except AssertionError:
|
||||
raise
|
||||
except Exception: # noqa: S110 - deliberate; see above
|
||||
pass
|
||||
|
||||
assert not isinstance(excinfo.value, AssertionError), (
|
||||
"speech() reached the network; the unsupported-endpoint guard is gone"
|
||||
)
|
||||
assert no_request_allowed == []
|
||||
|
||||
|
||||
|
|
@ -61,10 +66,13 @@ def test_transcription_makes_no_outbound_request(no_request_allowed, tmp_path):
|
|||
audio.write_bytes(b"\x00\x00")
|
||||
|
||||
with open(audio, "rb") as handle:
|
||||
with pytest.raises(Exception) as excinfo:
|
||||
try:
|
||||
litellm.transcription(model="clinepass/deepseek-v4-flash", file=handle)
|
||||
except AssertionError:
|
||||
raise
|
||||
except Exception: # noqa: S110 - deliberate; see test_speech_makes_no_outbound_request
|
||||
pass
|
||||
|
||||
assert not isinstance(excinfo.value, AssertionError)
|
||||
assert no_request_allowed == []
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue