From 41eb1a6731aae4b429781704b09e9d0cc12379d0 Mon Sep 17 00:00:00 2001 From: Avasam Date: Tue, 6 May 2025 02:39:14 -0400 Subject: [PATCH] networkx: Most nodelist params are collections (#13945) --- .../algorithms/centrality/laplacian.pyi | 5 ++--- .../algorithms/link_analysis/pagerank_alg.pyi | 4 ++-- .../algorithms/shortest_paths/dense.pyi | 4 ++-- stubs/networkx/networkx/algorithms/triads.pyi | 4 ++-- stubs/networkx/networkx/convert.pyi | 10 ++++++---- stubs/networkx/networkx/drawing/nx_pylab.pyi | 7 ++++--- .../networkx/networkx/generators/community.pyi | 3 ++- .../networkx/linalg/bethehessianmatrix.pyi | 3 ++- stubs/networkx/networkx/linalg/graphmatrix.pyi | 7 +++++-- .../networkx/linalg/laplacianmatrix.pyi | 17 +++++++++++++---- .../networkx/linalg/modularitymatrix.pyi | 5 +++-- 11 files changed, 43 insertions(+), 26 deletions(-) diff --git a/stubs/networkx/networkx/algorithms/centrality/laplacian.pyi b/stubs/networkx/networkx/algorithms/centrality/laplacian.pyi index 8dfdb2d0d..6869ac801 100644 --- a/stubs/networkx/networkx/algorithms/centrality/laplacian.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/laplacian.pyi @@ -1,5 +1,4 @@ -from _typeshed import Incomplete -from collections.abc import Iterable +from collections.abc import Collection from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -8,7 +7,7 @@ from networkx.utils.backends import _dispatchable def laplacian_centrality( G: Graph[_Node], normalized: bool = True, - nodelist: Iterable[Incomplete] | None = None, + nodelist: Collection[_Node] | None = None, weight: str | None = "weight", walk_type: str | None = None, alpha: float = 0.95, diff --git a/stubs/networkx/networkx/algorithms/link_analysis/pagerank_alg.pyi b/stubs/networkx/networkx/algorithms/link_analysis/pagerank_alg.pyi index cb3ab19ce..f79671d5c 100644 --- a/stubs/networkx/networkx/algorithms/link_analysis/pagerank_alg.pyi +++ b/stubs/networkx/networkx/algorithms/link_analysis/pagerank_alg.pyi @@ -1,5 +1,5 @@ from _typeshed import Incomplete, SupportsGetItem -from collections.abc import Iterable +from collections.abc import Collection from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -20,7 +20,7 @@ def google_matrix( G: Graph[_Node], alpha: float = 0.85, personalization: SupportsGetItem[Incomplete, Incomplete] | None = None, - nodelist: Iterable[Incomplete] | None = None, + nodelist: Collection[_Node] | None = None, weight: str | None = "weight", dangling: SupportsGetItem[Incomplete, Incomplete] | None = None, ): ... diff --git a/stubs/networkx/networkx/algorithms/shortest_paths/dense.pyi b/stubs/networkx/networkx/algorithms/shortest_paths/dense.pyi index 88e66d572..f40ce0ac0 100644 --- a/stubs/networkx/networkx/algorithms/shortest_paths/dense.pyi +++ b/stubs/networkx/networkx/algorithms/shortest_paths/dense.pyi @@ -1,11 +1,11 @@ from _typeshed import Incomplete, SupportsGetItem -from collections.abc import Iterable +from collections.abc import Collection from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @_dispatchable -def floyd_warshall_numpy(G: Graph[_Node], nodelist: Iterable[Incomplete] | None = None, weight: str | None = "weight"): ... +def floyd_warshall_numpy(G: Graph[_Node], nodelist: Collection[_Node] | None = None, weight: str | None = "weight"): ... @_dispatchable def floyd_warshall_predecessor_and_distance(G: Graph[_Node], weight: str | None = "weight"): ... @_dispatchable diff --git a/stubs/networkx/networkx/algorithms/triads.pyi b/stubs/networkx/networkx/algorithms/triads.pyi index d6bea369c..1942e68f9 100644 --- a/stubs/networkx/networkx/algorithms/triads.pyi +++ b/stubs/networkx/networkx/algorithms/triads.pyi @@ -1,5 +1,5 @@ from _typeshed import Incomplete -from collections.abc import Generator, Iterable +from collections.abc import Collection, Generator from networkx.classes.digraph import DiGraph from networkx.classes.graph import Graph, _Node @@ -7,7 +7,7 @@ from networkx.utils.backends import _dispatchable from numpy.random import RandomState @_dispatchable -def triadic_census(G: DiGraph[_Node], nodelist: Iterable[Incomplete] | None = None): ... +def triadic_census(G: DiGraph[_Node], nodelist: Collection[_Node] | None = None): ... @_dispatchable def is_triad(G: Graph[_Node]): ... @_dispatchable diff --git a/stubs/networkx/networkx/convert.pyi b/stubs/networkx/networkx/convert.pyi index d02a612f9..a85a117a9 100644 --- a/stubs/networkx/networkx/convert.pyi +++ b/stubs/networkx/networkx/convert.pyi @@ -1,5 +1,5 @@ from _typeshed import Incomplete -from collections.abc import Callable, Iterable +from collections.abc import Callable, Collection, Iterable from networkx.classes.graph import Graph, _Data, _Node from networkx.utils.backends import _dispatchable @@ -18,13 +18,15 @@ def to_networkx_graph( data: _Data[_Node], create_using: Graph[_Node] | Callable[[], Graph[_Node]] | None = None, multigraph_input: bool = False ) -> Graph[_Node]: ... @_dispatchable -def to_dict_of_lists(G: Graph[_Node], nodelist: None | Iterable[_Node] = None) -> dict[_Node, list[_Node]]: ... +def to_dict_of_lists(G: Graph[_Node], nodelist: Collection[_Node] | None = None) -> dict[_Node, list[_Node]]: ... @_dispatchable def from_dict_of_lists(d: dict[_Node, Iterable[_Node]], create_using: Incomplete | None = None) -> Graph[_Node]: ... -def to_dict_of_dicts(G: Graph[_Node], nodelist=None, edge_data=None) -> dict[Incomplete, Incomplete]: ... +def to_dict_of_dicts( + G: Graph[_Node], nodelist: Collection[_Node] | None = None, edge_data=None +) -> dict[Incomplete, Incomplete]: ... @_dispatchable def from_dict_of_dicts(d, create_using=None, multigraph_input=False) -> Graph[Incomplete]: ... @_dispatchable -def to_edgelist(G: Graph[_Node], nodelist=None): ... +def to_edgelist(G: Graph[_Node], nodelist: Collection[_Node] | None = None): ... @_dispatchable def from_edgelist(edgelist, create_using=None) -> Graph[Incomplete]: ... diff --git a/stubs/networkx/networkx/drawing/nx_pylab.pyi b/stubs/networkx/networkx/drawing/nx_pylab.pyi index 1852dcdd9..cb530376b 100644 --- a/stubs/networkx/networkx/drawing/nx_pylab.pyi +++ b/stubs/networkx/networkx/drawing/nx_pylab.pyi @@ -1,4 +1,5 @@ from _typeshed import Incomplete +from collections.abc import Collection def draw(G, pos: Incomplete | None = None, ax: Incomplete | None = None, **kwds) -> None: ... def draw_networkx( @@ -7,7 +8,7 @@ def draw_networkx( def draw_networkx_nodes( G, pos, - nodelist: Incomplete | None = None, + nodelist: Collection[Incomplete] | None = None, node_size: Incomplete | int = 300, node_color: str = "#1f78b4", node_shape: str = "o", @@ -39,7 +40,7 @@ def draw_networkx_edges( arrows: Incomplete | None = None, label: Incomplete | None = None, node_size: Incomplete | int = 300, - nodelist: Incomplete | None = None, + nodelist: list[Incomplete] | None = None, node_shape: str = "o", connectionstyle: str = "arc3", min_source_margin: int = 0, @@ -79,7 +80,7 @@ def draw_networkx_edge_labels( rotate: bool = True, clip_on: bool = True, node_size: int = 300, - nodelist: Incomplete | None = None, + nodelist: list[Incomplete] | None = None, connectionstyle: str = "arc3", hide_ticks: bool = True, ): ... diff --git a/stubs/networkx/networkx/generators/community.pyi b/stubs/networkx/networkx/generators/community.pyi index 55e386934..8cfedcb8a 100644 --- a/stubs/networkx/networkx/generators/community.pyi +++ b/stubs/networkx/networkx/generators/community.pyi @@ -1,4 +1,5 @@ from _typeshed import Incomplete +from collections.abc import Collection from networkx.utils.backends import _dispatchable @@ -22,7 +23,7 @@ def windmill_graph(n, k): ... def stochastic_block_model( sizes, p, - nodelist: Incomplete | None = None, + nodelist: Collection[Incomplete] | None = None, seed: Incomplete | None = None, directed: bool = False, selfloops: bool = False, diff --git a/stubs/networkx/networkx/linalg/bethehessianmatrix.pyi b/stubs/networkx/networkx/linalg/bethehessianmatrix.pyi index a122ca706..70bafa4f9 100644 --- a/stubs/networkx/networkx/linalg/bethehessianmatrix.pyi +++ b/stubs/networkx/networkx/linalg/bethehessianmatrix.pyi @@ -1,6 +1,7 @@ from _typeshed import Incomplete +from collections.abc import Collection from networkx.utils.backends import _dispatchable @_dispatchable -def bethe_hessian_matrix(G, r: Incomplete | None = None, nodelist: Incomplete | None = None): ... +def bethe_hessian_matrix(G, r: Incomplete | None = None, nodelist: Collection[Incomplete] | None = None): ... diff --git a/stubs/networkx/networkx/linalg/graphmatrix.pyi b/stubs/networkx/networkx/linalg/graphmatrix.pyi index 6eb0c4243..a26cdff36 100644 --- a/stubs/networkx/networkx/linalg/graphmatrix.pyi +++ b/stubs/networkx/networkx/linalg/graphmatrix.pyi @@ -1,14 +1,17 @@ from _typeshed import Incomplete +from collections.abc import Collection from networkx.utils.backends import _dispatchable @_dispatchable def incidence_matrix( G, - nodelist: Incomplete | None = None, + nodelist: Collection[Incomplete] | None = None, edgelist: Incomplete | None = None, oriented: bool = False, weight: Incomplete | None = None, ): ... @_dispatchable -def adjacency_matrix(G, nodelist: Incomplete | None = None, dtype: Incomplete | None = None, weight: str = "weight"): ... +def adjacency_matrix( + G, nodelist: Collection[Incomplete] | None = None, dtype: Incomplete | None = None, weight: str = "weight" +): ... diff --git a/stubs/networkx/networkx/linalg/laplacianmatrix.pyi b/stubs/networkx/networkx/linalg/laplacianmatrix.pyi index 5e607d91b..db9a7745c 100644 --- a/stubs/networkx/networkx/linalg/laplacianmatrix.pyi +++ b/stubs/networkx/networkx/linalg/laplacianmatrix.pyi @@ -1,18 +1,27 @@ from _typeshed import Incomplete +from collections.abc import Collection from networkx.utils.backends import _dispatchable @_dispatchable -def laplacian_matrix(G, nodelist: Incomplete | None = None, weight: str = "weight"): ... +def laplacian_matrix(G, nodelist: Collection[Incomplete] | None = None, weight: str = "weight"): ... @_dispatchable -def normalized_laplacian_matrix(G, nodelist: Incomplete | None = None, weight: str = "weight"): ... +def normalized_laplacian_matrix(G, nodelist: Collection[Incomplete] | None = None, weight: str = "weight"): ... @_dispatchable def total_spanning_tree_weight(G, weight: Incomplete | None = None): ... @_dispatchable def directed_laplacian_matrix( - G, nodelist: Incomplete | None = None, weight: str = "weight", walk_type: Incomplete | None = None, alpha: float = 0.95 + G, + nodelist: Collection[Incomplete] | None = None, + weight: str = "weight", + walk_type: Incomplete | None = None, + alpha: float = 0.95, ): ... @_dispatchable def directed_combinatorial_laplacian_matrix( - G, nodelist: Incomplete | None = None, weight: str = "weight", walk_type: Incomplete | None = None, alpha: float = 0.95 + G, + nodelist: Collection[Incomplete] | None = None, + weight: str = "weight", + walk_type: Incomplete | None = None, + alpha: float = 0.95, ): ... diff --git a/stubs/networkx/networkx/linalg/modularitymatrix.pyi b/stubs/networkx/networkx/linalg/modularitymatrix.pyi index 5ef6eec7c..7cc73a5f0 100644 --- a/stubs/networkx/networkx/linalg/modularitymatrix.pyi +++ b/stubs/networkx/networkx/linalg/modularitymatrix.pyi @@ -1,8 +1,9 @@ from _typeshed import Incomplete +from collections.abc import Collection from networkx.utils.backends import _dispatchable @_dispatchable -def modularity_matrix(G, nodelist: Incomplete | None = None, weight: Incomplete | None = None): ... +def modularity_matrix(G, nodelist: Collection[Incomplete] | None = None, weight: Incomplete | None = None): ... @_dispatchable -def directed_modularity_matrix(G, nodelist: Incomplete | None = None, weight: Incomplete | None = None): ... +def directed_modularity_matrix(G, nodelist: Collection[Incomplete] | None = None, weight: Incomplete | None = None): ...