Skip to content

Commit 0f1191a

Browse files
chore: silence pyright noise on embedding test files (OPEN-10480)
Adds the same file-level pragma already used by test_portkey_integration.py to suppress reportUnknown* and reportMissingParameterType — these come from openlayer.lib.integrations being in pyright's ignore list, which causes imports from there to be typed as Unknown. Per-line pyright ignores added on direct imports of botocore.response and openai, which are not present in the lint job's environment. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 6be00ed commit 0f1191a

5 files changed

Lines changed: 36 additions & 12 deletions

tests/test_async_openai_embedding_integration.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
"""Test OpenAI embedding integration (async)."""
22

3+
# openlayer.lib.integrations is in pyright's ignore list, so imports get
4+
# unknown/partially unknown types; disable these diagnostics for this test file only.
5+
# pyright: reportUnknownMemberType=false, reportUnknownVariableType=false, reportUnknownArgumentType=false, reportUnknownParameterType=false, reportMissingParameterType=false
6+
37
import asyncio
48
from unittest.mock import Mock, AsyncMock, MagicMock, patch
59

@@ -88,7 +92,7 @@ def test_handle_embedding_async_failure_does_not_break_client(self) -> None:
8892
assert result is fake
8993

9094
def test_trace_async_openai_patches_embeddings_create(self) -> None:
91-
import openai
95+
import openai # pyright: ignore[reportMissingImports]
9296

9397
from openlayer.lib.integrations.async_openai_tracer import trace_async_openai
9498

tests/test_bedrock_integration.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
"""Test AWS Bedrock integration."""
22

3+
# openlayer.lib.integrations is in pyright's ignore list, so imports from bedrock_tracer
4+
# get unknown/partially unknown types; disable these diagnostics for this test file only.
5+
# pyright: reportUnknownMemberType=false, reportUnknownVariableType=false, reportUnknownArgumentType=false, reportUnknownParameterType=false, reportMissingParameterType=false
6+
37
import io
48
import json
59
from unittest.mock import MagicMock, patch
@@ -10,7 +14,7 @@ class TestBedrockChatRegression:
1014

1115
def _make_anthropic_response(self, body_dict):
1216
"""Build a response dict mimicking what bedrock-runtime returns."""
13-
from botocore.response import StreamingBody
17+
from botocore.response import StreamingBody # pyright: ignore[reportMissingImports]
1418

1519
body_bytes = json.dumps(body_dict).encode("utf-8")
1620
return {"body": StreamingBody(io.BytesIO(body_bytes), len(body_bytes))}
@@ -88,7 +92,7 @@ def test_is_embedding_model_handles_empty_string(self) -> None:
8892

8993
def test_traced_invoke_routes_embedding_to_new_handler(self) -> None:
9094
"""An embedding modelId must call handle_embedding_invoke, not the chat handler."""
91-
from botocore.response import StreamingBody
95+
from botocore.response import StreamingBody # pyright: ignore[reportMissingImports]
9296

9397
from openlayer.lib.integrations.bedrock_tracer import trace_bedrock
9498

@@ -120,7 +124,7 @@ class TestBedrockTitanEmbedding:
120124
"""Titan v1 and v2 embedding requests produce well-formed embedding steps."""
121125

122126
def _titan_response(self, embedding, token_count):
123-
from botocore.response import StreamingBody
127+
from botocore.response import StreamingBody # pyright: ignore[reportMissingImports]
124128

