Commit 936b2f0d

Robert Craigie <robert@craigie.dev>
2025-08-07 17:58:11
chore(tests): bump inline-snapshot dependency
1 parent a825874
tests/lib/chat/_utils.py
@@ -52,3 +52,15 @@ def get_caller_name(*, stacklevel: int = 1) -> str:
 def clear_locals(string: str, *, stacklevel: int) -> str:
     caller = get_caller_name(stacklevel=stacklevel + 1)
     return string.replace(f"{caller}.<locals>.", "")
+
+
+def get_snapshot_value(snapshot: Any) -> Any:
+    if not hasattr(snapshot, "_old_value"):
+        return snapshot
+
+    old = snapshot._old_value
+    if not hasattr(old, "value"):
+        return old
+
+    loader = getattr(old.value, "_load_value", None)
+    return loader() if loader else old.value
tests/lib/chat/test_completions.py
@@ -17,7 +17,7 @@ from openai import OpenAI, AsyncOpenAI
 from openai._utils import assert_signatures_in_sync
 from openai._compat import PYDANTIC_V2
 
-from ._utils import print_obj
+from ._utils import print_obj, get_snapshot_value
 from ...conftest import base_url
 from ..schema_types.query import Query
 
@@ -1010,7 +1010,7 @@ def _make_snapshot_request(
         respx_mock.post("/chat/completions").mock(
             return_value=httpx.Response(
                 200,
-                content=content_snapshot._old_value,
+                content=get_snapshot_value(content_snapshot),
                 headers={"content-type": "application/json"},
             )
         )
@@ -1052,7 +1052,7 @@ async def _make_async_snapshot_request(
         respx_mock.post("/chat/completions").mock(
             return_value=httpx.Response(
                 200,
-                content=content_snapshot._old_value,
+                content=get_snapshot_value(content_snapshot),
                 headers={"content-type": "application/json"},
             )
         )
tests/lib/chat/test_completions_streaming.py
@@ -9,7 +9,11 @@ import httpx
 import pytest
 from respx import MockRouter
 from pydantic import BaseModel
-from inline_snapshot import external, snapshot, outsource
+from inline_snapshot import (
+    external,
+    snapshot,
+    outsource,  # pyright: ignore[reportUnknownVariableType]
+)
 
 import openai
 from openai import OpenAI, AsyncOpenAI
@@ -26,7 +30,7 @@ from openai.lib.streaming.chat import (
 )
 from openai.lib._parsing._completions import ResponseFormatT
 
-from ._utils import print_obj
+from ._utils import print_obj, get_snapshot_value
 from ...conftest import base_url
 
 _T = TypeVar("_T")
@@ -1123,7 +1127,7 @@ def _make_stream_snapshot_request(
         respx_mock.post("/chat/completions").mock(
             return_value=httpx.Response(
                 200,
-                content=content_snapshot._old_value._load_value(),
+                content=get_snapshot_value(content_snapshot),
                 headers={"content-type": "text/event-stream"},
             )
         )
@@ -1170,7 +1174,7 @@ def _make_raw_stream_snapshot_request(
         respx_mock.post("/chat/completions").mock(
             return_value=httpx.Response(
                 200,
-                content=content_snapshot._old_value._load_value(),
+                content=get_snapshot_value(content_snapshot),
                 headers={"content-type": "text/event-stream"},
             )
         )
requirements-dev.lock
@@ -35,8 +35,6 @@ attrs==24.2.0
 azure-core==1.31.0
     # via azure-identity
 azure-identity==1.19.0
-black==24.10.0
-    # via inline-snapshot
 certifi==2023.7.22
     # via httpcore
     # via httpx
@@ -46,9 +44,6 @@ cffi==1.16.0
     # via sounddevice
 charset-normalizer==3.3.2
     # via requests
-click==8.1.7
-    # via black
-    # via inline-snapshot
 colorlog==6.7.0
     # via nox
 cryptography==42.0.7
@@ -66,7 +61,7 @@ exceptiongroup==1.2.2
     # via trio
 execnet==2.1.1
     # via pytest-xdist
-executing==2.1.0
+executing==2.2.0
     # via inline-snapshot
 filelock==3.12.4
     # via virtualenv
@@ -92,7 +87,7 @@ idna==3.4
 importlib-metadata==7.0.0
 iniconfig==2.0.0
     # via pytest
-inline-snapshot==0.10.2
+inline-snapshot==0.27.0
 jiter==0.5.0
     # via openai
 markdown-it-py==3.0.0
@@ -109,7 +104,6 @@ multidict==6.5.0
     # via yarl
 mypy==1.14.1
 mypy-extensions==1.0.0
-    # via black
     # via mypy
 nest-asyncio==1.6.0
 nodeenv==1.8.0
@@ -122,17 +116,13 @@ numpy==2.0.2
 outcome==1.3.0.post0
     # via trio
 packaging==23.2
-    # via black
     # via nox
     # via pytest
 pandas==2.2.3
     # via openai
 pandas-stubs==2.1.4.231227
     # via openai
-pathspec==0.12.1
-    # via black
 platformdirs==3.11.0
-    # via black
     # via virtualenv
 pluggy==1.5.0
     # via pytest
@@ -148,11 +138,13 @@ pydantic==2.10.3
 pydantic-core==2.27.1
     # via pydantic
 pygments==2.18.0
+    # via pytest
     # via rich
 pyjwt==2.8.0
     # via msal
 pyright==1.1.399
-pytest==8.3.3
+pytest==8.4.1
+    # via inline-snapshot
     # via pytest-asyncio
     # via pytest-xdist
 pytest-asyncio==0.24.0
@@ -185,10 +177,8 @@ sortedcontainers==2.4.0
 sounddevice==0.5.1
     # via openai
 time-machine==2.9.0
-toml==0.10.2
-    # via inline-snapshot
 tomli==2.0.2
-    # via black
+    # via inline-snapshot
     # via mypy
     # via pytest
 tqdm==4.66.5
@@ -197,13 +187,10 @@ trio==0.27.0
 types-pyaudio==0.2.16.20240516
 types-pytz==2024.2.0.20241003
     # via pandas-stubs
-types-toml==0.10.8.20240310
-    # via inline-snapshot
 types-tqdm==4.66.0.20240417
 typing-extensions==4.12.2
     # via azure-core
     # via azure-identity
-    # via black
     # via multidict
     # via mypy
     # via openai