langgraph/libs/sdk-py/langgraph_sdk/auth/__init__.py
dependabot[bot] 5ea88ecbcd
chore(deps): bump the minor-and-patch group across 1 directory with 9 updates (#9530)
Bumps the minor-and-patch group with 9 updates in the /libs/sdk-py
directory:

| Package | From | To |
| --- | --- | --- |
| [orjson](https://github.com/ijl/orjson) | `3.12.0` | `3.13.0` |
| [langchain-protocol](https://github.com/langchain-ai/agent-protocol) |
`0.0.19` | `0.0.20` |
| [langchain-core](https://github.com/langchain-ai/langchain) | `1.6.5`
| `1.7.3` |
| [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.post1` |
| [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.95` |
| [pydantic](https://github.com/pydantic/pydantic) | `2.13.5` | `2.14.2`
|


Updates `orjson` from 3.12.0 to 3.13.0
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/ijl/orjson/releases">orjson's
releases</a>.</em></p>
<blockquote>
<h2>3.13.0</h2>
<h3>Changed</h3>
<ul>
<li>No longer publish PyPI wheels for Windows x86/i686.</li>
</ul>
<h3>Added</h3>
<ul>
<li>Serialize new Python 3.15 built-in type <code>frozendict</code>
identical to
<code>dict</code> (PEP 814).</li>
</ul>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/ijl/orjson/blob/master/CHANGELOG.md">orjson's
changelog</a>.</em></p>
<blockquote>
<h2>3.13.0 - 2026-08-17</h2>
<h3>Changed</h3>
<ul>
<li>No longer publish PyPI wheels for Windows x86/i686.</li>
</ul>
<h3>Added</h3>
<ul>
<li>Serialize new Python 3.15 built-in type <code>frozendict</code>
identical to
<code>dict</code> (PEP 814).</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="bd00937c5c"><code>bd00937</code></a>
3.13.0</li>
<li><a
href="de1fd5a0bf"><code>de1fd5a</code></a>
frozendict</li>
<li><a
href="f110dbe198"><code>f110dbe</code></a>
build update</li>
<li>See full diff in <a
href="https://github.com/ijl/orjson/compare/3.12.0...3.13.0">compare
view</a></li>
</ul>
</details>
<br />

Updates `langchain-protocol` from 0.0.19 to 0.0.20
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/langchain-ai/agent-protocol/releases">langchain-protocol's
releases</a>.</em></p>
<blockquote>
<h2>langchain-protocol==0.0.20</h2>
<h2>What's Changed</h2>
<ul>
<li>chore(deps): bump anyio from 4.11.0 to 4.14.2 in /tooling in the uv
group across 1 directory by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a>[bot]
in <a
href="https://redirect.github.com/langchain-ai/agent-protocol/pull/99">langchain-ai/agent-protocol#99</a></li>
<li>fix(deps): patch anyio vulnerabilities in server by <a
href="https://github.com/linted"><code>@​linted</code></a> in <a
href="https://redirect.github.com/langchain-ai/agent-protocol/pull/101">langchain-ai/agent-protocol#101</a></li>
<li>chore(deps-dev): bump virtualenv from 20.36.1 to 21.7.13 in
/client-python in the pip group across 1 directory by <a
href="https://github.com/dependabot"><code>@​dependabot</code></a>[bot]
in <a
href="https://redirect.github.com/langchain-ai/agent-protocol/pull/103">langchain-ai/agent-protocol#103</a></li>
<li>fix(deps): require patched urllib3 in Python client by <a
href="https://github.com/vladislav-nechakhin"><code>@​vladislav-nechakhin</code></a>
in <a
href="https://redirect.github.com/langchain-ai/agent-protocol/pull/104">langchain-ai/agent-protocol#104</a></li>
<li>fix: validate and pin the patched protocol model generator by <a
href="https://github.com/vladislav-nechakhin"><code>@​vladislav-nechakhin</code></a>
in <a
href="https://redirect.github.com/langchain-ai/agent-protocol/pull/105">langchain-ai/agent-protocol#105</a></li>
<li>feat(protocol): add append-only tool-call delta by <a
href="https://github.com/hntrl"><code>@​hntrl</code></a> in <a
href="https://redirect.github.com/langchain-ai/agent-protocol/pull/102">langchain-ai/agent-protocol#102</a></li>
</ul>
<h2>New Contributors</h2>
<ul>
<li><a href="https://github.com/linted"><code>@​linted</code></a> made
their first contribution in <a
href="https://redirect.github.com/langchain-ai/agent-protocol/pull/101">langchain-ai/agent-protocol#101</a></li>
<li><a
href="https://github.com/vladislav-nechakhin"><code>@​vladislav-nechakhin</code></a>
made their first contribution in <a
href="https://redirect.github.com/langchain-ai/agent-protocol/pull/104">langchain-ai/agent-protocol#104</a></li>
<li><a href="https://github.com/hntrl"><code>@​hntrl</code></a> made
their first contribution in <a
href="https://redirect.github.com/langchain-ai/agent-protocol/pull/102">langchain-ai/agent-protocol#102</a></li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/langchain-ai/agent-protocol/compare/langchain-protocol==0.0.19...langchain-protocol==0.0.20">https://github.com/langchain-ai/agent-protocol/compare/langchain-protocol==0.0.19...langchain-protocol==0.0.20</a></p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="1061307cfc"><code>1061307</code></a>
feat(protocol): add append-only tool-call delta (<a
href="https://redirect.github.com/langchain-ai/agent-protocol/issues/102">#102</a>)</li>
<li><a
href="1ed7656392"><code>1ed7656</code></a>
Merge pull request <a
href="https://redirect.github.com/langchain-ai/agent-protocol/issues/105">#105</a>
from langchain-ai/open-swe/langster-open-issues-07fb6bc4</li>
<li><a
href="dfb13a62a3"><code>dfb13a6</code></a>
chore: keep the generator security PR dependency-only</li>
<li><a
href="bcdfadc05d"><code>bcdfadc</code></a>
fix: pin a validated secure model generator for protocol tooling</li>
<li><a
href="440a86ba09"><code>440a86b</code></a>
Merge pull request <a
href="https://redirect.github.com/langchain-ai/agent-protocol/issues/104">#104</a>
from langchain-ai/open-swe/security-python-dependency...</li>
<li><a
href="4567a9cf24"><code>4567a9c</code></a>
fix(deps): require patched urllib3 in Python client</li>
<li><a
href="f7256a2b43"><code>f7256a2</code></a>
Merge pull request <a
href="https://redirect.github.com/langchain-ai/agent-protocol/issues/103">#103</a>
from langchain-ai/dependabot/pip/client-python/pip-0d...</li>
<li><a
href="dbb20325f8"><code>dbb2032</code></a>
chore(deps-dev): bump virtualenv</li>
<li><a
href="fb81f3e27e"><code>fb81f3e</code></a>
Merge pull request <a
href="https://redirect.github.com/langchain-ai/agent-protocol/issues/101">#101</a>
from langchain-ai/langsmith-fleet/deps/fix-anyio-sec-...</li>
<li><a
href="433e494060"><code>433e494</code></a>
fix(deps): patch anyio vulnerabilities in server</li>
<li>Additional commits viewable in <a
href="https://github.com/langchain-ai/agent-protocol/compare/langchain-protocol==0.0.19...langchain-protocol==0.0.20">compare
view</a></li>
</ul>
</details>
<br />

Updates `langchain-core` from 1.6.5 to 1.7.3
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/langchain-ai/langchain/releases">langchain-core's
releases</a>.</em></p>
<blockquote>
<h2>langchain-core==1.7.3</h2>
<p>Changes since langchain-core==1.7.2</p>
<p>release(core): 1.7.3 (<a
href="https://redirect.github.com/langchain-ai/langchain/issues/41564">#41564</a>)</p>
<h2>langchain-core==1.7.2</h2>
<p>Changes since langchain-core==1.7.1</p>
<p>release(core): 1.7.2 (<a
href="https://redirect.github.com/langchain-ai/langchain/issues/41562">#41562</a>)
feat(core): add <code>add_notification_metadata</code> and
<code>get_notification_metadata</code> (<a
href="https://redirect.github.com/langchain-ai/langchain/issues/41540">#41540</a>)
fix(core): stop <code>merge_content</code> from changing the first
message's content (<a
href="https://redirect.github.com/langchain-ai/langchain/issues/41502">#41502</a>)</p>
<h2>langchain-core==1.7.1</h2>
<p>Changes since langchain-core==1.7.0</p>
<p>release(core): version 1.7.1 (<a
href="https://redirect.github.com/langchain-ai/langchain/issues/41548">#41548</a>)
fix(core): preserve gateway tracing metadata in v3 streams (<a
href="https://redirect.github.com/langchain-ai/langchain/issues/41504">#41504</a>)
fix(core): escape node metadata in Mermaid labels (<a
href="https://redirect.github.com/langchain-ai/langchain/issues/41512">#41512</a>)
chore(deps): bump the minor-and-patch group across 3 directories with 32
updates (<a
href="https://redirect.github.com/langchain-ai/langchain/issues/41465">#41465</a>)
chore(deps-dev): bump setuptools from 83.0.0 to 84.1.0 in /libs/core (<a
href="https://redirect.github.com/langchain-ai/langchain/issues/41442">#41442</a>)
chore(deps): bump nbconvert from 7.17.1 to 7.17.2 in /libs/core (<a
href="https://redirect.github.com/langchain-ai/langchain/issues/41425">#41425</a>)
chore(infra): relax third-party dependency upper bounds (<a
href="https://redirect.github.com/langchain-ai/langchain/issues/41407">#41407</a>)</p>
<h2>langchain-core==1.7.0</h2>
<p>Changes since langchain-core==1.6.13</p>
<p>release(core): 1.7.0 (<a
href="https://redirect.github.com/langchain-ai/langchain/issues/41418">#41418</a>)
feat(core): emit <code>tool-call-delta</code> for streamed tool-call
args (<a
href="https://redirect.github.com/langchain-ai/langchain/issues/41257">#41257</a>)</p>
<h2>Notes</h2>
<ul>
<li>Tool-call args now stream as <code>tool-call-delta</code> slices
instead of <code>block-delta</code> snapshots of the args so far. If you
read raw stream events and their <code>block-delta</code> args
mid-stream, read <code>tool-call-delta</code> instead.
<code>.tool_calls.get()</code> and <code>.output</code> are unchanged.
To keep snapshots, pin <code>langchain-core&lt;1.7</code>.</li>
<li>Since 1.6.13, iterating <code>ChatModelStream.tool_calls</code>
yields each call's new args slice, not a snapshot of the args so
far.</li>
</ul>
<h2>langchain-core==1.6.13</h2>
<p>Changes since langchain-core==1.6.12</p>
<p>release(core): 1.6.13 (<a
href="https://redirect.github.com/langchain-ai/langchain/issues/41397">#41397</a>)
chore(deps): bump certifi from 2025.11.12 to 2026.10.19 in /libs/core
(<a
href="https://redirect.github.com/langchain-ai/langchain/issues/41373">#41373</a>)
feat(core,langchain,standard-tests): read <code>tool-call-delta</code>
in stream consumers (<a
href="https://redirect.github.com/langchain-ai/langchain/issues/41246">#41246</a>)</p>
<h2>langchain-core==1.6.12</h2>
<p>Changes since langchain-core==1.6.11</p>
<p>release(core): 1.6.12 (<a
href="https://redirect.github.com/langchain-ai/langchain/issues/41277">#41277</a>)
fix(core): propagate extras on content-block-start events (<a
href="https://redirect.github.com/langchain-ai/langchain/issues/41272">#41272</a>)</p>
<h2>langchain-core==1.6.11</h2>
<p>Changes since langchain-core==1.6.10</p>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="864754c5e2"><code>864754c</code></a>
release(core): 1.7.3 (<a
href="https://redirect.github.com/langchain-ai/langchain/issues/41564">#41564</a>)</li>
<li><a
href="51a3a6ae01"><code>51a3a6a</code></a>
chore(infra): ask how bug reports were discovered (<a
href="https://redirect.github.com/langchain-ai/langchain/issues/41563">#41563</a>)</li>
<li><a
href="0027e67769"><code>0027e67</code></a>
release(core): 1.7.2 (<a
href="https://redirect.github.com/langchain-ai/langchain/issues/41562">#41562</a>)</li>
<li><a
href="7f46a2e59f"><code>7f46a2e</code></a>
docs: update OpenWiki (<a
href="https://redirect.github.com/langchain-ai/langchain/issues/41524">#41524</a>)</li>
<li><a
href="7ce3593b63"><code>7ce3593</code></a>
feat(core): add <code>add_notification_metadata</code> and
<code>get_notification_metadata</code> (...</li>
<li><a
href="5029a0f7dd"><code>5029a0f</code></a>
chore(model-profiles): refresh model profile data (<a
href="https://redirect.github.com/langchain-ai/langchain/issues/41556">#41556</a>)</li>
<li><a
href="350568952c"><code>3505689</code></a>
fix(anthropic): handle null cache-creation token counts (<a
href="https://redirect.github.com/langchain-ai/langchain/issues/41553">#41553</a>)</li>
<li><a
href="8875dc8f5b"><code>8875dc8</code></a>
fix(fireworks): promote reranking out of beta (<a
href="https://redirect.github.com/langchain-ai/langchain/issues/41551">#41551</a>)</li>
<li><a
href="399fd2e433"><code>399fd2e</code></a>
fix(core): stop <code>merge_content</code> from changing the first
message's content (<a
href="https://redirect.github.com/langchain-ai/langchain/issues/4">#4</a>...</li>
<li><a
href="e633868f9c"><code>e633868</code></a>
chore(deps): bump authlib from 1.7.2 to 1.9.1 in /libs/langchain_v1 (<a
href="https://redirect.github.com/langchain-ai/langchain/issues/41539">#41539</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/langchain-ai/langchain/compare/langchain-core==1.6.5...langchain-core==1.7.3">compare
view</a></li>
</ul>
</details>
<br />

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()
&lt;pytest.Metafunc.parametrize&gt;</code> -- and therefore of
<code>@pytest.mark.parametrize &lt;pytest.mark.parametrize
ref&gt;</code> -- are now keyword-only.</p>
<p>Passing them positionally was a common source of confusing errors,
e.g. <code>parametrize(&quot;arg1&quot;, &quot;arg2&quot;, [(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 --> &amp; <!-- 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.post1
<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.post1</h2>
<h1><a
href="https://github.com/pytest-dev/pytest-asyncio/tree/1.4.1.post1">1.4.1.post1</a>
- 2026-11-01</h1>
<h2>Changed</h2>
<ul>
<li>Removed the upper version bound on the <code>pytest</code>
dependency. (<a
href="https://redirect.github.com/pytest-dev/pytest-asyncio/issues/1605">#1605</a>)</li>
</ul>
<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="e4203495fe"><code>e420349</code></a>
Bump mypy pre-commit hook to v2.4.0 (<a
href="https://redirect.github.com/pytest-dev/pytest-asyncio/issues/1601">#1601</a>)</li>
<li><a
href="16a1ba4154"><code>16a1ba4</code></a>
chore: Prepare release of v1.4.1.post1.</li>
<li><a
href="7087e7f64c"><code>7087e7f</code></a>
build: drop pytest upper bound (<a
href="https://redirect.github.com/pytest-dev/pytest-asyncio/issues/1605">#1605</a>)
(<a
href="https://redirect.github.com/pytest-dev/pytest-asyncio/issues/1606">#1606</a>)</li>
<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>Additional commits viewable in <a
href="https://github.com/pytest-dev/pytest-asyncio/compare/v1.4.0...v1.4.1.post1">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)
&lt;https://github.com/pytest-dev/pytest-mock/pull/641&gt;</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)
&lt;https://github.com/pytest-dev/pytest-mock/pull/642&gt;</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)
&lt;https://github.com/pytest-dev/pytest-mock/pull/643&gt;</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)
&lt;https://github.com/pytest-dev/pytest-mock/pull/617&gt;</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)
&lt;https://github.com/pytest-dev/pytest-mock/pull/621&gt;</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)
&lt;https://github.com/pytest-dev/pytest-mock/pull/621&gt;</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)
&lt;https://github.com/pytest-dev/pytest-mock/pull/623&gt;</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)
&lt;https://github.com/pytest-dev/pytest-mock/pull/624&gt;</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)
&lt;https://github.com/pytest-dev/pytest-mock/pull/627&gt;</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)
&lt;https://github.com/pytest-dev/pytest-mock/pull/629&gt;</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)
&lt;https://github.com/pytest-dev/pytest-mock/pull/630&gt;</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)
&lt;https://github.com/pytest-dev/pytest-mock/pull/633&gt;</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 &quot;irm
https://releases.astral.sh/github/ruff/releases/download/0.17.3/ruff-installer.ps1
| iex&quot;
</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.95
<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.95</h2>
<h2>Release Notes</h2>
<p>Released on 2026-10-29.</p>
<h3>Bug fixes</h3>
<ul>
<li>Accept another unpacked TypeVarTuple as a default (<a
href="https://redirect.github.com/astral-sh/ruff/pull/29752">#29752</a>)</li>
<li>Accept keyword arguments for <code>TypeAliasType</code> name and
value (<a
href="https://redirect.github.com/astral-sh/ruff/pull/29802">#29802</a>)</li>
<li>Detect traversal budget exhaustion in products of lower bounds (<a
href="https://redirect.github.com/astral-sh/ruff/pull/29679">#29679</a>)</li>
<li>Fix recursive protocol materialization self-comparison (<a
href="https://redirect.github.com/astral-sh/ruff/pull/29809">#29809</a>)</li>
<li>Reject out-of-scope type variables in PEP 695 pack defaults (<a
href="https://redirect.github.com/astral-sh/ruff/pull/29805">#29805</a>)</li>
<li>Use a trailing ParamSpec default after a TypeVarTuple (<a
href="https://redirect.github.com/astral-sh/ruff/pull/29755">#29755</a>)</li>
</ul>
<h3>LSP server</h3>
<ul>
<li>Parenthesize assignment and generator expressions in argument hint
edits (<a
href="https://redirect.github.com/astral-sh/ruff/pull/29797">#29797</a>)</li>
<li>Place argument name inlay hints before grouping parentheses (<a
href="https://redirect.github.com/astral-sh/ruff/pull/29794">#29794</a>)</li>
<li>Place variable type inlay hints after grouping parentheses (<a
href="https://redirect.github.com/astral-sh/ruff/pull/29795">#29795</a>)</li>
</ul>
<h3>Contributors</h3>
<ul>
<li><a href="https://github.com/carljm"><code>@​carljm</code></a></li>
<li><a
href="https://github.com/AlexWaygood"><code>@​AlexWaygood</code></a></li>
<li><a
href="https://github.com/charliermarsh"><code>@​charliermarsh</code></a></li>
</ul>
<h2>Install ty 0.0.95</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.95/ty-installer.sh
| sh
</code></pre>
<h3>Install prebuilt binaries via powershell script</h3>
<pre lang="sh"><code>powershell -ExecutionPolicy Bypass -c &quot;irm
https://releases.astral.sh/github/ty/releases/download/0.0.95/ty-installer.ps1
| iex&quot;
</code></pre>
<h2>Download ty 0.0.95</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.95/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.95/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.95/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.95/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.95/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.95/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.95/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.95/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.95/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.95/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.95/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.95/ty-aarch64-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.95</h2>
<p>Released on 2026-10-29.</p>
<h3>Bug fixes</h3>
<ul>
<li>Accept another unpacked TypeVarTuple as a default (<a
href="https://redirect.github.com/astral-sh/ruff/pull/29752">#29752</a>)</li>
<li>Accept keyword arguments for <code>TypeAliasType</code> name and
value (<a
href="https://redirect.github.com/astral-sh/ruff/pull/29802">#29802</a>)</li>
<li>Detect traversal budget exhaustion in products of lower bounds (<a
href="https://redirect.github.com/astral-sh/ruff/pull/29679">#29679</a>)</li>
<li>Fix recursive protocol materialization self-comparison (<a
href="https://redirect.github.com/astral-sh/ruff/pull/29809">#29809</a>)</li>
<li>Reject out-of-scope type variables in PEP 695 pack defaults (<a
href="https://redirect.github.com/astral-sh/ruff/pull/29805">#29805</a>)</li>
<li>Use a trailing ParamSpec default after a TypeVarTuple (<a
href="https://redirect.github.com/astral-sh/ruff/pull/29755">#29755</a>)</li>
</ul>
<h3>LSP server</h3>
<ul>
<li>Parenthesize assignment and generator expressions in argument hint
edits (<a
href="https://redirect.github.com/astral-sh/ruff/pull/29797">#29797</a>)</li>
<li>Place argument name inlay hints before grouping parentheses (<a
href="https://redirect.github.com/astral-sh/ruff/pull/29794">#29794</a>)</li>
<li>Place variable type inlay hints after grouping parentheses (<a
href="https://redirect.github.com/astral-sh/ruff/pull/29795">#29795</a>)</li>
</ul>
<h3>Contributors</h3>
<ul>
<li><a href="https://github.com/carljm"><code>@​carljm</code></a></li>
<li><a
href="https://github.com/AlexWaygood"><code>@​AlexWaygood</code></a></li>
<li><a
href="https://github.com/charliermarsh"><code>@​charliermarsh</code></a></li>
</ul>
<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>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="48c5ea1baf"><code>48c5ea1</code></a>
Bump version to 0.0.95 (<a
href="https://redirect.github.com/astral-sh/ty/issues/4870">#4870</a>)</li>
<li><a
href="13ef399a5f"><code>13ef399</code></a>
Speed up releases by using larger runners for all Windows builds (<a
href="https://redirect.github.com/astral-sh/ty/issues/4805">#4805</a>)</li>
<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>Additional commits viewable in <a
href="https://github.com/astral-sh/ty/compare/0.0.84...0.0.95">compare
view</a></li>
</ul>
</details>
<br />

Updates `pydantic` from 2.13.5 to 2.14.2
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/pydantic/pydantic/releases">pydantic's
releases</a>.</em></p>
<blockquote>
<h2>v2.14.2 2026-10-29</h2>
<h2>v2.14.2 (2026-10-29)</h2>
<p>This release addresses 2 security issues, <a
href="https://github.com/pydantic/pydantic/security/advisories/GHSA-qpmf-fgh3-ff25">https://github.com/pydantic/pydantic/security/advisories/GHSA-qpmf-fgh3-ff25</a>
and <a
href="https://github.com/pydantic/pydantic/security/advisories/GHSA-3r8g-cqwr-jr29">https://github.com/pydantic/pydantic/security/advisories/GHSA-3r8g-cqwr-jr29</a>.</p>
<h4>Packaging</h4>
<ul>
<li>Bump PyO3 to 0.30.1, jiter to 0.18.0, use <code>PyFrozenDict</code>
by <a href="https://github.com/Viicos"><code>@​Viicos</code></a> in <a
href="https://redirect.github.com/pydantic/pydantic/pull/14003">#14003</a></li>
<li>Bump speedate to v0.18.0 by <a
href="https://github.com/Viicos"><code>@​Viicos</code></a> in <a
href="https://redirect.github.com/pydantic/pydantic/pull/14007">#14007</a></li>
<li>Publish <code>pydantic-core</code> wheels for PyPy 8.0
(<code>pp80</code> ABI) by <a
href="https://github.com/Viicos"><code>@​Viicos</code></a> in <a
href="https://redirect.github.com/pydantic/pydantic/pull/14083">#14083</a></li>
</ul>
<h4>Performance</h4>
<ul>
<li>Avoid Python tuple allocation during model fields validation by <a
href="https://github.com/Viicos"><code>@​Viicos</code></a> in <a
href="https://redirect.github.com/pydantic/pydantic/pull/13955">#13955</a></li>
<li>Lazily call repr of values during nested union serialization by <a
href="https://github.com/Viicos"><code>@​Viicos</code></a> in <a
href="https://redirect.github.com/pydantic/pydantic/pull/14082">#14082</a></li>
<li>Skip decorator field checks when no field decorators exist by <a
href="https://github.com/alexmojaki"><code>@​alexmojaki</code></a> in <a
href="https://redirect.github.com/pydantic/pydantic/pull/14111">#14111</a></li>
<li>Avoid heap allocation for small JSON model field buffers by <a
href="https://github.com/alexmojaki"><code>@​alexmojaki</code></a> in <a
href="https://redirect.github.com/pydantic/pydantic/pull/14113">#14113</a></li>
</ul>
<h4>Fixes</h4>
<ul>
<li>
<p>Make JSON validation by iteration consistent with Python approach by
<a href="https://github.com/davidhewitt"><code>@​davidhewitt</code></a>
in <a
href="https://redirect.github.com/pydantic/pydantic/pull/13275">#13275</a>.</p>
<p>JSON validation now handles field lookup and extra data the same way
as Python validation. In particular, keys that only match an
unused alias or field name are now treated as extra data, instead of
being silently dropped:</p>
<pre lang="python"><code>from pydantic import BaseModel, ConfigDict
from pydantic.alias_generators import to_camel
<p>class Page(BaseModel):<br />
model_config = ConfigDict(extra='forbid', alias_generator=to_camel)</p>
<pre><code>page_size: int = 10
</code></pre>
<p>Page.model_validate_json('{&quot;page_size&quot;: 50}')</p>
<h1>Before: Page(page_size=10)</h1>
<h1>After: ValidationError (extra_forbidden)</h1>
<p></code></pre></p>
<p>See the <a
href="https://redirect.github.com/pydantic/pydantic/pull/13275">pull
request</a> for the full list of behavior changes.
This change addresses <a
href="https://github.com/pydantic/pydantic/security/advisories/GHSA-qpmf-fgh3-ff25">https://github.com/pydantic/pydantic/security/advisories/GHSA-qpmf-fgh3-ff25</a>.</p>
</li>
<li>
<p>Ignore extra data matching a field name in <code>TypedDict</code> and
dataclasses with <code>extra=allow</code> by <a
href="https://github.com/Viicos"><code>@​Viicos</code></a> in <a
href="https://redirect.github.com/pydantic/pydantic/pull/14090">#14090</a>.
Addresses <a
href="https://github.com/pydantic/pydantic/security/advisories/GHSA-3r8g-cqwr-jr29">https://github.com/pydantic/pydantic/security/advisories/GHSA-3r8g-cqwr-jr29</a>.</p>
</li>
<li>
<p>Fix unpickling of generic classes defined in separate module by <a
href="https://github.com/Viicos"><code>@​Viicos</code></a> in <a
href="https://redirect.github.com/pydantic/pydantic/pull/13994">#13994</a></p>
</li>
<li>
<p>Support explicit <code>by_alias</code> overriding
<code>validate_by_alias</code> in validation JSON schemas by <a
href="https://github.com/Viicos"><code>@​Viicos</code></a> in <a
href="https://redirect.github.com/pydantic/pydantic/pull/13997">#13997</a></p>
</li>
<li>
<p>Fix mypy plugin crash on deferred empty model by <a
href="https://github.com/ilevkivskyi"><code>@​ilevkivskyi</code></a> in
<a
href="https://redirect.github.com/pydantic/pydantic/pull/14027">#14027</a></p>
</li>
<li>
<p>Fix infinite recursion when validating an invalid default with
<code>PydanticUseDefault</code> by <a
href="https://github.com/Viicos"><code>@​Viicos</code></a> in <a
href="https://redirect.github.com/pydantic/pydantic/pull/14028">#14028</a></p>
</li>
<li>
<p>Implement recursion guard for <code>validate_strings()</code> by <a
href="https://github.com/Viicos"><code>@​Viicos</code></a> in <a
href="https://redirect.github.com/pydantic/pydantic/pull/14029">#14029</a></p>
</li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/pydantic/pydantic/blob/v2.14.2/HISTORY.md">pydantic's
changelog</a>.</em></p>
<blockquote>
<h2>v2.14.2 (2026-10-29)</h2>
<p><a
href="https://github.com/pydantic/pydantic/releases/tag/v2.14.2">GitHub
release</a></p>
<h3>What's Changed</h3>
<h4>Packaging</h4>
<ul>
<li>Bump PyO3 to 0.30.1, jiter to 0.18.0, use <code>PyFrozenDict</code>
by <a href="https://github.com/Viicos"><code>@​Viicos</code></a> in <a
href="https://redirect.github.com/pydantic/pydantic/pull/14003">#14003</a></li>
<li>Bump speedate to v0.18.0 by <a
href="https://github.com/Viicos"><code>@​Viicos</code></a> in <a
href="https://redirect.github.com/pydantic/pydantic/pull/14007">#14007</a></li>
<li>Publish <code>pydantic-core</code> wheels for PyPy 8.0...

_Description has been truncated_

---------

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 <65985482+jkennedyvz@users.noreply.github.com>
Co-authored-by: John Kennedy <jkennedyvz@users.noreply.github.com>
Co-authored-by: Robin <open-swe@users.noreply.github.com>
2026-11-10 20:29:12 -08:00

924 lines
32 KiB
Python

from __future__ import annotations
import inspect
import typing
from collections.abc import Callable, Sequence
from langgraph_sdk.auth import exceptions, types
TH = typing.TypeVar("TH", bound=types.Handler)
AH = typing.TypeVar("AH", bound=types.Authenticator)
class Auth:
"""Add custom authentication and authorization management to your LangGraph application.
The Auth class provides a unified system for handling authentication and
authorization in LangGraph applications. It supports custom user authentication
protocols and fine-grained authorization rules for different resources and
actions.
To use, create a separate python file and add the path to the file to your
LangGraph API configuration file (`langgraph.json`). Within that file, create
an instance of the Auth class and register authentication and authorization
handlers as needed.
Example `langgraph.json` file:
```json
{
"dependencies": ["."],
"graphs": {
"agent": "./my_agent/agent.py:graph"
},
"env": ".env",
"auth": {
"path": "./auth.py:my_auth"
}
```
Then the LangGraph server will load your auth file and run it server-side whenever a request comes in.
???+ example "Basic Usage"
```python
from langgraph_sdk import Auth
my_auth = Auth()
@my_auth.authenticate
async def authenticate(authorization: str) -> Auth.types.MinimalUserDict:
user = await verify_token(authorization) # Your token verification logic
if not user:
raise Auth.exceptions.HTTPException(
status_code=401, detail="Unauthorized"
)
return {
"identity": user["id"],
"permissions": user.get("permissions", []),
}
# Default deny: reject all requests that don't have a specific handler
@my_auth.on
async def deny_all(ctx: Auth.types.AuthContext, value: Any) -> False:
return False
# Allow users to create threads with their own identity as owner
@my_auth.on.threads.create
async def allow_thread_create(
ctx: Auth.types.AuthContext, value: Auth.types.on.threads.create.value
):
metadata = value.setdefault("metadata", {})
metadata["owner"] = ctx.user.identity
# Allow users to read and search their own threads
@my_auth.on.threads.read
async def allow_thread_read(
ctx: Auth.types.AuthContext, value: Auth.types.on.threads.read.value
) -> Auth.types.FilterType:
return {"owner": ctx.user.identity}
@my_auth.on.threads.search
async def allow_thread_search(
ctx: Auth.types.AuthContext, value: Auth.types.on.threads.search.value
) -> Auth.types.FilterType:
return {"owner": ctx.user.identity}
# Scope all store operations to the user's namespace
@my_auth.on.store
async def scope_store(ctx: Auth.types.AuthContext, value: Auth.types.on.store.value):
namespace = tuple(value["namespace"]) if value.get("namespace") else ()
if not namespace or namespace[0] != ctx.user.identity:
namespace = (ctx.user.identity, *namespace)
value["namespace"] = namespace
```
???+ note "Request Processing Flow"
1. Authentication (your `@auth.authenticate` handler) is performed first on **every request**
2. For authorization, the most specific matching handler is called:
* If a handler exists for the exact resource and action, it is used (e.g., `@auth.on.threads.create`)
* Otherwise, if a handler exists for the resource with any action, it is used (e.g., `@auth.on.threads`)
* Finally, if no specific handlers match, the global handler is used (e.g., `@auth.on`)
* If no global handler is set, the request is accepted
This allows you to set default behavior with a global handler while
overriding specific routes as needed.
"""
__slots__ = (
"_authenticate_handler",
"_global_handlers",
"_handler_cache",
"_handlers",
"on",
)
types = types
"""Reference to auth type definitions.
Provides access to all type definitions used in the auth system,
like ThreadsCreate, AssistantsRead, etc."""
exceptions = exceptions
"""Reference to auth exception definitions.
Provides access to all exception definitions used in the auth system,
like HTTPException, etc.
"""
def __init__(self) -> None:
self.on = _On(self)
"""Entry point for authorization handlers that control access to specific resources.
The on class provides a flexible way to define authorization rules for different
resources and actions in your application. It supports three main usage patterns:
1. Global handlers that run for all resources and actions
2. Resource-specific handlers that run for all actions on a resource
3. Resource and action specific handlers for fine-grained control
Each handler must be an async function that accepts two parameters:
- ctx (AuthContext): Contains request context and authenticated user info
- value: The data being authorized (type varies by endpoint)
The handler should return one of:
- None or True: Accept the request
- False: Reject with 403 error
- FilterType: Apply filtering rules to the response
???+ example "Examples"
Start by denying all requests by default, then add specific handlers
to allow access:
```python
# Default deny: reject all unhandled requests
@auth.on
async def deny_all(ctx: AuthContext, value: Any) -> False:
return False
```
Resource-specific handler. This takes precedence over the global handler
for all actions on the `threads` resource:
```python
@auth.on.threads
async def allow_thread_access(ctx: AuthContext, value: Any) -> Auth.types.FilterType:
# Only allow access to threads owned by the user
return {"owner": ctx.user.identity}
```
Resource and action specific handler:
```python
@auth.on.threads.delete
async def allow_admin_thread_deletion(ctx: AuthContext, value: Any) -> bool:
# Only admins can delete threads
return "admin" in ctx.user.permissions
```
Multiple resources or actions:
```python
@auth.on(resources=["threads", "assistants"], actions=["read", "search"])
async def allow_reads(ctx: AuthContext, value: Any) -> Auth.types.FilterType:
# Allow read/search access to resources owned by the user
return {"owner": ctx.user.identity}
```
Auth for the `store` resource is a bit different since its structure is developer defined.
You typically want to scope store operations by rewriting the namespace to include the user's identity.
The `value` dict is mutable — changes to `value["namespace"]` are used by the server for the actual operation.
```python
@auth.on.store
async def scope_store(ctx: AuthContext, value: Auth.types.on.store.value):
# Allow store access but scope to user's namespace
namespace = tuple(value["namespace"]) if value.get("namespace") else ()
if not namespace or namespace[0] != ctx.user.identity:
namespace = (ctx.user.identity, *namespace)
value["namespace"] = namespace
```
You can also register handlers for specific store actions:
```python
@auth.on.store.put
async def allow_put(ctx: AuthContext, value: Auth.types.on.store.put.value):
# Allow puts, scoped to user's namespace
value["namespace"] = (ctx.user.identity, *value["namespace"])
@auth.on.store.get
async def allow_get(ctx: AuthContext, value: Auth.types.on.store.get.value):
# Allow gets, scoped to user's namespace
value["namespace"] = (ctx.user.identity, *value["namespace"])
```
"""
# These are accessed by the API. Changes to their names or types is
# will be considered a breaking change.
self._handlers: dict[tuple[str, str], list[types.Handler]] = {}
self._global_handlers: list[types.Handler] = []
self._authenticate_handler: types.Authenticator | None = None
self._handler_cache: dict[tuple[str, str], types.Handler] = {}
def authenticate(self, fn: AH) -> AH:
"""Register an authentication handler function.
The authentication handler is responsible for verifying credentials
and returning user scopes. It can accept any of the following parameters
by name:
- request (Request): The raw ASGI request object
- path (str): The request path, e.g., "/threads/abcd-1234-abcd-1234/runs/abcd-1234-abcd-1234/stream"
- method (str): The HTTP method, e.g., "GET"
- path_params (dict[str, str]): URL path parameters, e.g., {"thread_id": "abcd-1234-abcd-1234", "run_id": "abcd-1234-abcd-1234"}
- query_params (dict[str, str]): URL query parameters, e.g., {"stream": "true"}
- headers (dict[bytes, bytes]): Request headers
- authorization (str | None): The Authorization header value (e.g., "Bearer <token>")
Args:
fn: The authentication handler function to register.
Must return a representation of the user. This could be a:
- string (the user id)
- dict containing {"identity": str, "permissions": list[str]}
- or an object with identity and permissions properties
Permissions can be optionally used by your handlers downstream.
Returns:
The registered handler function.
Raises:
ValueError: If an authentication handler is already registered.
???+ example "Examples"
Basic token authentication:
```python
@auth.authenticate
async def authenticate(authorization: str) -> str:
user_id = verify_token(authorization)
return user_id
```
Accept the full request context:
```python
@auth.authenticate
async def authenticate(
method: str,
path: str,
headers: dict[str, bytes]
) -> str:
user = await verify_request(method, path, headers)
return user
```
Return user name and permissions:
```python
@auth.authenticate
async def authenticate(
method: str,
path: str,
headers: dict[str, bytes]
) -> Auth.types.MinimalUserDict:
permissions, user = await verify_request(method, path, headers)
# Permissions could be things like ["runs:read", "runs:write", "threads:read", "threads:write"]
return {
"identity": user["id"],
"permissions": permissions,
"display_name": user["name"],
}
```
"""
if self._authenticate_handler is not None:
raise ValueError(
f"Authentication handler already set as {self._authenticate_handler}."
)
self._authenticate_handler = fn
return fn
## Helper types & utilities
V = typing.TypeVar("V", contravariant=True)
class _ActionHandler(typing.Protocol[V]):
async def __call__(
self, *, ctx: types.AuthContext, value: V
) -> types.HandlerResult: ...
T = typing.TypeVar("T")
class _ResourceActionOn(typing.Generic[T]):
def __init__(
self,
auth: Auth,
resource: typing.Literal["threads", "crons", "assistants"],
action: typing.Literal[
"create", "read", "update", "delete", "search", "create_run"
],
value: type[T],
) -> None:
self.auth = auth
self.resource = resource
self.action = action
self.value = value
def __call__(self, fn: _ActionHandler[T]) -> _ActionHandler[T]:
_validate_handler(fn)
_register_handler(self.auth, self.resource, self.action, fn)
return fn
VCreate = typing.TypeVar("VCreate", covariant=True)
VUpdate = typing.TypeVar("VUpdate", covariant=True)
VRead = typing.TypeVar("VRead", covariant=True)
VDelete = typing.TypeVar("VDelete", covariant=True)
VSearch = typing.TypeVar("VSearch", covariant=True)
ResourceActionT = typing.TypeVar("ResourceActionT", bound=str)
_ResourceAction = typing.Literal["create", "read", "update", "delete", "search"]
_ThreadAction = _ResourceAction | typing.Literal["create_run"]
class _ResourceOn(
typing.Generic[VCreate, VRead, VUpdate, VDelete, VSearch, ResourceActionT]
):
"""
Generic base class for resource-specific handlers.
"""
Create: type[VCreate]
Read: type[VRead]
Update: type[VUpdate]
Delete: type[VDelete]
Search: type[VSearch]
def __init__(
self,
auth: Auth,
resource: typing.Literal["threads", "crons", "assistants"],
) -> None:
self.auth = auth
self.resource = resource
self.create: _ResourceActionOn[VCreate] = _ResourceActionOn(
auth, resource, "create", self.Create
)
self.read: _ResourceActionOn[VRead] = _ResourceActionOn(
auth, resource, "read", self.Read
)
self.update: _ResourceActionOn[VUpdate] = _ResourceActionOn(
auth, resource, "update", self.Update
)
self.delete: _ResourceActionOn[VDelete] = _ResourceActionOn(
auth, resource, "delete", self.Delete
)
self.search: _ResourceActionOn[VSearch] = _ResourceActionOn(
auth, resource, "search", self.Search
)
@typing.overload
def __call__(
self,
fn: (
_ActionHandler[VCreate | VUpdate | VRead | VDelete | VSearch]
| _ActionHandler[dict[str, typing.Any]]
),
) -> _ActionHandler[VCreate | VUpdate | VRead | VDelete | VSearch]: ...
@typing.overload
def __call__(
self,
*,
resources: str | Sequence[str] | None = None,
actions: ResourceActionT | Sequence[ResourceActionT] | None = None,
) -> Callable[
[_ActionHandler[VCreate | VUpdate | VRead | VDelete | VSearch]],
_ActionHandler[VCreate | VUpdate | VRead | VDelete | VSearch],
]: ...
def __call__(
self,
fn: (
_ActionHandler[VCreate | VUpdate | VRead | VDelete | VSearch]
| _ActionHandler[dict[str, typing.Any]]
| None
) = None,
*,
resources: str | Sequence[str] | None = None,
actions: ResourceActionT | Sequence[ResourceActionT] | None = None,
) -> (
_ActionHandler[VCreate | VUpdate | VRead | VDelete | VSearch]
| Callable[
[_ActionHandler[VCreate | VUpdate | VRead | VDelete | VSearch]],
_ActionHandler[VCreate | VUpdate | VRead | VDelete | VSearch],
]
):
def decorator(
handler: _ActionHandler[VCreate | VUpdate | VRead | VDelete | VSearch],
) -> _ActionHandler[VCreate | VUpdate | VRead | VDelete | VSearch]:
_validate_handler(handler)
if resources is None:
resource_list = [self.resource]
elif isinstance(resources, str):
resource_list = [resources]
elif isinstance(resources, Sequence):
resource_list = list(resources)
else:
raise TypeError("resources must be a string or sequence of strings")
if resource_list != [self.resource]:
raise ValueError(
f"Resource-specific decorator for {self.resource!r} cannot "
f"register handlers for {resource_list!r}. Use @auth.on(...) "
"for other or multiple resources."
)
if actions is None:
action_list = ["*"]
elif isinstance(actions, str):
action_list = [actions]
elif isinstance(actions, Sequence):
action_list = list(actions)
else:
raise TypeError("actions must be a string or sequence of strings")
if not action_list:
raise ValueError("actions must not be empty")
if not all(isinstance(action, str) for action in action_list):
raise TypeError("actions must be a string or sequence of strings")
valid_actions = {
value.action
for value in vars(self).values()
if isinstance(value, _ResourceActionOn)
}
invalid_actions = (
sorted(set(action_list) - valid_actions) if actions is not None else []
)
if invalid_actions:
raise ValueError(
f"Invalid action(s) for {self.resource}: {', '.join(invalid_actions)}"
)
if len(action_list) != len(set(action_list)):
raise ValueError("actions must not contain duplicates")
for action in action_list:
if (self.resource, action) in self.auth._handlers:
raise ValueError(
f"types.Handler already set for {self.resource}, {action}."
)
for action in action_list:
_register_handler(self.auth, self.resource, action, handler)
return handler
if fn is not None:
return decorator(
typing.cast(
"_ActionHandler[VCreate | VUpdate | VRead | VDelete | VSearch]",
fn,
)
)
return decorator
class _AssistantsOn(
_ResourceOn[
types.AssistantsCreate,
types.AssistantsRead,
types.AssistantsUpdate,
types.AssistantsDelete,
types.AssistantsSearch,
_ResourceAction,
]
):
value = (
types.AssistantsCreate
| types.AssistantsRead
| types.AssistantsUpdate
| types.AssistantsDelete
| types.AssistantsSearch
)
Create = types.AssistantsCreate
Read = types.AssistantsRead
Update = types.AssistantsUpdate
Delete = types.AssistantsDelete
Search = types.AssistantsSearch
class _ThreadsOn(
_ResourceOn[
types.ThreadsCreate,
types.ThreadsRead,
types.ThreadsUpdate,
types.ThreadsDelete,
types.ThreadsSearch,
_ThreadAction,
]
):
value = (
types.ThreadsCreate
| types.ThreadsRead
| types.ThreadsUpdate
| types.ThreadsDelete
| types.ThreadsSearch
| types.RunsCreate
)
Create = types.ThreadsCreate
Read = types.ThreadsRead
Update = types.ThreadsUpdate
Delete = types.ThreadsDelete
Search = types.ThreadsSearch
CreateRun = types.RunsCreate
def __init__(
self,
auth: Auth,
resource: typing.Literal["threads", "crons", "assistants"],
) -> None:
super().__init__(auth, resource)
self.create_run: _ResourceActionOn[types.RunsCreate] = _ResourceActionOn(
auth, resource, "create_run", self.CreateRun
)
class _CronsOn(
_ResourceOn[
types.CronsCreate,
types.CronsRead,
types.CronsUpdate,
types.CronsDelete,
types.CronsSearch,
_ResourceAction,
]
):
value = type[
types.CronsCreate
| types.CronsRead
| types.CronsUpdate
| types.CronsDelete
| types.CronsSearch
]
Create = types.CronsCreate
Read = types.CronsRead
Update = types.CronsUpdate
Delete = types.CronsDelete
Search = types.CronsSearch
class _StoreActionOn(typing.Generic[T]):
"""Decorator for registering a handler for a specific store action."""
def __init__(
self,
auth: Auth,
action: typing.Literal["put", "get", "search", "delete", "list_namespaces"],
value: type[T],
) -> None:
self.auth = auth
self.action = action
self.value = value
def __call__(self, fn: _ActionHandler[T]) -> _ActionHandler[T]:
_validate_handler(fn)
_register_handler(self.auth, "store", self.action, fn)
return fn
class _StoreOn:
def __init__(self, auth: Auth) -> None:
self._auth = auth
self.put = _StoreActionOn(auth, "put", types.StorePut)
"""Register a handler for store put operations.
???+ example "Example"
If using `@auth.on` to deny by default, register this handler to allow
put operations (scoped to the user's namespace):
```python
@auth.on.store.put
async def allow_store_put(ctx: Auth.types.AuthContext, value: Auth.types.on.store.put.value):
# Allow puts, scoped to user's namespace
value["namespace"] = (ctx.user.identity, *value["namespace"])
```
"""
self.get = _StoreActionOn(auth, "get", types.StoreGet)
"""Register a handler for store get operations.
???+ example "Example"
If using `@auth.on` to deny by default, register this handler to allow
get operations (scoped to the user's namespace):
```python
@auth.on.store.get
async def allow_store_get(ctx: Auth.types.AuthContext, value: Auth.types.on.store.get.value):
# Allow gets, scoped to user's namespace
value["namespace"] = (ctx.user.identity, *value["namespace"])
```
"""
self.search = _StoreActionOn(auth, "search", types.StoreSearch)
"""Register a handler for store search operations.
???+ example "Example"
If using `@auth.on` to deny by default, register this handler to allow
search operations (scoped to the user's namespace):
```python
@auth.on.store.search
async def allow_store_search(ctx: Auth.types.AuthContext, value: Auth.types.on.store.search.value):
# Allow searches, scoped to user's namespace
value["namespace"] = (ctx.user.identity, *value["namespace"])
```
"""
self.delete = _StoreActionOn(auth, "delete", types.StoreDelete)
"""Register a handler for store delete operations.
???+ example "Example"
If using `@auth.on` to deny by default, register this handler to allow
delete operations (scoped to the user's namespace):
```python
@auth.on.store.delete
async def allow_store_delete(ctx: Auth.types.AuthContext, value: Auth.types.on.store.delete.value):
# Allow deletes, scoped to user's namespace
value["namespace"] = (ctx.user.identity, *value["namespace"])
```
"""
self.list_namespaces = _StoreActionOn(
auth, "list_namespaces", types.StoreListNamespaces
)
"""Register a handler for store list_namespaces operations.
???+ example "Example"
If using `@auth.on` to deny by default, register this handler to allow
namespace listing (scoped to the user's prefix):
```python
@auth.on.store.list_namespaces
async def allow_list_ns(ctx: Auth.types.AuthContext, value: Auth.types.on.store.list_namespaces.value):
# Allow listing, scoped to user's namespace prefix
value["namespace"] = (ctx.user.identity,)
```
"""
@typing.overload
def __call__(
self,
*,
actions: (
typing.Literal["put", "get", "search", "list_namespaces", "delete"]
| Sequence[
typing.Literal["put", "get", "search", "list_namespaces", "delete"]
]
| None
) = None,
) -> Callable[[AHO], AHO]: ...
@typing.overload
def __call__(self, fn: AHO) -> AHO: ...
def __call__(
self,
fn: AHO | None = None,
*,
actions: (
typing.Literal["put", "get", "search", "list_namespaces", "delete"]
| Sequence[
typing.Literal["put", "get", "search", "list_namespaces", "delete"]
]
| None
) = None,
) -> AHO | Callable[[AHO], AHO]:
"""Register a handler for specific resources and actions.
Can be used as a decorator or with explicit resource/action parameters:
@auth.on.store
async def handler(): ... # Handle all store ops
@auth.on.store(actions=("put", "get", "search", "delete"))
async def handler(): ... # Handle specific store ops
@auth.on.store.put
async def handler(): ... # Handle store.put ops
"""
if fn is not None:
# Used as a plain decorator
_register_handler(self._auth, "store", None, fn)
return fn
# Used with parameters, return a decorator
def decorator(
handler: AHO,
) -> AHO:
if isinstance(actions, str):
action_list = [actions]
else:
action_list = list(actions) if actions is not None else ["*"]
for action in action_list:
_register_handler(self._auth, "store", action, handler)
return handler
return decorator
AHO = typing.TypeVar("AHO", bound=_ActionHandler[dict[str, typing.Any]])
class _On:
"""Entry point for authorization handlers that control access to specific resources.
The _On class provides a flexible way to define authorization rules for different resources
and actions in your application. It supports three main usage patterns:
1. Global handlers that run for all resources and actions
2. Resource-specific handlers that run for all actions on a resource
3. Resource and action specific handlers for fine-grained control
Each handler must be an async function that accepts two parameters:
- ctx (AuthContext): Contains request context and authenticated user info
- value: The data being authorized (type varies by endpoint)
The handler should return one of:
- None or True: Accept the request
- False: Reject with 403 error
- FilterType: Apply filtering rules to the response
???+ example "Examples"
Start by denying all requests by default with a global handler,
then add specific handlers to allow access:
```python
# Default deny: reject all requests without a specific handler
@auth.on
async def deny_all(ctx: AuthContext, value: Any) -> False:
return False
```
Resource-specific handler to allow access (takes precedence
over the global deny handler):
```python
@auth.on.threads
async def allow_thread_access(ctx: AuthContext, value: Any) -> Auth.types.FilterType:
# Allow access only to threads owned by the user
return {"owner": ctx.user.identity}
```
Resource and action specific handler:
```python
@auth.on.threads.create
async def allow_thread_create(ctx: AuthContext, value: Any) -> None:
# Allow thread creation, stamping the owner
value.setdefault("metadata", {})["owner"] = ctx.user.identity
```
Multiple resources or actions:
```python
@auth.on(resources=["threads", "assistants"], actions=["read", "search"])
async def allow_reads(ctx: AuthContext, value: Any) -> Auth.types.FilterType:
# Allow read/search, scoped to user's resources
return {"owner": ctx.user.identity}
```
"""
__slots__ = (
"_auth",
"assistants",
"crons",
"runs",
"store",
"threads",
"value",
)
def __init__(self, auth: Auth) -> None:
self._auth = auth
self.assistants = _AssistantsOn(auth, "assistants")
self.threads = _ThreadsOn(auth, "threads")
self.crons = _CronsOn(auth, "crons")
self.store = _StoreOn(auth)
self.value = dict[str, typing.Any]
@typing.overload
def __call__(
self,
*,
resources: str | Sequence[str] | None = None,
actions: str | Sequence[str] | None = None,
) -> Callable[[AHO], AHO]: ...
@typing.overload
def __call__(self, fn: AHO) -> AHO: ...
def __call__(
self,
fn: AHO | None = None,
*,
resources: str | Sequence[str] | None = None,
actions: str | Sequence[str] | None = None,
) -> AHO | Callable[[AHO], AHO]:
"""Register a handler for specific resources and actions.
Can be used as a decorator or with explicit resource/action parameters:
@auth.on
async def handler(): ... # Global handler
@auth.on(resources="threads")
async def handler(): ... # types.Handler for all thread actions
@auth.on(resources="threads", actions="create")
async def handler(): ... # types.Handler for thread creation
"""
if fn is not None:
# Used as a plain decorator
_register_handler(self._auth, None, None, fn)
return fn
# Used with parameters, return a decorator
def decorator(
handler: AHO,
) -> AHO:
if isinstance(resources, str):
resource_list = [resources]
else:
resource_list = list(resources) if resources is not None else ["*"]
if isinstance(actions, str):
action_list = [actions]
else:
action_list = list(actions) if actions is not None else ["*"]
for resource in resource_list:
for action in action_list:
_register_handler(self._auth, resource, action, handler)
return handler
return decorator
def _register_handler(
auth: Auth,
resource: str | None,
action: str | None,
fn: types.Handler,
) -> types.Handler:
_validate_handler(fn)
resource = resource or "*"
action = action or "*"
if resource == "*" and action == "*":
if auth._global_handlers:
raise ValueError("Global handler already set.")
auth._global_handlers.append(fn)
else:
r = resource if resource is not None else "*"
a = action if action is not None else "*"
if (r, a) in auth._handlers:
raise ValueError(f"types.Handler already set for {r}, {a}.")
auth._handlers[(r, a)] = [fn]
return fn
def _validate_handler(fn: Callable[..., typing.Any]) -> None:
"""Validates that an auth handler function meets the required signature.
Auth handlers must:
1. Be async functions
2. Accept a ctx parameter of type AuthContext
3. Accept a value parameter for the data being authorized
"""
if not inspect.iscoroutinefunction(fn):
raise ValueError(
f"Auth handler '{getattr(fn, '__name__', fn)}' must be an async function. "
"Add 'async' before 'def' to make it asynchronous and ensure"
" any IO operations are non-blocking."
)
sig = inspect.signature(fn)
if "ctx" not in sig.parameters:
raise ValueError(
f"Auth handler '{getattr(fn, '__name__', fn)}' must have a 'ctx: AuthContext' parameter. "
"Update the function signature to include this required parameter."
)
if "value" not in sig.parameters:
raise ValueError(
f"Auth handler '{getattr(fn, '__name__', fn)}' must have a 'value' parameter. "
" The value contains the mutable data being sent to the endpoint."
"Update the function signature to include this required parameter."
)
def is_studio_user(
user: types.MinimalUser | types.BaseUser | types.MinimalUserDict,
) -> bool:
return isinstance(user, types.StudioUser) or (
isinstance(user, dict) and user.get("kind") == "StudioUser"
)
__all__ = ["Auth", "exceptions", "types"]