125129
body = json.dumps(
126130
{"embedding": embedding, "inputTextTokenCount": token_count}
@@ -198,7 +202,7 @@ class TestBedrockCohereEmbedding:
198202
"""Cohere v3 embedding produces a multi-vector batch step."""
199203

200204
def _cohere_response(self, embeddings):
201-
from botocore.response import StreamingBody
205+
from botocore.response import StreamingBody # pyright: ignore[reportMissingImports]
202206

203207
body = json.dumps(
204208
{
@@ -249,7 +253,7 @@ class TestBedrockEmbeddingResilience:
249253
"""Tracing failures must never break the caller; response body must remain usable."""
250254

251255
def test_embedding_failure_does_not_break_client(self) -> None:
252-
from botocore.response import StreamingBody
256+
from botocore.response import StreamingBody # pyright: ignore[reportMissingImports]
253257

254258
from openlayer.lib.integrations.bedrock_tracer import trace_bedrock
255259

@@ -275,7 +279,7 @@ def test_embedding_failure_does_not_break_client(self) -> None:
275279
assert response["body"].read() == body_bytes
276280

277281
def test_embedding_response_body_is_replayable(self) -> None:
278-
from botocore.response import StreamingBody
282+
from botocore.response import StreamingBody # pyright: ignore[reportMissingImports]
279283

280284
from openlayer.lib.integrations.bedrock_tracer import trace_bedrock
281285

tests/test_litellm_integration.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,9 @@ def test_trace_litellm_patches_embedding(self, mock_litellm: Mock) -> None:
300300

301301
@patch("openlayer.lib.integrations.litellm_tracer.HAVE_LITELLM", True)
302302
def test_handle_embedding_single_input(self) -> None:
303-
from openlayer.lib.integrations.litellm_tracer import handle_embedding
303+
from openlayer.lib.integrations.litellm_tracer import (
304+
handle_embedding, # pyright: ignore[reportUnknownVariableType]
305+
)
304306

305307
fake_response = Mock()
306308
fake_response.model = "text-embedding-3-small"
@@ -338,7 +340,9 @@ def test_handle_embedding_single_input(self) -> None:
338340

339341
@patch("openlayer.lib.integrations.litellm_tracer.HAVE_LITELLM", True)
340342
def test_handle_embedding_batch_input(self) -> None:
341-
from openlayer.lib.integrations.litellm_tracer import handle_embedding
343+
from openlayer.lib.integrations.litellm_tracer import (
344+
handle_embedding, # pyright: ignore[reportUnknownVariableType]
345+
)
342346

343347
fake_response = Mock()
344348
fake_response.model = "text-embedding-3-small"
@@ -376,7 +380,9 @@ def test_handle_embedding_batch_input(self) -> None:
376380

377381
@patch("openlayer.lib.integrations.litellm_tracer.HAVE_LITELLM", True)
378382
def test_handle_embedding_cost_from_hidden_params(self) -> None:
379-
from openlayer.lib.integrations.litellm_tracer import handle_embedding
383+
from openlayer.lib.integrations.litellm_tracer import (
384+
handle_embedding, # pyright: ignore[reportUnknownVariableType]
385+
)
380386

381387
fake_response = Mock()
382388
fake_response.model = "text-embedding-3-small"
@@ -398,7 +404,9 @@ def test_handle_embedding_cost_from_hidden_params(self) -> None:
398404

399405
@patch("openlayer.lib.integrations.litellm_tracer.HAVE_LITELLM", True)
400406
def test_handle_embedding_failure_does_not_break_client(self) -> None:
401-
from openlayer.lib.integrations.litellm_tracer import handle_embedding
407+
from openlayer.lib.integrations.litellm_tracer import (
408+
handle_embedding, # pyright: ignore[reportUnknownVariableType]
409+
)
402410

403411
fake_response = Mock()
404412
fake_response.model = "text-embedding-3-small"

tests/test_openai_embedding_helpers.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
"""Test shared OpenAI embedding parsers."""
22

3+
# openlayer.lib.integrations is in pyright's ignore list, so imports get
4+
# unknown/partially unknown types; disable these diagnostics for this test file only.
5+
# pyright: reportUnknownMemberType=false, reportUnknownVariableType=false, reportUnknownArgumentType=false, reportUnknownParameterType=false, reportMissingParameterType=false
6+
37
from unittest.mock import Mock
48

59

tests/test_openai_embedding_integration.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
"""Test OpenAI embedding integration (sync)."""
22

3+
# openlayer.lib.integrations is in pyright's ignore list, so imports get
4+
# unknown/partially unknown types; disable these diagnostics for this test file only.
5+
# pyright: reportUnknownMemberType=false, reportUnknownVariableType=false, reportUnknownArgumentType=false, reportUnknownParameterType=false, reportMissingParameterType=false
6+
37
from unittest.mock import Mock, MagicMock, patch
48

59

@@ -87,7 +91,7 @@ def test_handle_embedding_failure_does_not_break_client(self) -> None:
8791

8892
def test_trace_openai_patches_embeddings_create(self) -> None:
8993
"""After trace_openai, client.embeddings.create is replaced."""
90-
import openai
94+
import openai # pyright: ignore[reportMissingImports]
9195

9296
from openlayer.lib.integrations.openai_tracer import trace_openai
9397

0 commit comments

Comments
 (0)