pydantic-graph 1.22.0__tar.gz → 1.31.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. {pydantic_graph-1.22.0 → pydantic_graph-1.31.0}/PKG-INFO +1 -1
  2. {pydantic_graph-1.22.0 → pydantic_graph-1.31.0}/pydantic_graph/beta/graph.py +14 -11
  3. {pydantic_graph-1.22.0 → pydantic_graph-1.31.0}/pydantic_graph/beta/graph_builder.py +5 -3
  4. {pydantic_graph-1.22.0 → pydantic_graph-1.31.0}/pydantic_graph/beta/mermaid.py +1 -1
  5. {pydantic_graph-1.22.0 → pydantic_graph-1.31.0}/.gitignore +0 -0
  6. {pydantic_graph-1.22.0 → pydantic_graph-1.31.0}/LICENSE +0 -0
  7. {pydantic_graph-1.22.0 → pydantic_graph-1.31.0}/README.md +0 -0
  8. {pydantic_graph-1.22.0 → pydantic_graph-1.31.0}/pydantic_graph/__init__.py +0 -0
  9. {pydantic_graph-1.22.0 → pydantic_graph-1.31.0}/pydantic_graph/_utils.py +0 -0
  10. {pydantic_graph-1.22.0 → pydantic_graph-1.31.0}/pydantic_graph/beta/__init__.py +0 -0
  11. {pydantic_graph-1.22.0 → pydantic_graph-1.31.0}/pydantic_graph/beta/decision.py +0 -0
  12. {pydantic_graph-1.22.0 → pydantic_graph-1.31.0}/pydantic_graph/beta/id_types.py +0 -0
  13. {pydantic_graph-1.22.0 → pydantic_graph-1.31.0}/pydantic_graph/beta/join.py +0 -0
  14. {pydantic_graph-1.22.0 → pydantic_graph-1.31.0}/pydantic_graph/beta/node.py +0 -0
  15. {pydantic_graph-1.22.0 → pydantic_graph-1.31.0}/pydantic_graph/beta/node_types.py +0 -0
  16. {pydantic_graph-1.22.0 → pydantic_graph-1.31.0}/pydantic_graph/beta/parent_forks.py +0 -0
  17. {pydantic_graph-1.22.0 → pydantic_graph-1.31.0}/pydantic_graph/beta/paths.py +0 -0
  18. {pydantic_graph-1.22.0 → pydantic_graph-1.31.0}/pydantic_graph/beta/step.py +0 -0
  19. {pydantic_graph-1.22.0 → pydantic_graph-1.31.0}/pydantic_graph/beta/util.py +0 -0
  20. {pydantic_graph-1.22.0 → pydantic_graph-1.31.0}/pydantic_graph/exceptions.py +0 -0
  21. {pydantic_graph-1.22.0 → pydantic_graph-1.31.0}/pydantic_graph/graph.py +0 -0
  22. {pydantic_graph-1.22.0 → pydantic_graph-1.31.0}/pydantic_graph/mermaid.py +0 -0
  23. {pydantic_graph-1.22.0 → pydantic_graph-1.31.0}/pydantic_graph/nodes.py +0 -0
  24. {pydantic_graph-1.22.0 → pydantic_graph-1.31.0}/pydantic_graph/persistence/__init__.py +0 -0
  25. {pydantic_graph-1.22.0 → pydantic_graph-1.31.0}/pydantic_graph/persistence/_utils.py +0 -0
  26. {pydantic_graph-1.22.0 → pydantic_graph-1.31.0}/pydantic_graph/persistence/file.py +0 -0
  27. {pydantic_graph-1.22.0 → pydantic_graph-1.31.0}/pydantic_graph/persistence/in_mem.py +0 -0
  28. {pydantic_graph-1.22.0 → pydantic_graph-1.31.0}/pydantic_graph/py.typed +0 -0
  29. {pydantic_graph-1.22.0 → pydantic_graph-1.31.0}/pyproject.toml +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pydantic-graph
3
- Version: 1.22.0
3
+ Version: 1.31.0
4
4
  Summary: Graph and state machine library
5
5
  Project-URL: Homepage, https://ai.pydantic.dev/graph/tree/main/pydantic_graph
6
6
  Project-URL: Source, https://github.com/pydantic/pydantic-ai
@@ -13,7 +13,7 @@ from contextlib import AbstractContextManager, AsyncExitStack, ExitStack, asyncc
13
13
  from dataclasses import dataclass, field
14
14
  from typing import TYPE_CHECKING, Any, Generic, Literal, TypeGuard, cast, get_args, get_origin, overload
15
15
 
16
- from anyio import CancelScope, create_memory_object_stream, create_task_group
16
+ from anyio import BrokenResourceError, CancelScope, create_memory_object_stream, create_task_group
17
17
  from anyio.abc import TaskGroup
18
18
  from anyio.streams.memory import MemoryObjectReceiveStream, MemoryObjectSendStream
19
19
  from typing_extensions import TypeVar, assert_never
@@ -43,9 +43,9 @@ from pydantic_graph.beta.util import unpack_type_expression
43
43
  from pydantic_graph.nodes import BaseNode, End
44
44
 
45
45
  if sys.version_info < (3, 11):
46
- from exceptiongroup import ExceptionGroup as ExceptionGroup # pragma: lax no cover
46
+ from exceptiongroup import BaseExceptionGroup as BaseExceptionGroup # pragma: lax no cover
47
47
  else:
