From 303489566dbee6a332cf43aec13baa796292c486 Mon Sep 17 00:00:00 2001 From: Peter Corke Date: Sun, 11 Oct 2026 11:11:51 +1000 Subject: [PATCH] docs: planners return None when there is no path -- say so in :return: Co-Authored-By: Claude Sonnet 5.5 --- src/pgraph/PGraph.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/pgraph/PGraph.py b/src/pgraph/PGraph.py index 93d266b8..5853eae6 100644 --- a/src/pgraph/PGraph.py +++ b/src/pgraph/PGraph.py @@ -1845,11 +1845,13 @@ def path_BFS( :raises TypeError: ``S`` or ``G`` is neither a vertex nor a string :raises KeyError: ``S`` or ``G`` is a name not in the graph :raises ValueError: an edge on the path has no cost - :return: list of vertices from S to G inclusive, path length - :rtype: list of BaseVertex subclass, float + :return: list of vertices from S to G inclusive and path length, or + None if there is no path + :rtype: (list of BaseVertex subclass, float) or None Returns a list of vertices that form a path from vertex ``S`` to - vertex ``G`` if possible, otherwise return None. + vertex ``G`` if possible, otherwise returns None -- so check the + result before unpacking it. .. runblock:: pycon @@ -1947,11 +1949,13 @@ def path_UCS( :raises TypeError: ``S`` or ``G`` is neither a vertex nor a string :raises KeyError: ``S`` or ``G`` is a name not in the graph :raises ValueError: an edge examined during the search has no cost - :return: list of vertices from S to G inclusive, path length, tree - :rtype: list of BaseVertex subclass, float, dict + :return: list of vertices from S to G inclusive, path length and + search tree, or None if there is no path + :rtype: (list of BaseVertex subclass, float, dict) or None Returns a list of vertices that form a path from vertex ``S`` to - vertex ``G`` if possible, otherwise return None. + vertex ``G`` if possible, otherwise returns None -- so check the + result before unpacking it. The search tree is returned as dict that maps a vertex to its parent. @@ -2067,11 +2071,13 @@ def path_Astar( :raises TypeError: ``S`` or ``G`` is neither a vertex nor a string :raises KeyError: ``S`` or ``G`` is a name not in the graph :raises ValueError: an edge examined during the search has no cost - :return: list of vertices from S to G inclusive, path length, tree - :rtype: list of BaseVertex subclass, float, dict + :return: list of vertices from S to G inclusive, path length and + search tree, or None if there is no path + :rtype: (list of BaseVertex subclass, float, dict) or None Returns a list of vertices that form a path from vertex ``S`` to - vertex ``G`` if possible, otherwise return None. + vertex ``G`` if possible, otherwise returns None -- so check the + result before unpacking it. The search tree is returned as dict that maps a vertex to its parent.