Skip to content

Commit 810433f

Browse files
authored
networkx: Add type annotation to all G params (#14796)
1 parent 284acd4 commit 810433f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+183
-118
lines changed

stubs/networkx/networkx/algorithms/bipartite/edgelist.pyi

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ from networkx.utils.backends import _dispatchable
66
__all__ = ["generate_edgelist", "write_edgelist", "parse_edgelist", "read_edgelist"]
77

88
@_dispatchable
9-
def write_edgelist(G, path, comments: str = "#", delimiter: str = " ", data: bool = True, encoding: str = "utf-8") -> None: ...
9+
def write_edgelist(
10+
G: Graph[_Node], path, comments: str = "#", delimiter: str = " ", data: bool = True, encoding: str = "utf-8"
11+
) -> None: ...
1012
@_dispatchable
11-
def generate_edgelist(G, delimiter: str = " ", data: bool = True) -> Generator[str]: ...
13+
def generate_edgelist(G: Graph[_Node], delimiter: str = " ", data: bool = True) -> Generator[str]: ...
1214
@_dispatchable
1315
def parse_edgelist(
1416
lines,

stubs/networkx/networkx/algorithms/centrality/flow_matrix.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
from _typeshed import Incomplete
22
from collections.abc import Generator
33

4+
from networkx.classes.graph import Graph, _Node
45
from networkx.utils.backends import _dispatchable
56

67
@_dispatchable
7-
def flow_matrix_row(G, weight=None, dtype=..., solver: str = "lu") -> Generator[Incomplete, None, None]: ...
8+
def flow_matrix_row(G: Graph[_Node], weight=None, dtype=..., solver: str = "lu") -> Generator[Incomplete, None, None]: ...
89

910
class InverseLaplacian:
1011
dtype: Incomplete

stubs/networkx/networkx/algorithms/chordal.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ def chordal_graph_cliques(G: Graph[_Node]) -> Generator[frozenset[_Node], None,
2626
@_dispatchable
2727
def chordal_graph_treewidth(G: Graph[_Node]) -> int: ...
2828
@_dispatchable
29-
def complete_to_chordal_graph(G) -> tuple[Incomplete, dict[Incomplete, int]]: ...
29+
def complete_to_chordal_graph(G: Graph[_Node]) -> tuple[Incomplete, dict[Incomplete, int]]: ...

stubs/networkx/networkx/algorithms/clique.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ def node_clique_number(
3434
) -> dict[_Node, int]: ...
3535
@overload
3636
def node_clique_number(G: Graph[_Node], nodes=None, cliques: Iterable[Incomplete] | None = None, separate_nodes=False) -> int: ...
37-
def number_of_cliques(G, nodes=None, cliques=None) -> int | dict[Incomplete, Incomplete]: ...
37+
def number_of_cliques(G: Graph[_Node], nodes=None, cliques=None) -> int | dict[Incomplete, Incomplete]: ...
3838
@_dispatchable
39-
def max_weight_clique(G, weight="weight") -> tuple[list[Incomplete], int]: ...
39+
def max_weight_clique(G: Graph[_Node], weight="weight") -> tuple[list[Incomplete], int]: ...
4040

4141
class MaxWeightClique:
4242
G: Graph[Incomplete]

stubs/networkx/networkx/algorithms/coloring/greedy_coloring.pyi

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from _typeshed import Incomplete
1+
from _typeshed import Incomplete, Unused
22
from collections.abc import Callable, Generator
33
from typing import Final
44

@@ -18,21 +18,23 @@ __all__ = [
1818
]
1919

2020
@_dispatchable
21-
def strategy_largest_first(G, colors): ...
21+
def strategy_largest_first(G: Graph[_Node], colors: Unused): ...
2222
@_dispatchable
23-
def strategy_random_sequential(G, colors, seed=None): ...
23+
def strategy_random_sequential(G: Graph[_Node], colors: Unused, seed=None): ...
2424
@_dispatchable
25-
def strategy_smallest_last(G, colors): ...
25+
def strategy_smallest_last(G: Graph[_Node], colors: Unused): ...
2626
@_dispatchable
27-
def strategy_independent_set(G, colors) -> Generator[Incomplete, Incomplete, None]: ...
27+
def strategy_independent_set(G: Graph[_Node], colors: Unused) -> Generator[Incomplete, Incomplete, None]: ...
2828
@_dispatchable
29-
def strategy_connected_sequential_bfs(G, colors): ...
29+
def strategy_connected_sequential_bfs(G: Graph[_Node], colors): ...
3030
@_dispatchable
31-
def strategy_connected_sequential_dfs(G, colors): ...
31+
def strategy_connected_sequential_dfs(G: Graph[_Node], colors): ...
3232
@_dispatchable
33-
def strategy_connected_sequential(G, colors, traversal: str = "bfs") -> Generator[Incomplete, None, None]: ...
33+
def strategy_connected_sequential(
34+
G: Graph[_Node], colors: Unused, traversal: str = "bfs"
35+
) -> Generator[Incomplete, None, None]: ...
3436
@_dispatchable
35-
def strategy_saturation_largest_first(G, colors) -> Generator[Incomplete, None, Incomplete]: ...
37+
def strategy_saturation_largest_first(G: Graph[_Node], colors) -> Generator[Incomplete, None, Incomplete]: ...
3638

3739
STRATEGIES: Final[dict[str, Callable[..., Incomplete]]]
3840

stubs/networkx/networkx/algorithms/community/label_propagation.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ from numpy.random import RandomState
99
__all__ = ["label_propagation_communities", "asyn_lpa_communities", "fast_label_propagation_communities"]
1010

1111
@_dispatchable
12-
def fast_label_propagation_communities(G, *, weight=None, seed=None) -> Generator[Incomplete]: ...
12+
def fast_label_propagation_communities(G: Graph[_Node], *, weight=None, seed=None) -> Generator[Incomplete]: ...
1313
@_dispatchable
1414
def asyn_lpa_communities(
1515
G: Graph[_Node], weight: str | None = None, seed: int | RandomState | None = None

stubs/networkx/networkx/algorithms/community/quality.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ from networkx.utils.decorators import argmap
66
__all__ = ["modularity", "partition_quality"]
77

88
class NotAPartition(NetworkXError):
9-
def __init__(self, G, collection) -> None: ...
9+
def __init__(self, G: Graph[_Node], collection) -> None: ...
1010

1111
require_partition: argmap
1212

stubs/networkx/networkx/algorithms/connectivity/edge_kcomponents.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class EdgeComponentAuxGraph:
1818
H: Incomplete
1919

2020
@classmethod
21-
def construct(cls, G): ...
21+
def construct(cls, G: Graph[_Node]): ...
2222
def k_edge_components(self, k: int) -> Generator[Incomplete, Incomplete, None]: ...
2323
def k_edge_subgraphs(self, k: int) -> Generator[Incomplete, Incomplete, None]: ...
2424

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
from networkx.classes.graph import Graph, _Node
12
from networkx.utils.backends import _dispatchable
23

34
__all__ = ["build_auxiliary_node_connectivity", "build_auxiliary_edge_connectivity"]
45

56
@_dispatchable
6-
def build_auxiliary_node_connectivity(G): ...
7+
def build_auxiliary_node_connectivity(G: Graph[_Node]): ...
78
@_dispatchable
8-
def build_auxiliary_edge_connectivity(G): ...
9+
def build_auxiliary_edge_connectivity(G: Graph[_Node]): ...

stubs/networkx/networkx/algorithms/d_separation.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ __all__ = ["is_d_separator", "is_minimal_d_separator", "find_minimal_d_separator
99
@_dispatchable
1010
def is_d_separator(G: DiGraph[_Node], x: _Node | set[_Node], y: _Node | set[_Node], z: _Node | set[_Node]) -> bool: ...
1111
@_dispatchable
12-
def find_minimal_d_separator(G, x, y, *, included=None, restricted=None) -> set[Incomplete] | None: ...
12+
def find_minimal_d_separator(G: DiGraph[_Node], x, y, *, included=None, restricted=None) -> set[Incomplete] | None: ...
1313
@_dispatchable
1414
def is_minimal_d_separator(
1515
G: DiGraph[_Node],

0 commit comments

Comments
 (0)