48
- ExceptionGroup = ExceptionGroup # pragma: lax no cover
48
+ BaseExceptionGroup = BaseExceptionGroup # pragma: lax no cover
49
49
 
50
50
  if TYPE_CHECKING:
51
51
  from pydantic_graph.beta.mermaid import StateDiagramDirection
@@ -562,7 +562,7 @@ class _GraphIterator(Generic[StateT, DepsT, OutputT]):
562
562
  self.iter_stream_sender, self.iter_stream_receiver = create_memory_object_stream[_GraphTaskResult]()
563
563
  self._next_node_run_id = 1
564
564
 
565
- async def iter_graph( # noqa C901
565
+ async def iter_graph( # noqa: C901
566
566
  self, first_task: GraphTask
567
567
  ) -> AsyncGenerator[EndMarker[OutputT] | Sequence[GraphTask], EndMarker[OutputT] | Sequence[GraphTask]]:
568
568
  async with self.iter_stream_sender:
@@ -748,12 +748,15 @@ class _GraphIterator(Generic[StateT, DepsT, OutputT]):
748
748
  with CancelScope() as scope:
749
749
  self.cancel_scopes[t_.task_id] = scope
750
750
  result = await self._run_task(t_)
751
- if isinstance(result, _GraphTaskAsyncIterable):
752
- async for new_tasks in result.iterable:
753
- await self.iter_stream_sender.send(_GraphTaskResult(t_, new_tasks, False))
754
- await self.iter_stream_sender.send(_GraphTaskResult(t_, []))
755
- else:
756
- await self.iter_stream_sender.send(_GraphTaskResult(t_, result))
751
+ try:
752
+ if isinstance(result, _GraphTaskAsyncIterable):
753
+ async for new_tasks in result.iterable:
754
+ await self.iter_stream_sender.send(_GraphTaskResult(t_, new_tasks, False))
755
+ await self.iter_stream_sender.send(_GraphTaskResult(t_, []))
756
+ else:
757
+ await self.iter_stream_sender.send(_GraphTaskResult(t_, result))
758
+ except BrokenResourceError:
759
+ pass # pragma: no cover # This can happen in difficult-to-reproduce circumstances when cancelling an asyncio task
757
760
 
758
761
  async def _run_task(
759
762
  self,
@@ -970,7 +973,7 @@ def _unwrap_exception_groups():
970
973
  else:
971
974
  try:
972
975
  yield
973
- except ExceptionGroup as e:
976
+ except BaseExceptionGroup as e:
974
977
  exception = e.exceptions[0]
975
978
  if exception.__cause__ is None:
976
979
  # bizarrely, this prevents recursion errors when formatting the exception for logfire
@@ -284,6 +284,8 @@ class GraphBuilder(Generic[StateT, DepsT, GraphInputT, GraphOutputT]):
284
284
  async def wrapper(ctx: StepContext[StateT, DepsT, InputT]):
285
285
  return call(ctx)
286
286
 
287
+ node_id = node_id or get_callable_name(call)
288
+
287
289
  return self.step(call=wrapper, node_id=node_id, label=label)
288
290
 
289
291
  @overload
@@ -318,7 +320,7 @@ class GraphBuilder(Generic[StateT, DepsT, GraphInputT, GraphOutputT]):
318
320
  preferred_parent_fork: Literal['farthest', 'closest'] = 'farthest',
319
321
  ) -> Join[StateT, DepsT, InputT, OutputT]:
320
322
  if initial_factory is UNSET:
321
- initial_factory = lambda: initial # pyright: ignore[reportAssignmentType] # noqa E731
323
+ initial_factory = lambda: initial # pyright: ignore[reportAssignmentType] # noqa: E731
322
324
 
323
325
  return Join[StateT, DepsT, InputT, OutputT](
324
326
  id=JoinID(NodeID(node_id or generate_placeholder_node_id(get_callable_name(reducer)))),
@@ -329,7 +331,7 @@ class GraphBuilder(Generic[StateT, DepsT, GraphInputT, GraphOutputT]):
329
331
  )
330
332
 
331
333
  # Edge building
332
- def add(self, *edges: EdgePath[StateT, DepsT]) -> None: # noqa C901
334
+ def add(self, *edges: EdgePath[StateT, DepsT]) -> None: # noqa: C901
333
335
  """Add one or more edge paths to the graph.
334
336
 
335
337
  This method processes edge paths and automatically creates any necessary
@@ -674,7 +676,7 @@ class GraphBuilder(Generic[StateT, DepsT, GraphInputT, GraphOutputT]):
674
676
  )
675
677
 
676
678
 
677
- def _validate_graph_structure( # noqa C901
679
+ def _validate_graph_structure( # noqa: C901
678
680
  nodes: dict[NodeID, AnyNode],
679
681
  edges_by_source: dict[NodeID, list[Path]],
680
682
  ) -> None:
@@ -49,7 +49,7 @@ class MermaidEdge:
49
49
  label: str | None
50
50
 
51
51
 
52
- def build_mermaid_graph( # noqa C901
52
+ def build_mermaid_graph( # noqa: C901
53
53
  graph_nodes: dict[NodeID, AnyNode], graph_edges_by_source: dict[NodeID, list[Path]]
54
54
  ) -> MermaidGraph:
55
55
  """Build a mermaid graph."""
File without changes