diff --git a/pydantic_ai_slim/pydantic_ai/_agent_graph.py b/pydantic_ai_slim/pydantic_ai/_agent_graph.py index 2f27aac8da..e3785e7adf 100644 --- a/pydantic_ai_slim/pydantic_ai/_agent_graph.py +++ b/pydantic_ai_slim/pydantic_ai/_agent_graph.py @@ -371,9 +371,8 @@ async def run( ) -> Union[ModelRequestNode[DepsT, NodeRunEndT], End[result.FinalResult[NodeRunEndT]]]: # noqa UP007 async with self.stream(ctx): pass - - assert (next_node := self._next_node) is not None, 'the stream should set `self._next_node` before it ends' - return next_node + assert self._next_node is not None, 'the stream should set `self._next_node` before it ends' + return self._next_node @asynccontextmanager async def stream( diff --git a/pydantic_ai_slim/pydantic_ai/agent.py b/pydantic_ai_slim/pydantic_ai/agent.py index 4d4eeac2fa..a532fe4659 100644 --- a/pydantic_ai_slim/pydantic_ai/agent.py +++ b/pydantic_ai_slim/pydantic_ai/agent.py @@ -329,8 +329,8 @@ async def main(): async for _ in agent_run: pass - assert (final_result := agent_run.result) is not None, 'The graph run did not finish properly' - return final_result + assert agent_run.result is not None, 'The graph run did not finish properly' + return agent_run.result @asynccontextmanager async def iter( diff --git a/pyproject.toml b/pyproject.toml index adcd5dfece..5f7a48fafc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -102,7 +102,16 @@ include = [ ] [tool.ruff.lint] -extend-select = ["Q", "RUF100", "C90", "UP", "I", "D", "TID251"] +extend-select = [ + "Q", + "RUF100", + "RUF018", # https://docs.astral.sh/ruff/rules/assignment-in-assert/ + "C90", + "UP", + "I", + "D", + "TID251", +] flake8-quotes = { inline-quotes = "single", multiline-quotes = "double" } isort = { combine-as-imports = true, known-first-party = ["pydantic_ai"] } mccabe = { max-complexity = 15 }