Bumps the minor-and-patch group in /libs/checkpoint-sqlite with 5 updates: | Package | From | To | | --- | --- | --- | | [pytest](https://github.com/pytest-dev/pytest) | `9.1.1` | `9.2.0` | | [pytest-asyncio](https://github.com/pytest-dev/pytest-asyncio) | `1.4.0` | `1.4.1` | | [pytest-mock](https://github.com/pytest-dev/pytest-mock) | `3.16.0` | `3.17.0` | | [ruff](https://github.com/astral-sh/ruff) | `0.16.9` | `0.17.3` | | [ty](https://github.com/astral-sh/ty) | `0.0.84` | `0.0.94` | Updates `pytest` from 9.1.1 to 9.2.0 <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/pytest-dev/pytest/releases">pytest's releases</a>.</em></p> <blockquote> <h2>9.2.0</h2> <h1>pytest 9.2.0 (2026-10-27)</h1> <h2>Removals and backward incompatible breaking changes</h2> <ul> <li> <p><a href="https://redirect.github.com/pytest-dev/pytest/issues/14716">#14716</a>: <code>-c</code> now raises a usage error for a path that does not exist, is a directory, or is in a format pytest has no loader for. Such paths were previously either ignored or reported as an unhandled <code>FileNotFoundError</code>.</p> </li> <li> <p><a href="https://redirect.github.com/pytest-dev/pytest/issues/8593">#8593</a>: The <code>indirect</code>, <code>ids</code> and <code>scope</code> arguments of <code>Metafunc.parametrize() <pytest.Metafunc.parametrize></code> -- and therefore of <code>@pytest.mark.parametrize <pytest.mark.parametrize ref></code> -- are now keyword-only.</p> <p>Passing them positionally was a common source of confusing errors, e.g. <code>parametrize("arg1", "arg2", [(1, 2)])</code> made the argvalues land in <code>indirect</code> and failed with <code>indirect fixture '(1, 2)' doesn't exist</code>; such mistakes now fail with an understandable <code>TypeError</code>. The type annotations have always declared these arguments as keyword-only.</p> </li> <li> <p><a href="https://redirect.github.com/pytest-dev/pytest/issues/993">#993</a>: Plugin import failures at startup are now reported and classified instead of escaping as a raw traceback with the accidental exit code <code>1</code>:</p> <ul> <li>a plugin that cannot be found -- via <code>-p</code>, <code>pytest_plugins</code> or <code>PYTEST_PLUGINS</code> -- exits with <code>pytest.ExitCode</code> <code>USAGE_ERROR</code> (<code>4</code>), like a <code>conftest.py</code> that fails to import;</li> <li>a plugin that is found but raises while importing -- including a broken <code>pytest11</code> entry point or a missing plugin dependency -- exits with <code>pytest.ExitCode</code> <code>INTERNAL_ERROR</code> (<code>3</code>), with the traceback preserved.</li> </ul> <p><code>pytest.main</code> now returns these codes instead of raising <code>ImportError</code>. Also fixed an <code>IndexError</code> from pytest's own internals when the plugin raised an exception with no arguments.</p> </li> </ul> <h2>Deprecations (removal in next major release)</h2> <ul> <li> <p><a href="https://redirect.github.com/pytest-dev/pytest/issues/14742">#14742</a>: The private <code>_pytest.python.CallSpec2</code> name has been renamed to <code>CallSpec</code>. The old <code>CallSpec2</code> alias remains available for now and will be removed in pytest 10 or 11.</p> </li> <li> <p><a href="https://redirect.github.com/pytest-dev/pytest/issues/14755">#14755</a>: Schedule <em>yield_fixture</em> decorator for removal in pytest 10 or 11.</p> </li> <li> <p><a href="https://redirect.github.com/pytest-dev/pytest/issues/14774">#14774</a>: Similarly to the deprecation of class-scoped fixtures defined as instance methods in pytest 9.1, <em>all</em> higher-scoped fixtures (<code>module</code>, <code>package</code>, and <code>session</code>) defined as instance methods are now deprecated.</p> <p>They suffer from the same issue the original deprecation only fixed for class-scoped fixtures, see <code>10819</code> and <code>14011</code>.</p> </li> <li> <p><a href="https://redirect.github.com/pytest-dev/pytest/issues/14808">#14808</a>: Passing a non-string value to a <code>string</code>-typed ini option now emits a <code>pytest.PytestRemovedIn10Warning</code>. This affects <code>[tool.pytest.ini_options]</code> in <code>pyproject.toml</code>. In pytest 10 this will raise a <code>TypeError</code>, matching the behavior of the corresponding TOML config path.</p> </li> <li> <p><a href="https://redirect.github.com/pytest-dev/pytest/issues/7323">#7323</a>: Passing <code>bytes</code> to <code>TerminalReporter.write_line()</code> is now deprecated, pass a <code>str</code> instead.</p> </li> </ul> <h2>New features</h2> <ul> <li><a href="https://redirect.github.com/pytest-dev/pytest/issues/14743">#14743</a>: <!-- raw HTML omitted -->Full diff:<!-- raw HTML omitted --> now contains a legend explaining the <!-- raw HTML omitted -->+<!-- raw HTML omitted --> & <!-- raw HTML omitted -->-<!-- raw HTML omitted --> symbols in diff output.</li> <li><a href="https://redirect.github.com/pytest-dev/pytest/issues/2781">#2781</a>: When <code>strict_markers</code> is enabled, marker names used in <code>-m</code> expressions are now validated against registered markers.</li> <li><a href="https://redirect.github.com/pytest-dev/pytest/issues/6881">#6881</a>: Added the <code>parametrize_long_str_id_strategy</code> configuration option to control how long <code>str</code>/<code>bytes</code> parameter values are handled in auto-generated test IDs. Explicit IDs set via <code>ids=[...]</code> or <code>pytest.param(..., id=...)</code> are not affected. Available strategies: <code>short</code> (default, values over 100 chars fall back to <code>argname+index</code>), <code>sha256</code> (SHA-256 hex digest), <code>legacy</code> (keep full value), and <code>disallow</code> (error requesting explicit IDs).</li> </ul> <h2>Improvements in existing functionality</h2> <ul> <li><a href="https://redirect.github.com/pytest-dev/pytest/issues/10745">#10745</a>: A <code>RecursionError</code> whose recursion origin cannot be located now shows only the first and last 10 stack frames, matching what pytest already did when locating the origin failed outright. Previously the full traceback -- often around a thousand near-identical frames -- was rendered, which was both slow and unreadable. Pass <code>--full-trace</code> to see every frame.</li> </ul> <!-- raw HTML omitted --> </blockquote> <p>... (truncated)</p> </details> <details> <summary>Commits</summary> <ul> <li><a href="ae1d0ff57b"><code>ae1d0ff</code></a> Prepare release version 9.2.0</li> <li><a href="143ce31dea"><code>143ce31</code></a> pre-commit: exclude codespell on generated release announcements</li> <li><a href="532dc5fc78"><code>532dc5f</code></a> tox: add attrs dependency to regen, needed in reportingdemo.rst</li> <li><a href="a7b2446ee4"><code>a7b2446</code></a> Merge pull request <a href="https://redirect.github.com/pytest-dev/pytest/issues/15245">#15245</a> from pytest-dev/claude/project-thread-9jcf91</li> <li><a href="679d09c694"><code>679d09c</code></a> [pre-commit.ci] pre-commit autoupdate (<a href="https://redirect.github.com/pytest-dev/pytest/issues/15266">#15266</a>)</li> <li><a href="41d12cdbb4"><code>41d12cd</code></a> docs: clarify typing for yield fixtures</li> <li><a href="b9022ba04a"><code>b9022ba</code></a> Merge pull request <a href="https://redirect.github.com/pytest-dev/pytest/issues/15182">#15182</a> from 1871698/docs/improve-getting-started-description</li> <li><a href="16f87a7f36"><code>16f87a7</code></a> docs: improve getting-started.rst test execution description</li> <li><a href="082ed70e31"><code>082ed70</code></a> Merge pull request <a href="https://redirect.github.com/pytest-dev/pytest/issues/15255">#15255</a> from pytest-dev/claude/project-thread-eoi3d6</li> <li><a href="ae37a01376"><code>ae37a01</code></a> Merge pull request <a href="https://redirect.github.com/pytest-dev/pytest/issues/15227">#15227</a> from pytest-dev/claude/project-thread-4etye4</li> <li>Additional commits viewable in <a href="https://github.com/pytest-dev/pytest/compare/9.1.1...9.2.0">compare view</a></li> </ul> </details> <br /> Updates `pytest-asyncio` from 1.4.0 to 1.4.1 <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/pytest-dev/pytest-asyncio/releases">pytest-asyncio's releases</a>.</em></p> <blockquote> <h2>pytest-asyncio v1.4.1</h2> <h1><a href="https://github.com/pytest-dev/pytest-asyncio/tree/1.4.1">1.4.1</a> - 2026-10-25</h1> <h2>Added</h2> <ul> <li>Declared support for Python 3.15 (<a href="https://redirect.github.com/pytest-dev/pytest-asyncio/issues/1588">#1588</a>)</li> </ul> <h2>Fixed</h2> <ul> <li>Allow <em>AsyncIterable</em> as a return type for asynchronous generator fixtures decorated with <em>pytest_asyncio.fixture</em> (<a href="https://redirect.github.com/pytest-dev/pytest-asyncio/issues/1090">#1090</a>)</li> </ul> <h2>Notes for Downstream Packagers</h2> <ul> <li>Source-tree development dependencies now use PEP 735 dependency groups and <code>uv.lock</code>. (<a href="https://redirect.github.com/pytest-dev/pytest-asyncio/issues/1518">#1518</a>)</li> </ul> </blockquote> </details> <details> <summary>Commits</summary> <ul> <li><a href="6af7f5c9a8"><code>6af7f5c</code></a> chore: Prepare release of v1.4.1.</li> <li><a href="32ccf64ec1"><code>32ccf64</code></a> Support 3.15 (<a href="https://redirect.github.com/pytest-dev/pytest-asyncio/issues/1588">#1588</a>)</li> <li><a href="983007120d"><code>9830071</code></a> Build(deps): Bump certifi from 2026.6.17 to 2026.10.19 (<a href="https://redirect.github.com/pytest-dev/pytest-asyncio/issues/1590">#1590</a>)</li> <li><a href="0238023e43"><code>0238023</code></a> Build(deps): Bump virtualenv from 21.7.13 to 21.14.13 (<a href="https://redirect.github.com/pytest-dev/pytest-asyncio/issues/1589">#1589</a>)</li> <li><a href="93893ecd94"><code>93893ec</code></a> Build(deps): Bump astral-sh/setup-uv from 10.2.0 to 10.3.0 (<a href="https://redirect.github.com/pytest-dev/pytest-asyncio/issues/1583">#1583</a>)</li> <li><a href="f287e5e0f5"><code>f287e5e</code></a> Build(deps): Bump actions/download-artifact from 8.0.1 to 8.0.2 (<a href="https://redirect.github.com/pytest-dev/pytest-asyncio/issues/1581">#1581</a>)</li> <li><a href="b71da4fe09"><code>b71da4f</code></a> Build(deps-dev): Bump hypothesis from 6.168.3 to 6.168.5 (<a href="https://redirect.github.com/pytest-dev/pytest-asyncio/issues/1582">#1582</a>)</li> <li><a href="d8c51d8990"><code>d8c51d8</code></a> Build(deps): Bump actions/upload-artifact from 7.0.1 to 7.0.2 (<a href="https://redirect.github.com/pytest-dev/pytest-asyncio/issues/1580">#1580</a>)</li> <li><a href="b12808bd8d"><code>b12808b</code></a> Build(deps): Bump virtualenv from 21.7.12 to 21.7.13 (<a href="https://redirect.github.com/pytest-dev/pytest-asyncio/issues/1578">#1578</a>)</li> <li><a href="e0601f0ce9"><code>e0601f0</code></a> Build(deps-dev): Bump coverage from 7.16.1 to 7.16.2 (<a href="https://redirect.github.com/pytest-dev/pytest-asyncio/issues/1577">#1577</a>)</li> <li>Additional commits viewable in <a href="https://github.com/pytest-dev/pytest-asyncio/compare/v1.4.0...v1.4.1">compare view</a></li> </ul> </details> <br /> Updates `pytest-mock` from 3.16.0 to 3.17.0 <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/pytest-dev/pytest-mock/releases">pytest-mock's releases</a>.</em></p> <blockquote> <h2>v3.17.0</h2> <p><em>2026-10-17</em></p> <ul> <li><a href="https://redirect.github.com/pytest-dev/pytest-mock/pull/641">#641</a>: Failures of mock assertions such as <code>assert_called_with</code> are again reported only once, instead of two or three times with the original error from the <code>mock</code> module chained before them.</li> <li><a href="https://redirect.github.com/pytest-dev/pytest-mock/pull/642">#642</a>: Mock assertion failures no longer show misleading introspection when they are not about the arguments of the last call: <code>assert_called</code>, <code>assert_called_once</code>, <code>assert_not_called</code>, <code>assert_any_call</code>, their <code>await</code> counterparts, and <code>assert_called_once_with</code>/<code>assert_awaited_once_with</code> when the mock was not called (awaited) exactly once. The introspection also no longer reports arguments passed by position versus by keyword as different for autospecced mocks, and no longer shows empty <code>Args:</code>/<code>Kwargs:</code> sections when assertion rewriting is not available.</li> <li><a href="https://redirect.github.com/pytest-dev/pytest-mock/pull/643">#643</a>: <code>assert_has_calls</code> and <code>assert_has_awaits</code> failures no longer show pytest introspection, which compared the expected and actual calls position by position and so reported differences between unrelated calls. The mock's own message, listing the expected and actual calls, is still shown.</li> </ul> <h2>v3.16.1</h2> <p><em>2026-10-17</em></p> <ul> <li><a href="https://redirect.github.com/pytest-dev/pytest-mock/pull/617">#617</a>: Fixed <code>assert_has_calls</code> raising <code>ValueError</code> instead of <code>AssertionError</code> (or showing misleading introspection) when the expected calls are plain tuples rather than <code>call(...)</code> objects, such as <code>(args, kwargs)</code> entries of another mock's <code>call_args_list</code>, <code>(args,)</code>, <code>(kwargs,)</code>, <code>(name, args)</code> or <code>(name, kwargs)</code>.</li> <li><a href="https://redirect.github.com/pytest-dev/pytest-mock/pull/621">#621</a>: Fixed <code>mocker.stop()</code> sometimes stopping the wrong mock, for example with mocks from <code>mocker.create_autospec</code>.</li> <li><a href="https://redirect.github.com/pytest-dev/pytest-mock/pull/621">#621</a>: <code>mocker.stop()</code> now undoes the most recent patch first when the same object is used in several patches.</li> <li><a href="https://redirect.github.com/pytest-dev/pytest-mock/pull/623">#623</a>: Fixed misleading introspection in <code>assert_has_awaits</code> failures, and <code>assert_has_calls</code>/<code>assert_has_awaits</code> raising <code>IndexError</code> instead of <code>AssertionError</code> when <code>calls</code> is passed by keyword.</li> <li><a href="https://redirect.github.com/pytest-dev/pytest-mock/pull/624">#624</a>: Clear <code>spy_return_iter</code> after a spied synchronous or asynchronous function raises, matching <code>spy_return</code>.</li> <li><a href="https://redirect.github.com/pytest-dev/pytest-mock/pull/627">#627</a>: Document <code>async_stub</code> await assertions and the distinction between call and await tracking.</li> <li><a href="https://redirect.github.com/pytest-dev/pytest-mock/pull/629">#629</a>: Fixed <code>mocker.resetall()</code> skipping the mocks patched with <code>mocker.patch.multiple()</code>, both the ones it creates and the ones passed explicitly.</li> <li><a href="https://redirect.github.com/pytest-dev/pytest-mock/pull/630">#630</a>: <code>mocker.resetall()</code> now also resets <code>spy_return</code> and <code>spy_exception</code> of spies, like it already did for <code>spy_return_list</code> and <code>spy_return_iter</code>, and no longer overwrites attributes with these names on mocks that are not spies.</li> <li><a href="https://redirect.github.com/pytest-dev/pytest-mock/pull/633">#633</a>: Fixed spies on <code>classmethod</code>, <code>staticmethod</code>, builtins and classes returning a <code>MagicMock</code> instead of calling the spied code after <code>mocker.resetall(side_effect=True)</code>. Resetting a spy's <code>side_effect</code> now goes back to calling the spied code, also clearing any <code>side_effect</code> set on the spy.</li> </ul> </blockquote> </details> <details> <summary>Changelog</summary> <p><em>Sourced from <a href="https://github.com/pytest-dev/pytest-mock/blob/main/CHANGELOG.rst">pytest-mock's changelog</a>.</em></p> <blockquote> <h2>3.17.0</h2> <p><em>2026-10-17</em></p> <ul> <li><code>[#641](https://github.com/pytest-dev/pytest-mock/issues/641) <https://github.com/pytest-dev/pytest-mock/pull/641></code>_: Failures of mock assertions such as <code>assert_called_with</code> are again reported only once, instead of two or three times with the original error from the <code>mock</code> module chained before them.</li> <li><code>[#642](https://github.com/pytest-dev/pytest-mock/issues/642) <https://github.com/pytest-dev/pytest-mock/pull/642></code>_: Mock assertion failures no longer show misleading introspection when they are not about the arguments of the last call: <code>assert_called</code>, <code>assert_called_once</code>, <code>assert_not_called</code>, <code>assert_any_call</code>, their <code>await</code> counterparts, and <code>assert_called_once_with</code>/<code>assert_awaited_once_with</code> when the mock was not called (awaited) exactly once. The introspection also no longer reports arguments passed by position versus by keyword as different for autospecced mocks, and no longer shows empty <code>Args:</code>/<code>Kwargs:</code> sections when assertion rewriting is not available.</li> <li><code>[#643](https://github.com/pytest-dev/pytest-mock/issues/643) <https://github.com/pytest-dev/pytest-mock/pull/643></code>_: <code>assert_has_calls</code> and <code>assert_has_awaits</code> failures no longer show pytest introspection, which compared the expected and actual calls position by position and so reported differences between unrelated calls. The mock's own message, listing the expected and actual calls, is still shown.</li> </ul> <h2>3.16.1</h2> <p><em>2026-10-17</em></p> <ul> <li><code>[#617](https://github.com/pytest-dev/pytest-mock/issues/617) <https://github.com/pytest-dev/pytest-mock/pull/617></code>_: Fixed <code>assert_has_calls</code> raising <code>ValueError</code> instead of <code>AssertionError</code> (or showing misleading introspection) when the expected calls are plain tuples rather than <code>call(...)</code> objects, such as <code>(args, kwargs)</code> entries of another mock's <code>call_args_list</code>, <code>(args,)</code>, <code>(kwargs,)</code>, <code>(name, args)</code> or <code>(name, kwargs)</code>.</li> <li><code>[#621](https://github.com/pytest-dev/pytest-mock/issues/621) <https://github.com/pytest-dev/pytest-mock/pull/621></code>_: Fixed <code>mocker.stop()</code> sometimes stopping the wrong mock, for example with mocks from <code>mocker.create_autospec</code>.</li> <li><code>[#621](https://github.com/pytest-dev/pytest-mock/issues/621) <https://github.com/pytest-dev/pytest-mock/pull/621></code>_: <code>mocker.stop()</code> now undoes the most recent patch first when the same object is used in several patches.</li> <li><code>[#623](https://github.com/pytest-dev/pytest-mock/issues/623) <https://github.com/pytest-dev/pytest-mock/pull/623></code>_: Fixed misleading introspection in <code>assert_has_awaits</code> failures, and <code>assert_has_calls</code>/<code>assert_has_awaits</code> raising <code>IndexError</code> instead of <code>AssertionError</code> when <code>calls</code> is passed by keyword.</li> <li><code>[#624](https://github.com/pytest-dev/pytest-mock/issues/624) <https://github.com/pytest-dev/pytest-mock/pull/624></code>_: Clear <code>spy_return_iter</code> after a spied synchronous or asynchronous function raises, matching <code>spy_return</code>.</li> <li><code>[#627](https://github.com/pytest-dev/pytest-mock/issues/627) <https://github.com/pytest-dev/pytest-mock/pull/627></code>_: Document <code>async_stub</code> await assertions and the distinction between call and await tracking.</li> <li><code>[#629](https://github.com/pytest-dev/pytest-mock/issues/629) <https://github.com/pytest-dev/pytest-mock/pull/629></code>_: Fixed <code>mocker.resetall()</code> skipping the mocks patched with <code>mocker.patch.multiple()</code>, both the ones it creates and the ones passed explicitly.</li> <li><code>[#630](https://github.com/pytest-dev/pytest-mock/issues/630) <https://github.com/pytest-dev/pytest-mock/pull/630></code>_: <code>mocker.resetall()</code> now also resets <code>spy_return</code> and <code>spy_exception</code> of spies, like it already did for <code>spy_return_list</code> and <code>spy_return_iter</code>, and no longer overwrites attributes with these names on mocks that are not spies.</li> <li><code>[#633](https://github.com/pytest-dev/pytest-mock/issues/633) <https://github.com/pytest-dev/pytest-mock/pull/633></code>_: Fixed spies on <code>classmethod</code>, <code>staticmethod</code>, builtins and classes returning a <code>MagicMock</code> instead of calling the spied code after <code>mocker.resetall(side_effect=True)</code>. Resetting a spy's <code>side_effect</code> now goes back to calling the spied code, also clearing any <code>side_effect</code> set on the spy.</li> </ul> </blockquote> </details> <details> <summary>Commits</summary> <ul> <li><a href="5c2f207ca7"><code>5c2f207</code></a> Release 3.17.0</li> <li><a href="96252715fa"><code>9625271</code></a> Bump the minor version for releases that change existing behavior</li> <li><a href="34b87aeeef"><code>34b87ae</code></a> Drop introspection from assert_has_calls and assert_has_awaits (<a href="https://redirect.github.com/pytest-dev/pytest-mock/issues/643">#643</a>)</li> <li><a href="866520f2d3"><code>866520f</code></a> Only show introspection for failures about the call arguments (<a href="https://redirect.github.com/pytest-dev/pytest-mock/issues/642">#642</a>)</li> <li><a href="5ab41c143c"><code>5ab41c1</code></a> Do not chain the original mock error to wrapped assertion failures (<a href="https://redirect.github.com/pytest-dev/pytest-mock/issues/641">#641</a>)</li> <li><a href="1916b14db2"><code>1916b14</code></a> Merge pull request <a href="https://redirect.github.com/pytest-dev/pytest-mock/issues/635">#635</a> from nicoddemus/docs-contributing-resetall</li> <li><a href="212fcd903a"><code>212fcd9</code></a> Document resetall, the changelog format and running tests with tox</li> <li><a href="9374b2c3e3"><code>9374b2c</code></a> Merge pull request <a href="https://redirect.github.com/pytest-dev/pytest-mock/issues/634">#634</a> from pytest-dev/release-3.16.1</li> <li><a href="fab730daf4"><code>fab730d</code></a> Release 3.16.1</li> <li><a href="d26d41bb01"><code>d26d41b</code></a> Merge pull request <a href="https://redirect.github.com/pytest-dev/pytest-mock/issues/627">#627</a> from xiehuanyi/docs/async-stub-awaits-20261012-r2</li> <li>Additional commits viewable in <a href="https://github.com/pytest-dev/pytest-mock/compare/v3.16.0...v3.17.0">compare view</a></li> </ul> </details> <br /> Updates `ruff` from 0.16.9 to 0.17.3 <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/astral-sh/ruff/releases">ruff's releases</a>.</em></p> <blockquote> <h2>0.17.3</h2> <h2>Release Notes</h2> <p>Released on 2026-10-26.</p> <h3>Preview features</h3> <ul> <li>[<code>suspicious</code>] Add <code>shared-clock-mock</code> (<a href="https://redirect.github.com/astral-sh/ruff/pull/29074">#29074</a>)</li> </ul> <h3>Bug fixes</h3> <ul> <li>[<code>pyupgrade</code>] Avoid incorrect conversions to f-strings (<code>UP032</code>) (<a href="https://redirect.github.com/astral-sh/ruff/pull/25485">#25485</a>)</li> </ul> <h3>Performance</h3> <ul> <li>Buffer stdout in <code>ruff format</code> (<a href="https://redirect.github.com/astral-sh/ruff/pull/29631">#29631</a>)</li> <li>Specialize ASCII identifier lexing (<a href="https://redirect.github.com/astral-sh/ruff/pull/29503">#29503</a>)</li> <li>Speed up identifier and keyword lexing (<a href="https://redirect.github.com/astral-sh/ruff/pull/29463">#29463</a>)</li> </ul> <h3>Documentation</h3> <ul> <li>[<code>flake8-bandit</code>] Describe what the rule actually checks for <code>httpx</code> (<code>S113</code>) (<a href="https://redirect.github.com/astral-sh/ruff/pull/27936">#27936</a>)</li> </ul> <h3>Contributors</h3> <ul> <li><a href="https://github.com/itsvedantkumar"><code>@itsvedantkumar</code></a></li> <li><a href="https://github.com/charliermarsh"><code>@charliermarsh</code></a></li> <li><a href="https://github.com/anishgirianish"><code>@anishgirianish</code></a></li> </ul> <h2>Install ruff 0.17.3</h2> <h3>Install prebuilt binaries via shell script</h3> <pre lang="sh"><code>curl --proto '=https' --tlsv1.2 -LsSf https://releases.astral.sh/github/ruff/releases/download/0.17.3/ruff-installer.sh | sh </code></pre> <h3>Install prebuilt binaries via powershell script</h3> <pre lang="sh"><code>powershell -ExecutionPolicy Bypass -c "irm https://releases.astral.sh/github/ruff/releases/download/0.17.3/ruff-installer.ps1 | iex" </code></pre> <h2>Download ruff 0.17.3</h2> <table> <thead> <tr> <th>File</th> <th>Platform</th> <th>Checksum</th> </tr> </thead> <tbody> <tr> <td><a href="https://releases.astral.sh/github/ruff/releases/download/0.17.3/ruff-aarch64-apple-darwin.tar.gz">ruff-aarch64-apple-darwin.tar.gz</a></td> <td>Apple Silicon macOS</td> <td><a href="https://releases.astral.sh/github/ruff/releases/download/0.17.3/ruff-aarch64-apple-darwin.tar.gz.sha256">checksum</a></td> </tr> <tr> <td><a href="https://releases.astral.sh/github/ruff/releases/download/0.17.3/ruff-x86_64-apple-darwin.tar.gz">ruff-x86_64-apple-darwin.tar.gz</a></td> <td>Intel macOS</td> <td><a href="https://releases.astral.sh/github/ruff/releases/download/0.17.3/ruff-x86_64-apple-darwin.tar.gz.sha256">checksum</a></td> </tr> <tr> <td><a href="https://releases.astral.sh/github/ruff/releases/download/0.17.3/ruff-aarch64-pc-windows-msvc.zip">ruff-aarch64-pc-windows-msvc.zip</a></td> <td>ARM64 Windows</td> <td><a href="https://releases.astral.sh/github/ruff/releases/download/0.17.3/ruff-aarch64-pc-windows-msvc.zip.sha256">checksum</a></td> </tr> </tbody> </table> <!-- raw HTML omitted --> </blockquote> <p>... (truncated)</p> </details> <details> <summary>Changelog</summary> <p><em>Sourced from <a href="https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md">ruff's changelog</a>.</em></p> <blockquote> <h2>0.17.3</h2> <p>Released on 2026-10-26.</p> <h3>Preview features</h3> <ul> <li>[<code>suspicious</code>] Add <code>shared-clock-mock</code> (<a href="https://redirect.github.com/astral-sh/ruff/pull/29074">#29074</a>)</li> </ul> <h3>Bug fixes</h3> <ul> <li>[<code>pyupgrade</code>] Avoid incorrect conversions to f-strings (<code>UP032</code>) (<a href="https://redirect.github.com/astral-sh/ruff/pull/25485">#25485</a>)</li> </ul> <h3>Performance</h3> <ul> <li>Buffer stdout in <code>ruff format</code> (<a href="https://redirect.github.com/astral-sh/ruff/pull/29631">#29631</a>)</li> <li>Specialize ASCII identifier lexing (<a href="https://redirect.github.com/astral-sh/ruff/pull/29503">#29503</a>)</li> <li>Speed up identifier and keyword lexing (<a href="https://redirect.github.com/astral-sh/ruff/pull/29463">#29463</a>)</li> </ul> <h3>Documentation</h3> <ul> <li>[<code>flake8-bandit</code>] Describe what the rule actually checks for <code>httpx</code> (<code>S113</code>) (<a href="https://redirect.github.com/astral-sh/ruff/pull/27936">#27936</a>)</li> </ul> <h3>Contributors</h3> <ul> <li><a href="https://github.com/itsvedantkumar"><code>@itsvedantkumar</code></a></li> <li><a href="https://github.com/charliermarsh"><code>@charliermarsh</code></a></li> <li><a href="https://github.com/anishgirianish"><code>@anishgirianish</code></a></li> </ul> <h2>0.17.2</h2> <p>Released on 2026-10-22.</p> <h3>Preview features</h3> <ul> <li>[<code>complexity</code>] Add <code>unnecessary-regular-expression-compile</code> (<a href="https://redirect.github.com/astral-sh/ruff/pull/25533">#25533</a>)</li> </ul> <h3>Bug fixes</h3> <ul> <li>Avoid syntax errors for type variables with starred constraints (<code>UP040</code>, <code>UP046</code>, <code>UP047</code>, <code>RUF053</code>) (<a href="https://redirect.github.com/astral-sh/ruff/pull/28362">#28362</a>)</li> <li>[<code>pydocstyle</code>] Treat backslash-escaped <code>*args</code> and <code>**kwargs</code> as documented (<code>D417</code>) (<a href="https://redirect.github.com/astral-sh/ruff/pull/29536">#29536</a>)</li> <li>[<code>pylint</code>] Avoid false positive on starred elements (<code>PLE0643</code>) (<a href="https://redirect.github.com/astral-sh/ruff/pull/29483">#29483</a>)</li> <li>[<code>pylint</code>] Mark fixes unsafe when deleting comments (<code>PLR5501</code>, <code>PLW0120</code>) (<a href="https://redirect.github.com/astral-sh/ruff/pull/29414">#29414</a>)</li> <li>[<code>pyupgrade</code>] Mark fix unsafe when deleting comments (<code>UP035</code>) (<a href="https://redirect.github.com/astral-sh/ruff/pull/29413">#29413</a>)</li> </ul> <h3>Performance</h3> <ul> <li>Avoid intermediate names in lint name resolution (<a href="https://redirect.github.com/astral-sh/ruff/pull/29506">#29506</a>)</li> <li>Prefilter bidirectional Unicode checks by UTF-8 leading bytes (<a href="https://redirect.github.com/astral-sh/ruff/pull/29561">#29561</a>)</li> <li>Share postfix parsing and reduce expression copies (<a href="https://redirect.github.com/astral-sh/ruff/pull/29480">#29480</a>)</li> </ul> <!-- raw HTML omitted --> </blockquote> <p>... (truncated)</p> </details> <details> <summary>Commits</summary> <ul> <li><a href="ba65abf8ba"><code>ba65abf</code></a> Bump version to 0.17.3 (<a href="https://redirect.github.com/astral-sh/ruff/issues/29745">#29745</a>)</li> <li><a href="fb2f921879"><code>fb2f921</code></a> [ty] Fix narrowing of strings and integers compared with enum members (<a href="https://redirect.github.com/astral-sh/ruff/issues/29743">#29743</a>)</li> <li><a href="d1812878d5"><code>d181287</code></a> [ty] Index nominal union alternatives (<a href="https://redirect.github.com/astral-sh/ruff/issues/29196">#29196</a>)</li> <li><a href="07872adbaf"><code>07872ad</code></a> [ty] Preserve string literals in comparisons with <code>LiteralString</code> (<a href="https://redirect.github.com/astral-sh/ruff/issues/29741">#29741</a>)</li> <li><a href="95888b2edf"><code>95888b2</code></a> [ty] Preserve narrowing after guarded match subject captures (<a href="https://redirect.github.com/astral-sh/ruff/issues/29558">#29558</a>)</li> <li><a href="3c8166b683"><code>3c8166b</code></a> [ty] Fix hang when negating recursive unions of instance types (<a href="https://redirect.github.com/astral-sh/ruff/issues/29652">#29652</a>)</li> <li><a href="3fd20e0859"><code>3fd20e0</code></a> [ty] Preserve generic callback specializations during return refinement (<a href="https://redirect.github.com/astral-sh/ruff/issues/29667">#29667</a>)</li> <li><a href="2f0a29ece1"><code>2f0a29e</code></a> [ty] Record predicate truthiness alongside expression inference (<a href="https://redirect.github.com/astral-sh/ruff/issues/29706">#29706</a>)</li> <li><a href="60f104a1a2"><code>60f104a</code></a> [ty] Honor <a href="https://github.com/override"><code>@override</code></a> on overload implementations in stubs (<a href="https://redirect.github.com/astral-sh/ruff/issues/29470">#29470</a>)</li> <li><a href="207ec3affe"><code>207ec3a</code></a> [ty] Add diagnostic baseline support (<a href="https://redirect.github.com/astral-sh/ruff/issues/27636">#27636</a>)</li> <li>Additional commits viewable in <a href="https://github.com/astral-sh/ruff/compare/0.16.9...0.17.3">compare view</a></li> </ul> </details> <br /> Updates `ty` from 0.0.84 to 0.0.94 <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/astral-sh/ty/releases">ty's releases</a>.</em></p> <blockquote> <h2>0.0.94</h2> <h2>Release Notes</h2> <p>Released on 2026-10-28.</p> <h3>Bug fixes</h3> <ul> <li>Correctly handle line continuation when fixing unused ignore comments (<a href="https://redirect.github.com/astral-sh/ruff/pull/29781">#29781</a>)</li> <li>Fix Linux x86-64 startup on older kernels (<a href="https://redirect.github.com/astral-sh/ty/pull/4853">#4853</a>)</li> <li>Fix a panic when a comprehension filter depends on a later binding (<a href="https://redirect.github.com/astral-sh/ruff/pull/29786">#29786</a>)</li> <li>Fix a panic when sorting diagnostics without a source location (<a href="https://redirect.github.com/astral-sh/ruff/pull/29780">#29780</a>)</li> <li>Fix panic on a chained assignment with a missing value (<a href="https://redirect.github.com/astral-sh/ruff/pull/29787">#29787</a>)</li> <li>Reject defaulted TypeVars after a TypeVarTuple in legacy generic classes (<a href="https://redirect.github.com/astral-sh/ruff/pull/29753">#29753</a>)</li> </ul> <h3>Other changes</h3> <ul> <li>Django: suppress invalid-override errors for <code>Meta</code> configurations (<a href="https://redirect.github.com/astral-sh/ruff/pull/29769">#29769</a>)</li> </ul> <h3>Contributors</h3> <ul> <li><a href="https://github.com/sharkdp"><code>@sharkdp</code></a></li> <li><a href="https://github.com/charliermarsh"><code>@charliermarsh</code></a></li> <li><a href="https://github.com/MichaReiser"><code>@MichaReiser</code></a></li> </ul> <h2>Install ty 0.0.94</h2> <h3>Install prebuilt binaries via shell script</h3> <pre lang="sh"><code>curl --proto '=https' --tlsv1.2 -LsSf https://releases.astral.sh/github/ty/releases/download/0.0.94/ty-installer.sh | sh </code></pre> <h3>Install prebuilt binaries via powershell script</h3> <pre lang="sh"><code>powershell -ExecutionPolicy Bypass -c "irm https://releases.astral.sh/github/ty/releases/download/0.0.94/ty-installer.ps1 | iex" </code></pre> <h2>Download ty 0.0.94</h2> <table> <thead> <tr> <th>File</th> <th>Platform</th> <th>Checksum</th> </tr> </thead> <tbody> <tr> <td><a href="https://releases.astral.sh/github/ty/releases/download/0.0.94/ty-aarch64-apple-darwin.tar.gz">ty-aarch64-apple-darwin.tar.gz</a></td> <td>Apple Silicon macOS</td> <td><a href="https://releases.astral.sh/github/ty/releases/download/0.0.94/ty-aarch64-apple-darwin.tar.gz.sha256">checksum</a></td> </tr> <tr> <td><a href="https://releases.astral.sh/github/ty/releases/download/0.0.94/ty-x86_64-apple-darwin.tar.gz">ty-x86_64-apple-darwin.tar.gz</a></td> <td>Intel macOS</td> <td><a href="https://releases.astral.sh/github/ty/releases/download/0.0.94/ty-x86_64-apple-darwin.tar.gz.sha256">checksum</a></td> </tr> <tr> <td><a href="https://releases.astral.sh/github/ty/releases/download/0.0.94/ty-aarch64-pc-windows-msvc.zip">ty-aarch64-pc-windows-msvc.zip</a></td> <td>ARM64 Windows</td> <td><a href="https://releases.astral.sh/github/ty/releases/download/0.0.94/ty-aarch64-pc-windows-msvc.zip.sha256">checksum</a></td> </tr> <tr> <td><a href="https://releases.astral.sh/github/ty/releases/download/0.0.94/ty-i686-pc-windows-msvc.zip">ty-i686-pc-windows-msvc.zip</a></td> <td>x86 Windows</td> <td><a href="https://releases.astral.sh/github/ty/releases/download/0.0.94/ty-i686-pc-windows-msvc.zip.sha256">checksum</a></td> </tr> <tr> <td><a href="https://releases.astral.sh/github/ty/releases/download/0.0.94/ty-x86_64-pc-windows-msvc.zip">ty-x86_64-pc-windows-msvc.zip</a></td> <td>x64 Windows</td> <td><a href="https://releases.astral.sh/github/ty/releases/download/0.0.94/ty-x86_64-pc-windows-msvc.zip.sha256">checksum</a></td> </tr> <tr> <td><a href="https://releases.astral.sh/github/ty/releases/download/0.0.94/ty-aarch64-unknown-linux-gnu.tar.gz">ty-aarch64-unknown-linux-gnu.tar.gz</a></td> <td>ARM64 Linux</td> <td><a href="https://releases.astral.sh/github/ty/releases/download/0.0.94/ty-aarch64-unknown-linux-gnu.tar.gz.sha256">checksum</a></td> </tr> <tr> <td><a href="https://releases.astral.sh/github/ty/releases/download/0.0.94/ty-i686-unknown-linux-gnu.tar.gz">ty-i686-unknown-linux-gnu.tar.gz</a></td> <td>x86 Linux</td> <td><a href="https://releases.astral.sh/github/ty/releases/download/0.0.94/ty-i686-unknown-linux-gnu.tar.gz.sha256">checksum</a></td> </tr> <tr> <td><a href="https://releases.astral.sh/github/ty/releases/download/0.0.94/ty-powerpc64le-unknown-linux-gnu.tar.gz">ty-powerpc64le-unknown-linux-gnu.tar.gz</a></td> <td>PPC64LE Linux</td> <td><a href="https://releases.astral.sh/github/ty/releases/download/0.0.94/ty-powerpc64le-unknown-linux-gnu.tar.gz.sha256">checksum</a></td> </tr> </tbody> </table> <!-- raw HTML omitted --> </blockquote> <p>... (truncated)</p> </details> <details> <summary>Changelog</summary> <p><em>Sourced from <a href="https://github.com/astral-sh/ty/blob/main/CHANGELOG.md">ty's changelog</a>.</em></p> <blockquote> <h2>0.0.94</h2> <p>Released on 2026-10-28.</p> <h3>Bug fixes</h3> <ul> <li>Correctly handle line continuation when fixing unused ignore comments (<a href="https://redirect.github.com/astral-sh/ruff/pull/29781">#29781</a>)</li> <li>Fix Linux x86-64 startup on older kernels (<a href="https://redirect.github.com/astral-sh/ty/pull/4853">#4853</a>)</li> <li>Fix a panic when a comprehension filter depends on a later binding (<a href="https://redirect.github.com/astral-sh/ruff/pull/29786">#29786</a>)</li> <li>Fix a panic when sorting diagnostics without a source location (<a href="https://redirect.github.com/astral-sh/ruff/pull/29780">#29780</a>)</li> <li>Fix panic on a chained assignment with a missing value (<a href="https://redirect.github.com/astral-sh/ruff/pull/29787">#29787</a>)</li> <li>Reject defaulted TypeVars after a TypeVarTuple in legacy generic classes (<a href="https://redirect.github.com/astral-sh/ruff/pull/29753">#29753</a>)</li> </ul> <h3>Other changes</h3> <ul> <li>Django: suppress invalid-override errors for <code>Meta</code> configurations (<a href="https://redirect.github.com/astral-sh/ruff/pull/29769">#29769</a>)</li> </ul> <h3>Contributors</h3> <ul> <li><a href="https://github.com/sharkdp"><code>@sharkdp</code></a></li> <li><a href="https://github.com/charliermarsh"><code>@charliermarsh</code></a></li> <li><a href="https://github.com/MichaReiser"><code>@MichaReiser</code></a></li> </ul> <h2>0.0.93</h2> <p>Released on 2026-10-28.</p> <h3>Preview features</h3> <ul> <li> <p>Add diagnostic baselines to help adopt ty in projects with existing errors (<a href="https://redirect.github.com/astral-sh/ruff/pull/27636">#27636</a>). Configure a baseline in <code>pyproject.toml</code>:</p> <pre lang="toml"><code>[tool.ty] baseline = "ty-baseline.json" </code></pre> <p>Run <code>ty check --update-baseline</code> to record existing diagnostics. Subsequent checks filter matching diagnostics from CLI output and show them as hints in the language server. The baseline format may change while the feature is in preview.</p> </li> </ul> <h3>Bug fixes</h3> <ul> <li>Fix a panic when checking truthiness in a loop (<a href="https://redirect.github.com/astral-sh/ruff/pull/29759">#29759</a>)</li> <li>Fix hang when negating recursive unions of instance types (<a href="https://redirect.github.com/astral-sh/ruff/pull/29652">#29652</a>)</li> </ul> <h3>Core type checking</h3> <ul> <li>Avoid synthesizing primary keys for abstract Django models (<a href="https://redirect.github.com/astral-sh/ruff/pull/29744">#29744</a>)</li> <li>Combine constraints from repeated <code>ParamSpec</code>s (<a href="https://redirect.github.com/astral-sh/ruff/pull/29172">#29172</a>)</li> <li>Fix narrowing of strings and integers compared with enum members (<a href="https://redirect.github.com/astral-sh/ruff/pull/29743">#29743</a>)</li> <li>Honor <code>@override</code> on overload implementations in stubs (<a href="https://redirect.github.com/astral-sh/ruff/pull/29470">#29470</a>)</li> <li>Preserve caller type variables in nested union inference (<a href="https://redirect.github.com/astral-sh/ruff/pull/29611">#29611</a>)</li> </ul> <!-- raw HTML omitted --> </blockquote> <p>... (truncated)</p> </details> <details> <summary>Commits</summary> <ul> <li><a href="f8ea270e0b"><code>f8ea270</code></a> Bump version to 0.0.94 (<a href="https://redirect.github.com/astral-sh/ty/issues/4857">#4857</a>)</li> <li><a href="7a36fc9131"><code>7a36fc9</code></a> Fix Linux x86-64 startup on older kernels (<a href="https://redirect.github.com/astral-sh/ty/issues/4853">#4853</a>)</li> <li><a href="3db5e4df7b"><code>3db5e4d</code></a> Bump version to 0.0.93 (<a href="https://redirect.github.com/astral-sh/ty/issues/4842">#4842</a>)</li> <li><a href="f8fd0e8b5c"><code>f8fd0e8</code></a> Update astral-sh/setup-uv action to v10.3.2 (<a href="https://redirect.github.com/astral-sh/ty/issues/4843">#4843</a>)</li> <li><a href="c1ca420006"><code>c1ca420</code></a> Update uv to v0.13.6 (<a href="https://redirect.github.com/astral-sh/ty/issues/4845">#4845</a>)</li> <li><a href="4c5c9079ac"><code>4c5c907</code></a> Update prek dependencies (<a href="https://redirect.github.com/astral-sh/ty/issues/4844">#4844</a>)</li> <li><a href="0445d6497a"><code>0445d64</code></a> Optimize Linux x86-64 ty releases with LLVM BOLT (<a href="https://redirect.github.com/astral-sh/ty/issues/4833">#4833</a>)</li> <li><a href="3933e6918b"><code>3933e69</code></a> Bump version to 0.0.92 (<a href="https://redirect.github.com/astral-sh/ty/issues/4821">#4821</a>)</li> <li><a href="9aaec9ba58"><code>9aaec9b</code></a> Handle AI policy labels through Actions (<a href="https://redirect.github.com/astral-sh/ty/issues/4812">#4812</a>)</li> <li><a href="e1b8efaafd"><code>e1b8efa</code></a> Update uv to 0.13.5 (<a href="https://redirect.github.com/astral-sh/ty/issues/4809">#4809</a>)</li> <li>Additional commits viewable in <a href="https://github.com/astral-sh/ty/compare/0.0.84...0.0.94">compare view</a></li> </ul> </details> <br /> Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore <dependency name> major version` will close this group update PR and stop Dependabot creating any more for the specific dependency's major version (unless you unignore this specific dependency's major version or upgrade to it yourself) - `@dependabot ignore <dependency name> minor version` will close this group update PR and stop Dependabot creating any more for the specific dependency's minor version (unless you unignore this specific dependency's minor version or upgrade to it yourself) - `@dependabot ignore <dependency name>` will close this group update PR and stop Dependabot creating any more for the specific dependency (unless you unignore this specific dependency or upgrade to it yourself) - `@dependabot unignore <dependency name>` will remove all of the ignore conditions of the specified dependency - `@dependabot unignore <dependency name> <ignore condition>` will remove the ignore condition of the specified dependency and ignore conditions </details> --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: John Kennedy <jkennedyvz@users.noreply.github.com> Co-authored-by: Robin <open-swe@users.noreply.github.com>
811 lines
29 KiB
Python
811 lines
29 KiB
Python
import asyncio
|
|
import os
|
|
import tempfile
|
|
import uuid
|
|
from collections.abc import AsyncGenerator, AsyncIterator, Generator, Iterable
|
|
from contextlib import asynccontextmanager
|
|
from typing import cast
|
|
|
|
import pytest
|
|
from langgraph.store.base import (
|
|
GetOp,
|
|
InvalidNamespaceError,
|
|
Item,
|
|
ListNamespacesOp,
|
|
MatchCondition,
|
|
PutOp,
|
|
SearchOp,
|
|
)
|
|
|
|
from langgraph.store.sqlite import AsyncSqliteStore
|
|
from langgraph.store.sqlite.base import SqliteIndexConfig
|
|
from tests.test_store import CharacterEmbeddings
|
|
|
|
|
|
@pytest.fixture(scope="function", params=["memory", "file"])
|
|
async def store(request: pytest.FixtureRequest) -> AsyncIterator[AsyncSqliteStore]:
|
|
"""Create an AsyncSqliteStore for testing."""
|
|
if request.param == "memory":
|
|
# In-memory store
|
|
async with AsyncSqliteStore.from_conn_string(":memory:") as store:
|
|
await store.setup()
|
|
yield store
|
|
else:
|
|
# Temporary file store
|
|
temp_file = tempfile.NamedTemporaryFile(delete=False)
|
|
temp_file.close()
|
|
try:
|
|
async with AsyncSqliteStore.from_conn_string(temp_file.name) as store:
|
|
await store.setup()
|
|
yield store
|
|
finally:
|
|
os.unlink(temp_file.name)
|
|
|
|
|
|
@pytest.fixture(scope="function")
|
|
def fake_embeddings() -> CharacterEmbeddings:
|
|
"""Create fake embeddings for testing."""
|
|
return CharacterEmbeddings(dims=500)
|
|
|
|
|
|
@asynccontextmanager
|
|
async def create_vector_store(
|
|
fake_embeddings: CharacterEmbeddings,
|
|
conn_string: str = ":memory:",
|
|
text_fields: list[str] | None = None,
|
|
) -> AsyncGenerator[AsyncSqliteStore, None]:
|
|
"""Create an AsyncSqliteStore with vector search capabilities."""
|
|
index_config: SqliteIndexConfig = {
|
|
"dims": fake_embeddings.dims,
|
|
"embed": fake_embeddings,
|
|
"text_fields": text_fields,
|
|
}
|
|
|
|
async with AsyncSqliteStore.from_conn_string(
|
|
conn_string, index=index_config
|
|
) as store:
|
|
await store.setup()
|
|
yield store
|
|
|
|
|
|
@pytest.fixture(scope="function", params=["memory", "file"])
|
|
def conn_string(request: pytest.FixtureRequest) -> Generator[str, None, None]:
|
|
if request.param == "memory":
|
|
yield ":memory:"
|
|
else:
|
|
temp_file = tempfile.NamedTemporaryFile(delete=False)
|
|
temp_file.close()
|
|
try:
|
|
yield temp_file.name
|
|
finally:
|
|
os.unlink(temp_file.name)
|
|
|
|
|
|
async def test_no_running_loop(store: AsyncSqliteStore) -> None:
|
|
"""Test that sync methods raise proper errors in the main thread."""
|
|
with pytest.raises(asyncio.InvalidStateError):
|
|
store.put(("foo", "bar"), "baz", {"val": "baz"})
|
|
with pytest.raises(asyncio.InvalidStateError):
|
|
store.get(("foo", "bar"), "baz")
|
|
with pytest.raises(asyncio.InvalidStateError):
|
|
store.delete(("foo", "bar"), "baz")
|
|
with pytest.raises(asyncio.InvalidStateError):
|
|
store.search(("foo", "bar"))
|
|
with pytest.raises(asyncio.InvalidStateError):
|
|
store.list_namespaces(prefix=("foo",))
|
|
with pytest.raises(asyncio.InvalidStateError):
|
|
store.batch([PutOp(namespace=("foo", "bar"), key="baz", value={"val": "baz"})])
|
|
|
|
|
|
async def test_large_batches_async(store: AsyncSqliteStore) -> None:
|
|
"""Test processing large batch operations asynchronously."""
|
|
N = 100
|
|
M = 10
|
|
coros = []
|
|
for m in range(M):
|
|
for i in range(N):
|
|
coros.append(
|
|
store.aput(
|
|
("test", "foo", "bar", "baz", str(m % 2)),
|
|
f"key{i}",
|
|
value={"foo": "bar" + str(i)},
|
|
)
|
|
)
|
|
coros.append(
|
|
asyncio.create_task(
|
|
store.aget(
|
|
("test", "foo", "bar", "baz", str(m % 2)),
|
|
f"key{i}",
|
|
)
|
|
)
|
|
)
|
|
coros.append(
|
|
asyncio.create_task(
|
|
store.alist_namespaces(
|
|
prefix=None,
|
|
max_depth=m + 1,
|
|
)
|
|
)
|
|
)
|
|
coros.append(
|
|
asyncio.create_task(
|
|
store.asearch(
|
|
("test",),
|
|
)
|
|
)
|
|
)
|
|
coros.append(
|
|
store.aput(
|
|
("test", "foo", "bar", "baz", str(m % 2)),
|
|
f"key{i}",
|
|
value={"foo": "bar" + str(i)},
|
|
)
|
|
)
|
|
coros.append(
|
|
store.adelete(
|
|
("test", "foo", "bar", "baz", str(m % 2)),
|
|
f"key{i}",
|
|
)
|
|
)
|
|
|
|
results = await asyncio.gather(*coros)
|
|
assert len(results) == M * N * 6
|
|
|
|
|
|
async def test_abatch_order(store: AsyncSqliteStore) -> None:
|
|
"""Test ordering of batch operations in async context."""
|
|
# Setup test data
|
|
await store.aput(("test", "foo"), "key1", {"data": "value1"})
|
|
await store.aput(("test", "bar"), "key2", {"data": "value2"})
|
|
|
|
ops = [
|
|
GetOp(namespace=("test", "foo"), key="key1"),
|
|
PutOp(namespace=("test", "bar"), key="key2", value={"data": "value2"}),
|
|
SearchOp(
|
|
namespace_prefix=("test",), filter={"data": "value1"}, limit=10, offset=0
|
|
),
|
|
ListNamespacesOp(match_conditions=None, max_depth=None, limit=10, offset=0),
|
|
GetOp(namespace=("test",), key="key3"),
|
|
]
|
|
|
|
results = await store.abatch(
|
|
cast(Iterable[GetOp | PutOp | SearchOp | ListNamespacesOp], ops)
|
|
)
|
|
assert len(results) == 5
|
|
assert isinstance(results[0], Item)
|
|
assert isinstance(results[0].value, dict)
|
|
assert results[0].value == {"data": "value1"}
|
|
assert results[0].key == "key1"
|
|
assert results[1] is None # Put operation returns None
|
|
assert isinstance(results[2], list)
|
|
# SQLite query implementation might return different results
|
|
# Just check that we get a list back and don't check the exact content
|
|
assert isinstance(results[3], list)
|
|
assert len(results[3]) > 0
|
|
assert results[4] is None # Non-existent key returns None
|
|
|
|
# Test reordered operations
|
|
ops_reordered = [
|
|
SearchOp(namespace_prefix=("test",), filter=None, limit=5, offset=0),
|
|
GetOp(namespace=("test", "bar"), key="key2"),
|
|
ListNamespacesOp(match_conditions=None, max_depth=None, limit=5, offset=0),
|
|
PutOp(namespace=("test",), key="key3", value={"data": "value3"}),
|
|
GetOp(namespace=("test", "foo"), key="key1"),
|
|
]
|
|
|
|
results_reordered = await store.abatch(
|
|
cast(Iterable[GetOp | PutOp | SearchOp | ListNamespacesOp], ops_reordered)
|
|
)
|
|
assert len(results_reordered) == 5
|
|
assert isinstance(results_reordered[0], list)
|
|
assert len(results_reordered[0]) >= 2 # Should find at least our two test items
|
|
assert isinstance(results_reordered[1], Item)
|
|
assert results_reordered[1].value == {"data": "value2"}
|
|
assert results_reordered[1].key == "key2"
|
|
assert isinstance(results_reordered[2], list)
|
|
assert len(results_reordered[2]) > 0
|
|
assert results_reordered[3] is None # Put operation returns None
|
|
assert isinstance(results_reordered[4], Item)
|
|
assert results_reordered[4].value == {"data": "value1"}
|
|
assert results_reordered[4].key == "key1"
|
|
|
|
|
|
async def test_batch_get_ops(store: AsyncSqliteStore) -> None:
|
|
"""Test GET operations in batch context."""
|
|
# Setup test data
|
|
await store.aput(("test",), "key1", {"data": "value1"})
|
|
await store.aput(("test",), "key2", {"data": "value2"})
|
|
|
|
ops = [
|
|
GetOp(namespace=("test",), key="key1"),
|
|
GetOp(namespace=("test",), key="key2"),
|
|
GetOp(namespace=("test",), key="key3"), # Non-existent key
|
|
]
|
|
|
|
results = await store.abatch(ops)
|
|
|
|
assert len(results) == 3
|
|
assert results[0] is not None
|
|
assert results[1] is not None
|
|
assert results[2] is None
|
|
if results[0] is not None:
|
|
assert results[0].key == "key1"
|
|
if results[1] is not None:
|
|
assert results[1].key == "key2"
|
|
|
|
|
|
async def test_batch_put_ops(store: AsyncSqliteStore) -> None:
|
|
"""Test PUT operations in batch context."""
|
|
ops = [
|
|
PutOp(namespace=("test",), key="key1", value={"data": "value1"}),
|
|
PutOp(namespace=("test",), key="key2", value={"data": "value2"}),
|
|
PutOp(namespace=("test",), key="key3", value=None), # Delete operation
|
|
]
|
|
|
|
results = await store.abatch(ops)
|
|
assert len(results) == 3
|
|
assert all(result is None for result in results)
|
|
|
|
# Verify the puts worked
|
|
items = await store.asearch(("test",), limit=10)
|
|
assert len(items) == 2 # key3 had None value so wasn't stored
|
|
|
|
|
|
async def test_batch_search_ops(store: AsyncSqliteStore) -> None:
|
|
"""Test SEARCH operations in batch context."""
|
|
# Setup test data
|
|
await store.aput(("test", "foo"), "key1", {"data": "value1"})
|
|
await store.aput(("test", "bar"), "key2", {"data": "value2"})
|
|
|
|
ops = [
|
|
SearchOp(
|
|
namespace_prefix=("test",), filter={"data": "value1"}, limit=10, offset=0
|
|
),
|
|
SearchOp(namespace_prefix=("test",), filter=None, limit=5, offset=0),
|
|
]
|
|
|
|
results = await store.abatch(ops)
|
|
|
|
assert len(results) == 2
|
|
# SQLite query implementation might return different results
|
|
# Just check that we get lists back and don't check the exact content
|
|
assert isinstance(results[0], list)
|
|
assert isinstance(results[1], list)
|
|
assert len(results[1]) >= 1 # We should at least find some results
|
|
|
|
|
|
async def test_batch_list_namespaces_ops(store: AsyncSqliteStore) -> None:
|
|
"""Test LIST NAMESPACES operations in batch context."""
|
|
# Setup test data
|
|
await store.aput(("test", "namespace1"), "key1", {"data": "value1"})
|
|
await store.aput(("test", "namespace2"), "key2", {"data": "value2"})
|
|
|
|
ops = [ListNamespacesOp(match_conditions=None, max_depth=None, limit=10, offset=0)]
|
|
|
|
results = await store.abatch(ops)
|
|
|
|
assert len(results) == 1
|
|
if isinstance(results[0], list):
|
|
assert len(results[0]) == 2
|
|
assert ("test", "namespace1") in results[0]
|
|
assert ("test", "namespace2") in results[0]
|
|
|
|
|
|
async def test_vector_store_initialization(
|
|
fake_embeddings: CharacterEmbeddings,
|
|
) -> None:
|
|
"""Test store initialization with embedding config."""
|
|
async with create_vector_store(fake_embeddings) as store:
|
|
assert store.index_config is not None
|
|
assert store.index_config["dims"] == fake_embeddings.dims
|
|
if hasattr(store.index_config.get("embed"), "embed_documents"):
|
|
assert store.index_config["embed"] == fake_embeddings
|
|
|
|
|
|
async def test_vector_insert_with_auto_embedding(
|
|
fake_embeddings: CharacterEmbeddings,
|
|
conn_string: str,
|
|
) -> None:
|
|
"""Test inserting items that get auto-embedded."""
|
|
async with create_vector_store(fake_embeddings, conn_string=conn_string) as store:
|
|
docs = [
|
|
("doc1", {"text": "short text"}),
|
|
("doc2", {"text": "longer text document"}),
|
|
("doc3", {"text": "longest text document here"}),
|
|
("doc4", {"description": "text in description field"}),
|
|
("doc5", {"content": "text in content field"}),
|
|
("doc6", {"body": "text in body field"}),
|
|
]
|
|
|
|
for key, value in docs:
|
|
await store.aput(("test",), key, value)
|
|
|
|
results = await store.asearch(("test",), query="long text")
|
|
assert len(results) > 0
|
|
|
|
doc_order = [r.key for r in results]
|
|
assert "doc2" in doc_order
|
|
assert "doc3" in doc_order
|
|
|
|
|
|
async def test_vector_update_with_embedding(
|
|
fake_embeddings: CharacterEmbeddings,
|
|
conn_string: str,
|
|
) -> None:
|
|
"""Test that updating items properly updates their embeddings."""
|
|
async with create_vector_store(fake_embeddings, conn_string=conn_string) as store:
|
|
await store.aput(("test",), "doc1", {"text": "zany zebra Xerxes"})
|
|
await store.aput(("test",), "doc2", {"text": "something about dogs"})
|
|
await store.aput(("test",), "doc3", {"text": "text about birds"})
|
|
|
|
results_initial = await store.asearch(("test",), query="Zany Xerxes")
|
|
assert len(results_initial) > 0
|
|
assert results_initial[0].score is not None
|
|
assert results_initial[0].key == "doc1"
|
|
initial_score = results_initial[0].score
|
|
|
|
await store.aput(("test",), "doc1", {"text": "new text about dogs"})
|
|
|
|
results_after = await store.asearch(("test",), query="Zany Xerxes")
|
|
after_score = next((r.score for r in results_after if r.key == "doc1"), 0.0)
|
|
assert (
|
|
after_score is not None
|
|
and initial_score is not None
|
|
and after_score < initial_score
|
|
)
|
|
|
|
results_new = await store.asearch(("test",), query="new text about dogs")
|
|
for r in results_new:
|
|
if r.key == "doc1":
|
|
assert (
|
|
r.score is not None
|
|
and after_score is not None
|
|
and r.score > after_score
|
|
)
|
|
|
|
# Don't index this one
|
|
await store.aput(
|
|
("test",), "doc4", {"text": "new text about dogs"}, index=False
|
|
)
|
|
results_new = await store.asearch(
|
|
("test",), query="new text about dogs", limit=3
|
|
)
|
|
assert not any(r.key == "doc4" for r in results_new)
|
|
|
|
|
|
async def test_vector_search_with_filters(
|
|
fake_embeddings: CharacterEmbeddings,
|
|
conn_string: str,
|
|
) -> None:
|
|
"""Test combining vector search with filters."""
|
|
async with create_vector_store(fake_embeddings, conn_string=conn_string) as store:
|
|
docs = [
|
|
("doc1", {"text": "red apple", "color": "red", "score": 4.5}),
|
|
("doc2", {"text": "red car", "color": "red", "score": 3.0}),
|
|
("doc3", {"text": "green apple", "color": "green", "score": 4.0}),
|
|
("doc4", {"text": "blue car", "color": "blue", "score": 3.5}),
|
|
]
|
|
|
|
for key, value in docs:
|
|
await store.aput(("test",), key, value)
|
|
|
|
# Vector search with filters can be inconsistent in test environments
|
|
# Skip asserting exact results as we've already validated the functionality
|
|
# in the synchronous tests
|
|
_ = await store.asearch(("test",), query="apple", filter={"color": "red"})
|
|
|
|
# Skip asserting exact results as we've already validated the functionality
|
|
# in the synchronous tests
|
|
_ = await store.asearch(("test",), query="car", filter={"color": "red"})
|
|
|
|
# Skip asserting exact results as we've already validated the functionality
|
|
# in the synchronous tests
|
|
_ = await store.asearch(
|
|
("test",), query="bbbbluuu", filter={"score": {"$gt": 3.2}}
|
|
)
|
|
|
|
# Skip asserting exact results as we've already validated the functionality
|
|
# in the synchronous tests
|
|
_ = await store.asearch(
|
|
("test",), query="apple", filter={"score": {"$gte": 4.0}, "color": "green"}
|
|
)
|
|
|
|
|
|
async def test_vector_search_pagination(fake_embeddings: CharacterEmbeddings) -> None:
|
|
"""Test pagination with vector search."""
|
|
async with create_vector_store(fake_embeddings) as store:
|
|
for i in range(5):
|
|
await store.aput(
|
|
("test",), f"doc{i}", {"text": f"test document number {i}"}
|
|
)
|
|
|
|
results_page1 = await store.asearch(("test",), query="test", limit=2)
|
|
results_page2 = await store.asearch(("test",), query="test", limit=2, offset=2)
|
|
|
|
assert len(results_page1) == 2
|
|
assert len(results_page2) == 2
|
|
assert results_page1[0].key != results_page2[0].key
|
|
|
|
all_results = await store.asearch(("test",), query="test", limit=10)
|
|
assert len(all_results) == 5
|
|
|
|
|
|
async def test_vector_search_edge_cases(fake_embeddings: CharacterEmbeddings) -> None:
|
|
"""Test edge cases in vector search."""
|
|
async with create_vector_store(fake_embeddings) as store:
|
|
await store.aput(("test",), "doc1", {"text": "test document"})
|
|
|
|
results = await store.asearch(("test",), query="")
|
|
assert len(results) == 1
|
|
|
|
results = await store.asearch(("test",), query=None)
|
|
assert len(results) == 1
|
|
|
|
long_query = "test " * 100
|
|
results = await store.asearch(("test",), query=long_query)
|
|
assert len(results) == 1
|
|
|
|
special_query = "test!@#$%^&*()"
|
|
results = await store.asearch(("test",), query=special_query)
|
|
assert len(results) == 1
|
|
|
|
|
|
async def test_embed_with_path(
|
|
fake_embeddings: CharacterEmbeddings,
|
|
) -> None:
|
|
"""Test vector search with specific text fields in SQLite store."""
|
|
async with create_vector_store(
|
|
fake_embeddings, text_fields=["key0", "key1", "key3"]
|
|
) as store:
|
|
# This will have 2 vectors representing it
|
|
doc1 = {
|
|
# Omit key0 - check it doesn't raise an error
|
|
"key1": "xxx",
|
|
"key2": "yyy",
|
|
"key3": "zzz",
|
|
}
|
|
# This will have 3 vectors representing it
|
|
doc2 = {
|
|
"key0": "uuu",
|
|
"key1": "vvv",
|
|
"key2": "www",
|
|
"key3": "xxx",
|
|
}
|
|
await store.aput(("test",), "doc1", doc1)
|
|
await store.aput(("test",), "doc2", doc2)
|
|
|
|
# doc2.key3 and doc1.key1 both would have the highest score
|
|
results = await store.asearch(("test",), query="xxx")
|
|
assert len(results) == 2
|
|
assert results[0].key != results[1].key
|
|
assert results[0].score > 0.9
|
|
assert results[1].score > 0.9
|
|
|
|
# ~Only match doc2
|
|
results = await store.asearch(("test",), query="uuu")
|
|
assert len(results) == 2
|
|
assert results[0].key != results[1].key
|
|
assert results[0].key == "doc2"
|
|
assert results[0].score > results[1].score
|
|
|
|
# Un-indexed - will have low results for both. Not zero (because we're projecting)
|
|
# but less than the above.
|
|
results = await store.asearch(("test",), query="www")
|
|
assert len(results) == 2
|
|
assert results[0].score < 0.9
|
|
assert results[1].score < 0.9
|
|
|
|
|
|
async def test_basic_store_ops(
|
|
fake_embeddings: CharacterEmbeddings,
|
|
) -> None:
|
|
"""Test vector search with specific text fields in SQLite store."""
|
|
async with create_vector_store(
|
|
fake_embeddings, text_fields=["key0", "key1", "key3"]
|
|
) as store:
|
|
uid = uuid.uuid4().hex
|
|
namespace = (uid, "test", "documents")
|
|
item_id = "doc1"
|
|
item_value = {"title": "Test Document", "content": "Hello, World!"}
|
|
results = await store.asearch((uid,))
|
|
assert len(results) == 0
|
|
|
|
await store.aput(namespace, item_id, item_value)
|
|
item = await store.aget(namespace, item_id)
|
|
|
|
assert item is not None
|
|
assert item.namespace == namespace
|
|
assert item.key == item_id
|
|
assert item.value == item_value
|
|
assert item.created_at is not None
|
|
assert item.updated_at is not None
|
|
|
|
updated_value = {
|
|
"title": "Updated Test Document",
|
|
"content": "Hello, LangGraph!",
|
|
}
|
|
await asyncio.sleep(1.01)
|
|
await store.aput(namespace, item_id, updated_value)
|
|
updated_item = await store.aget(namespace, item_id)
|
|
assert updated_item is not None
|
|
|
|
assert updated_item.value == updated_value
|
|
assert updated_item.updated_at > item.updated_at
|
|
different_namespace = (uid, "test", "other_documents")
|
|
item_in_different_namespace = await store.aget(different_namespace, item_id)
|
|
assert item_in_different_namespace is None
|
|
|
|
new_item_id = "doc2"
|
|
new_item_value = {"title": "Another Document", "content": "Greetings!"}
|
|
await store.aput(namespace, new_item_id, new_item_value)
|
|
|
|
items = await store.asearch((uid, "test"), limit=10)
|
|
assert len(items) == 2
|
|
assert any(item.key == item_id for item in items)
|
|
assert any(item.key == new_item_id for item in items)
|
|
|
|
namespaces = await store.alist_namespaces(prefix=(uid, "test"))
|
|
assert (uid, "test", "documents") in namespaces
|
|
|
|
await store.adelete(namespace, item_id)
|
|
await store.adelete(namespace, new_item_id)
|
|
deleted_item = await store.aget(namespace, item_id)
|
|
assert deleted_item is None
|
|
|
|
deleted_item = await store.aget(namespace, new_item_id)
|
|
assert deleted_item is None
|
|
|
|
empty_search_results = await store.asearch((uid, "test"), limit=10)
|
|
assert len(empty_search_results) == 0
|
|
|
|
|
|
async def test_list_namespaces(
|
|
fake_embeddings: CharacterEmbeddings,
|
|
) -> None:
|
|
"""Test list namespaces functionality with various filters."""
|
|
async with create_vector_store(
|
|
fake_embeddings, text_fields=["key0", "key1", "key3"]
|
|
) as store:
|
|
test_pref = str(uuid.uuid4())
|
|
test_namespaces = [
|
|
(test_pref, "test", "documents", "public", test_pref),
|
|
(test_pref, "test", "documents", "private", test_pref),
|
|
(test_pref, "test", "images", "public", test_pref),
|
|
(test_pref, "test", "images", "private", test_pref),
|
|
(test_pref, "prod", "documents", "public", test_pref),
|
|
(test_pref, "prod", "documents", "some", "nesting", "public", test_pref),
|
|
(test_pref, "prod", "documents", "private", test_pref),
|
|
]
|
|
|
|
# Add test data
|
|
for namespace in test_namespaces:
|
|
await store.aput(namespace, "dummy", {"content": "dummy"})
|
|
|
|
# Test prefix filtering
|
|
prefix_result = await store.alist_namespaces(prefix=(test_pref, "test"))
|
|
assert len(prefix_result) == 4
|
|
assert all(ns[1] == "test" for ns in prefix_result)
|
|
|
|
# Test specific prefix
|
|
specific_prefix_result = await store.alist_namespaces(
|
|
prefix=(test_pref, "test", "documents")
|
|
)
|
|
assert len(specific_prefix_result) == 2
|
|
assert all(ns[1:3] == ("test", "documents") for ns in specific_prefix_result)
|
|
|
|
# Test suffix filtering
|
|
suffix_result = await store.alist_namespaces(suffix=("public", test_pref))
|
|
assert len(suffix_result) == 4
|
|
assert all(ns[-2] == "public" for ns in suffix_result)
|
|
|
|
# Test combined prefix and suffix
|
|
prefix_suffix_result = await store.alist_namespaces(
|
|
prefix=(test_pref, "test"), suffix=("public", test_pref)
|
|
)
|
|
assert len(prefix_suffix_result) == 2
|
|
assert all(
|
|
ns[1] == "test" and ns[-2] == "public" for ns in prefix_suffix_result
|
|
)
|
|
|
|
# Test wildcard in prefix
|
|
wildcard_prefix_result = await store.alist_namespaces(
|
|
prefix=(test_pref, "*", "documents")
|
|
)
|
|
assert len(wildcard_prefix_result) == 5
|
|
assert all(ns[2] == "documents" for ns in wildcard_prefix_result)
|
|
|
|
# Test wildcard in suffix
|
|
wildcard_suffix_result = await store.alist_namespaces(
|
|
suffix=("*", "public", test_pref)
|
|
)
|
|
assert len(wildcard_suffix_result) == 4
|
|
assert all(ns[-2] == "public" for ns in wildcard_suffix_result)
|
|
|
|
wildcard_single = await store.alist_namespaces(
|
|
suffix=("some", "*", "public", test_pref)
|
|
)
|
|
assert len(wildcard_single) == 1
|
|
assert wildcard_single[0] == (
|
|
test_pref,
|
|
"prod",
|
|
"documents",
|
|
"some",
|
|
"nesting",
|
|
"public",
|
|
test_pref,
|
|
)
|
|
|
|
# Test max depth
|
|
max_depth_result = await store.alist_namespaces(max_depth=3)
|
|
assert all(len(ns) <= 3 for ns in max_depth_result)
|
|
|
|
max_depth_result = await store.alist_namespaces(
|
|
max_depth=4, prefix=(test_pref, "*", "documents")
|
|
)
|
|
assert len(set(res for res in max_depth_result)) == len(max_depth_result) == 5
|
|
|
|
# Test pagination
|
|
limit_result = await store.alist_namespaces(prefix=(test_pref,), limit=3)
|
|
assert len(limit_result) == 3
|
|
|
|
offset_result = await store.alist_namespaces(prefix=(test_pref,), offset=3)
|
|
assert len(offset_result) == len(test_namespaces) - 3
|
|
|
|
empty_prefix_result = await store.alist_namespaces(prefix=(test_pref,))
|
|
assert len(empty_prefix_result) == len(test_namespaces)
|
|
assert set(empty_prefix_result) == set(test_namespaces)
|
|
|
|
# Clean up
|
|
for namespace in test_namespaces:
|
|
await store.adelete(namespace, "dummy")
|
|
|
|
|
|
async def test_search_items(
|
|
fake_embeddings: CharacterEmbeddings,
|
|
) -> None:
|
|
"""Test search_items functionality by calling store methods directly."""
|
|
base = "test_search_items"
|
|
test_namespaces = [
|
|
(base, "documents", "user1"),
|
|
(base, "documents", "user2"),
|
|
(base, "reports", "department1"),
|
|
(base, "reports", "department2"),
|
|
]
|
|
test_items = [
|
|
{"title": "Doc 1", "author": "John Doe", "tags": ["important"]},
|
|
{"title": "Doc 2", "author": "Jane Smith", "tags": ["draft"]},
|
|
{"title": "Report A", "author": "John Doe", "tags": ["final"]},
|
|
{"title": "Report B", "author": "Alice Johnson", "tags": ["draft"]},
|
|
]
|
|
|
|
async with create_vector_store(
|
|
fake_embeddings, text_fields=["key0", "key1", "key3"]
|
|
) as store:
|
|
# Insert test data
|
|
for ns, item in zip(test_namespaces, test_items, strict=False):
|
|
key = f"item_{ns[-1]}"
|
|
await store.aput(ns, key, item)
|
|
|
|
# 1. Search documents
|
|
docs = await store.asearch((base, "documents"))
|
|
assert len(docs) == 2
|
|
assert all(item.namespace[1] == "documents" for item in docs)
|
|
|
|
# 2. Search reports
|
|
reports = await store.asearch((base, "reports"))
|
|
assert len(reports) == 2
|
|
assert all(item.namespace[1] == "reports" for item in reports)
|
|
|
|
# 3. Pagination
|
|
first_page = await store.asearch((base,), limit=2, offset=0)
|
|
second_page = await store.asearch((base,), limit=2, offset=2)
|
|
assert len(first_page) == 2
|
|
assert len(second_page) == 2
|
|
keys_page1 = {item.key for item in first_page}
|
|
keys_page2 = {item.key for item in second_page}
|
|
assert keys_page1.isdisjoint(keys_page2)
|
|
all_items = await store.asearch((base,))
|
|
assert len(all_items) == 4
|
|
|
|
john_items = await store.asearch((base,), filter={"author": "John Doe"})
|
|
assert len(john_items) == 2
|
|
assert all(item.value["author"] == "John Doe" for item in john_items)
|
|
|
|
draft_items = await store.asearch((base,), filter={"tags": ["draft"]})
|
|
assert len(draft_items) == 2
|
|
assert all("draft" in item.value["tags"] for item in draft_items)
|
|
|
|
for ns in test_namespaces:
|
|
key = f"item_{ns[-1]}"
|
|
await store.adelete(ns, key)
|
|
|
|
|
|
async def test_async_namespace_segment_boundary(store: AsyncSqliteStore) -> None:
|
|
"""Segment-aware scoping on the async path.
|
|
|
|
Also covers that the namespace-match SQLite function is registered on the
|
|
async connection -- aiosqlite's create_function is a coroutine, so it is
|
|
registered in setup() rather than __init__.
|
|
"""
|
|
for namespace in [
|
|
("foo",),
|
|
("foo", "child"),
|
|
("foobar",),
|
|
("uid", "users", "alice"),
|
|
("uid", "users", "malice"),
|
|
("user_1",),
|
|
("userX1",),
|
|
]:
|
|
await store.aput(namespace, "k", {"v": 1})
|
|
|
|
found = {item.namespace for item in await store.asearch(("foo",), limit=100)}
|
|
assert found == {("foo",), ("foo", "child")}
|
|
|
|
found = {item.namespace for item in await store.asearch(("user_1",), limit=100)}
|
|
assert found == {("user_1",)}
|
|
|
|
assert set(await store.alist_namespaces(suffix=["alice"], limit=100)) == {
|
|
("uid", "users", "alice"),
|
|
}
|
|
|
|
|
|
@pytest.mark.parametrize("namespace", [("foo.bar",), ("foo", ""), ("foo", 1)])
|
|
async def test_abatch_rejects_invalid_namespace_labels(
|
|
store: AsyncSqliteStore, namespace: tuple
|
|
) -> None:
|
|
await store.aput(("foo", "bar"), "key", {"original": True})
|
|
|
|
for op in (
|
|
GetOp(namespace, "key"),
|
|
GetOp(namespace, "key", refresh_ttl=True),
|
|
PutOp(namespace, "key", {"changed": True}),
|
|
PutOp(namespace, "key", None),
|
|
SearchOp(namespace),
|
|
ListNamespacesOp((MatchCondition("prefix", namespace),)),
|
|
ListNamespacesOp((MatchCondition("suffix", namespace),)),
|
|
):
|
|
with pytest.raises(InvalidNamespaceError):
|
|
await store.abatch([op])
|
|
|
|
item = await store.aget(("foo", "bar"), "key")
|
|
assert item is not None and item.value == {"original": True}
|
|
|
|
|
|
async def test_invalid_namespace_only_fails_its_own_call(
|
|
store: AsyncSqliteStore,
|
|
) -> None:
|
|
"""Concurrent calls share one `abatch`, which fails every op if it raises.
|
|
|
|
Labels are checked before an op is queued, so one caller's bad label cannot
|
|
fail another caller's request.
|
|
"""
|
|
await store.aput(("foo", "bar"), "key", {"original": True})
|
|
|
|
valid, invalid = await asyncio.gather(
|
|
store.aget(("foo", "bar"), "key"),
|
|
store.aget(("foo.bar",), "key"),
|
|
return_exceptions=True,
|
|
)
|
|
|
|
assert isinstance(valid, Item) and valid.value == {"original": True}
|
|
assert isinstance(invalid, InvalidNamespaceError)
|
|
|
|
|
|
async def test_sync_methods_reject_invalid_namespace_labels(
|
|
store: AsyncSqliteStore,
|
|
) -> None:
|
|
"""The sync wrappers run off the event loop thread and must validate too."""
|
|
await store.aput(("foo", "bar"), "key", {"original": True})
|
|
|
|
for call in (
|
|
lambda: store.get(("foo.bar",), "key"),
|
|
lambda: store.search(("foo.bar",)),
|
|
lambda: store.delete(("foo.bar",), "key"),
|
|
lambda: store.list_namespaces(prefix=("foo.bar",)),
|
|
lambda: store.batch([GetOp(("foo.bar",), "key")]),
|
|
):
|
|
with pytest.raises(InvalidNamespaceError):
|
|
await asyncio.to_thread(call)
|
|
|
|
item = await store.aget(("foo", "bar"), "key")
|
|
assert item is not None and item.value == {"original": True}
|