From 540e817ae5b7d1a27b7feb7e0021957fc8565a31 Mon Sep 17 00:00:00 2001 From: Daniel Shafer Date: Wed, 28 Oct 2026 14:41:00 +0000 Subject: [PATCH 1/2] [networkx] Use concrete node types for the Harary, circulant and expander generators --- stubs/networkx/networkx/generators/classic.pyi | 2 +- stubs/networkx/networkx/generators/expanders.pyi | 12 +++++++----- stubs/networkx/networkx/generators/harary_graph.pyi | 4 ++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/stubs/networkx/networkx/generators/classic.pyi b/stubs/networkx/networkx/generators/classic.pyi index bd070af62575..f84af8a5d1ae 100644 --- a/stubs/networkx/networkx/generators/classic.pyi +++ b/stubs/networkx/networkx/generators/classic.pyi @@ -51,7 +51,7 @@ def circular_ladder_graph(n, create_using=None): ... @_dispatchable def circulant_graph( n: int, offsets: list[int], create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None -) -> Graph[Incomplete]: ... +) -> Graph[int]: ... @_dispatchable def cycle_graph(n: int | Iterable[Incomplete], create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None): ... @_dispatchable diff --git a/stubs/networkx/networkx/generators/expanders.pyi b/stubs/networkx/networkx/generators/expanders.pyi index 72d061145a1a..2732dd2099b1 100644 --- a/stubs/networkx/networkx/generators/expanders.pyi +++ b/stubs/networkx/networkx/generators/expanders.pyi @@ -18,13 +18,13 @@ __all__ = [ @_dispatchable def margulis_gabber_galil_graph( n: int, create_using: MultiGraph[Incomplete] | type[MultiGraph[Incomplete]] | None = None -) -> Graph[Incomplete]: ... +) -> Graph[tuple[int, int]]: ... @_dispatchable -def chordal_cycle_graph(p: int, create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None) -> Graph[Incomplete]: ... +def chordal_cycle_graph(p: int, create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None) -> Graph[int]: ... @_dispatchable -def paley_graph(p: int, create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None) -> Graph[Incomplete]: ... +def paley_graph(p: int, create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None) -> Graph[int]: ... @_dispatchable -def maybe_regular_expander_graph(n: int, d: int, *, create_using=None, max_tries: int = 100, seed=None) -> Graph[Incomplete]: ... +def maybe_regular_expander_graph(n: int, d: int, *, create_using=None, max_tries: int = 100, seed=None) -> Graph[int]: ... @deprecated( "`maybe_regular_expander` is a deprecated alias for `maybe_regular_expander_graph`. " "Use `maybe_regular_expander_graph` instead." @@ -33,4 +33,6 @@ def maybe_regular_expander(n, d, *, create_using=None, max_tries: int = 100, see @_dispatchable def is_regular_expander(G: Graph[_Node], *, epsilon: float = 0) -> bool: ... @_dispatchable -def random_regular_expander_graph(n: int, d: int, *, epsilon=0, create_using=None, max_tries=100, seed=None): ... +def random_regular_expander_graph( + n: int, d: int, *, epsilon=0, create_using=None, max_tries=100, seed=None +) -> Graph[int]: ... diff --git a/stubs/networkx/networkx/generators/harary_graph.pyi b/stubs/networkx/networkx/generators/harary_graph.pyi index bf2d609225a0..79dbb3d4b2a0 100644 --- a/stubs/networkx/networkx/generators/harary_graph.pyi +++ b/stubs/networkx/networkx/generators/harary_graph.pyi @@ -8,8 +8,8 @@ __all__ = ["hnm_harary_graph", "hkn_harary_graph"] @_dispatchable def hnm_harary_graph( n: int, m: int, create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None -) -> Graph[Incomplete]: ... +) -> Graph[int]: ... @_dispatchable def hkn_harary_graph( k: int, n: int, create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None -) -> Graph[Incomplete]: ... +) -> Graph[int]: ... From 89d11b3d0c902983da0daac1c4d12570b65f60ee Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 28 Oct 2026 14:43:36 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stubs/networkx/networkx/generators/expanders.pyi | 4 +--- stubs/networkx/networkx/generators/harary_graph.pyi | 8 ++------ 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/stubs/networkx/networkx/generators/expanders.pyi b/stubs/networkx/networkx/generators/expanders.pyi index 2732dd2099b1..204521e652c1 100644 --- a/stubs/networkx/networkx/generators/expanders.pyi +++ b/stubs/networkx/networkx/generators/expanders.pyi @@ -33,6 +33,4 @@ def maybe_regular_expander(n, d, *, create_using=None, max_tries: int = 100, see @_dispatchable def is_regular_expander(G: Graph[_Node], *, epsilon: float = 0) -> bool: ... @_dispatchable -def random_regular_expander_graph( - n: int, d: int, *, epsilon=0, create_using=None, max_tries=100, seed=None -) -> Graph[int]: ... +def random_regular_expander_graph(n: int, d: int, *, epsilon=0, create_using=None, max_tries=100, seed=None) -> Graph[int]: ... diff --git a/stubs/networkx/networkx/generators/harary_graph.pyi b/stubs/networkx/networkx/generators/harary_graph.pyi index 79dbb3d4b2a0..78837bd580f7 100644 --- a/stubs/networkx/networkx/generators/harary_graph.pyi +++ b/stubs/networkx/networkx/generators/harary_graph.pyi @@ -6,10 +6,6 @@ from networkx.utils.backends import _dispatchable __all__ = ["hnm_harary_graph", "hkn_harary_graph"] @_dispatchable -def hnm_harary_graph( - n: int, m: int, create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None -) -> Graph[int]: ... +def hnm_harary_graph(n: int, m: int, create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None) -> Graph[int]: ... @_dispatchable -def hkn_harary_graph( - k: int, n: int, create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None -) -> Graph[int]: ... +def hkn_harary_graph(k: int, n: int, create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None) -> Graph[int]: ...