From e5b9e8de03e5e1e9db696353e15d76de9c7e3fd4 Mon Sep 17 00:00:00 2001 From: Axel Dahlberg Date: Mon, 16 Jun 2025 17:44:44 +0200 Subject: [PATCH 1/3] [networkx] More precise annotation for nested tuples --- stubs/networkx/networkx/algorithms/tree/coding.pyi | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/stubs/networkx/networkx/algorithms/tree/coding.pyi b/stubs/networkx/networkx/algorithms/tree/coding.pyi index 619dc44d5142..2865ea52f825 100644 --- a/stubs/networkx/networkx/algorithms/tree/coding.pyi +++ b/stubs/networkx/networkx/algorithms/tree/coding.pyi @@ -1,4 +1,5 @@ from _typeshed import Incomplete +from typing import TypeAlias from collections.abc import Iterable from networkx.classes.graph import Graph, _Node @@ -7,12 +8,14 @@ from networkx.utils.backends import _dispatchable __all__ = ["from_nested_tuple", "from_prufer_sequence", "NotATree", "to_nested_tuple", "to_prufer_sequence"] +_NestedTuple: TypeAlias = tuple['_NestedTuple', ...] + class NotATree(NetworkXException): ... @_dispatchable def to_nested_tuple(T: Graph[_Node], root: _Node, canonical_form: bool = False): ... @_dispatchable -def from_nested_tuple(sequence: tuple[Incomplete, ...], sensible_relabeling: bool = False): ... +def from_nested_tuple(sequence: _NestedTuple, sensible_relabeling: bool = False): ... @_dispatchable def to_prufer_sequence(T: Graph[_Node]): ... @_dispatchable From b753f41962f1f4f70b14ee4196a766ed9c8b15fe Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 16 Jun 2025 15:48:04 +0000 Subject: [PATCH 2/3] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stubs/networkx/networkx/algorithms/tree/coding.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stubs/networkx/networkx/algorithms/tree/coding.pyi b/stubs/networkx/networkx/algorithms/tree/coding.pyi index 2865ea52f825..6cad6012a853 100644 --- a/stubs/networkx/networkx/algorithms/tree/coding.pyi +++ b/stubs/networkx/networkx/algorithms/tree/coding.pyi @@ -1,6 +1,6 @@ from _typeshed import Incomplete -from typing import TypeAlias from collections.abc import Iterable +from typing import TypeAlias from networkx.classes.graph import Graph, _Node from networkx.exception import NetworkXException @@ -8,7 +8,7 @@ from networkx.utils.backends import _dispatchable __all__ = ["from_nested_tuple", "from_prufer_sequence", "NotATree", "to_nested_tuple", "to_prufer_sequence"] -_NestedTuple: TypeAlias = tuple['_NestedTuple', ...] +_NestedTuple: TypeAlias = tuple[_NestedTuple, ...] class NotATree(NetworkXException): ... From 4a200d6ce12ad9a3912ae905fb9e3a4a82c0d151 Mon Sep 17 00:00:00 2001 From: Axel Dahlberg Date: Mon, 16 Jun 2025 18:08:24 +0200 Subject: [PATCH 3/3] Update stubs/networkx/networkx/algorithms/tree/coding.pyi Co-authored-by: Brian Schubert --- stubs/networkx/networkx/algorithms/tree/coding.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/networkx/networkx/algorithms/tree/coding.pyi b/stubs/networkx/networkx/algorithms/tree/coding.pyi index 6cad6012a853..87fc22938a46 100644 --- a/stubs/networkx/networkx/algorithms/tree/coding.pyi +++ b/stubs/networkx/networkx/algorithms/tree/coding.pyi @@ -1,6 +1,6 @@ from _typeshed import Incomplete from collections.abc import Iterable -from typing import TypeAlias +from typing_extensions import TypeAlias from networkx.classes.graph import Graph, _Node from networkx.exception import NetworkXException