diff --git a/stubs/networkx/networkx/algorithms/approximation/maxcut.pyi b/stubs/networkx/networkx/algorithms/approximation/maxcut.pyi index af1c01f9ec8e..403990cef627 100644 --- a/stubs/networkx/networkx/algorithms/approximation/maxcut.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/maxcut.pyi @@ -1,4 +1,5 @@ from _typeshed import Incomplete +from collections.abc import Iterable from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -12,5 +13,8 @@ def randomized_partitioning( ): ... @_dispatchable def one_exchange( - G: Graph[_Node], initial_cut: set[Incomplete] | None = None, seed: int | RandomState | None = None, weight: str | None = None + G: Graph[_Node], + initial_cut: Iterable[Incomplete] | None = None, + seed: int | RandomState | None = None, + weight: str | None = None, ): ... diff --git a/stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi b/stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi index eaff9c69cc07..cd33c37a058a 100644 --- a/stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi +++ b/stubs/networkx/networkx/algorithms/approximation/traveling_salesman.pyi @@ -30,7 +30,7 @@ def traveling_salesman_problem( cycle: bool = True, method: Callable[..., Incomplete] | None = None, **kwargs, -): ... +) -> list[Incomplete]: ... @_dispatchable def asadpour_atsp( G: DiGraph[_Node], weight: str | None = "weight", seed: int | RandomState | None = None, source: str | None = None diff --git a/stubs/networkx/networkx/algorithms/assortativity/correlation.pyi b/stubs/networkx/networkx/algorithms/assortativity/correlation.pyi index 78f36749726d..7029272e0899 100644 --- a/stubs/networkx/networkx/algorithms/assortativity/correlation.pyi +++ b/stubs/networkx/networkx/algorithms/assortativity/correlation.pyi @@ -23,3 +23,4 @@ def degree_pearson_correlation_coefficient( def attribute_assortativity_coefficient(G: Graph[_Node], attribute: str, nodes: Iterable[Incomplete] | None = None) -> float: ... @_dispatchable def numeric_assortativity_coefficient(G: Graph[_Node], attribute: str, nodes: Iterable[Incomplete] | None = None) -> float: ... +def attribute_ac(M) -> float: ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/edgelist.pyi b/stubs/networkx/networkx/algorithms/bipartite/edgelist.pyi index a80cc0fc6e36..7d578a5d6744 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/edgelist.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/edgelist.pyi @@ -1,4 +1,5 @@ -from collections.abc import Generator +from _typeshed import Incomplete +from collections.abc import Generator, Iterable from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -7,10 +8,15 @@ __all__ = ["generate_edgelist", "write_edgelist", "parse_edgelist", "read_edgeli @_dispatchable def write_edgelist( - G: Graph[_Node], path, comments: str = "#", delimiter: str = " ", data: bool = True, encoding: str = "utf-8" + G: Graph[_Node], + path, + comments: str = "#", + delimiter: str = " ", + data: bool | Iterable[Incomplete] = True, + encoding: str = "utf-8", ) -> None: ... @_dispatchable -def generate_edgelist(G: Graph[_Node], delimiter: str = " ", data: bool = True) -> Generator[str]: ... +def generate_edgelist(G: Graph[_Node], delimiter: str = " ", data: bool | Iterable[Incomplete] = True) -> Generator[str]: ... @_dispatchable def parse_edgelist( lines, @@ -18,7 +24,7 @@ def parse_edgelist( delimiter: str | None = None, create_using: Graph[_Node] | None = None, nodetype=None, - data=True, + data: bool | Iterable[Incomplete] = True, ): ... @_dispatchable def read_edgelist( @@ -27,7 +33,7 @@ def read_edgelist( delimiter: str | None = None, create_using=None, nodetype=None, - data=True, + data: bool | Iterable[Incomplete] = True, edgetype=None, encoding: str | None = "utf-8", ): ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/generators.pyi b/stubs/networkx/networkx/algorithms/bipartite/generators.pyi index f9aef242b895..491ad84d51b0 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/generators.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/generators.pyi @@ -1,5 +1,5 @@ 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 @@ -20,24 +20,24 @@ __all__ = [ def complete_bipartite_graph(n1, n2, create_using: Graph[_Node] | None = None): ... @_dispatchable def configuration_model( - aseq: Iterable[Incomplete], - bseq: Iterable[Incomplete], + aseq: Collection[Incomplete], + bseq: Collection[Incomplete], create_using: Graph[_Node] | None = None, seed: int | RandomState | None = None, ): ... @_dispatchable -def havel_hakimi_graph(aseq: Iterable[Incomplete], bseq: Iterable[Incomplete], create_using: Graph[_Node] | None = None): ... +def havel_hakimi_graph(aseq: Collection[Incomplete], bseq: Collection[Incomplete], create_using: Graph[_Node] | None = None): ... @_dispatchable def reverse_havel_hakimi_graph( - aseq: Iterable[Incomplete], bseq: Iterable[Incomplete], create_using: Graph[_Node] | None = None + aseq: Collection[Incomplete], bseq: Collection[Incomplete], create_using: Graph[_Node] | None = None ): ... @_dispatchable def alternating_havel_hakimi_graph( - aseq: Iterable[Incomplete], bseq: Iterable[Incomplete], create_using: Graph[_Node] | None = None + aseq: Collection[Incomplete], bseq: Collection[Incomplete], create_using: Graph[_Node] | None = None ): ... @_dispatchable def preferential_attachment_graph( - aseq: Iterable[Incomplete], p: float, create_using: Graph[_Node] | None = None, seed: int | RandomState | None = None + aseq: Collection[Incomplete], p: float, create_using: Graph[_Node] | None = None, seed: int | RandomState | None = None ): ... @_dispatchable def random_graph(n: int, m: int, p: float, seed: int | RandomState | None = None, directed: bool | None = False): ... diff --git a/stubs/networkx/networkx/algorithms/bipartite/matching.pyi b/stubs/networkx/networkx/algorithms/bipartite/matching.pyi index cdf9dddbbbf1..d8c79210f491 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/matching.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/matching.pyi @@ -1,4 +1,4 @@ -from _typeshed import Incomplete, SupportsGetItem +from _typeshed import Incomplete from collections.abc import Iterable from networkx.classes.graph import Graph, _Node @@ -11,9 +11,7 @@ def hopcroft_karp_matching(G: Graph[_Node], top_nodes: Iterable[_Node] | None = @_dispatchable def eppstein_matching(G: Graph[_Node], top_nodes: Iterable[Incomplete] | None = None) -> dict[Incomplete, Incomplete]: ... @_dispatchable -def to_vertex_cover( - G: Graph[_Node], matching: SupportsGetItem[Incomplete, Incomplete], top_nodes: Iterable[Incomplete] | None = None -): ... +def to_vertex_cover(G: Graph[_Node], matching: Iterable[Incomplete], top_nodes: Iterable[Incomplete] | None = None): ... maximum_matching = hopcroft_karp_matching diff --git a/stubs/networkx/networkx/algorithms/bipartite/matrix.pyi b/stubs/networkx/networkx/algorithms/bipartite/matrix.pyi index b33fed570b98..817e4e4cbbfd 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/matrix.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/matrix.pyi @@ -1,5 +1,5 @@ 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 @@ -9,8 +9,8 @@ __all__ = ["biadjacency_matrix", "from_biadjacency_matrix"] @_dispatchable def biadjacency_matrix( G: Graph[_Node], - row_order: Iterable[_Node], - column_order: Iterable[Incomplete] | None = None, + row_order: Collection[_Node], + column_order: Collection[Incomplete] | None = None, dtype=None, weight: str | None = "weight", format="csr", diff --git a/stubs/networkx/networkx/algorithms/bipartite/projection.pyi b/stubs/networkx/networkx/algorithms/bipartite/projection.pyi index 9f1fd27d3880..c3dabf1bfb90 100644 --- a/stubs/networkx/networkx/algorithms/bipartite/projection.pyi +++ b/stubs/networkx/networkx/algorithms/bipartite/projection.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, _Node from networkx.utils.backends import _dispatchable @@ -15,7 +15,7 @@ __all__ = [ @_dispatchable def projected_graph(B: Graph[_Node], nodes: Iterable[Incomplete], multigraph: bool = False): ... @_dispatchable -def weighted_projected_graph(B: Graph[_Node], nodes: Iterable[Incomplete], ratio: bool = False): ... +def weighted_projected_graph(B: Graph[_Node], nodes: Collection[Incomplete], ratio: bool = False): ... @_dispatchable def collaboration_weighted_projected_graph(B: Graph[_Node], nodes: Iterable[Incomplete]): ... @_dispatchable diff --git a/stubs/networkx/networkx/algorithms/boundary.pyi b/stubs/networkx/networkx/algorithms/boundary.pyi index 7cbec735e1b5..17a8ee24e8a3 100644 --- a/stubs/networkx/networkx/algorithms/boundary.pyi +++ b/stubs/networkx/networkx/algorithms/boundary.pyi @@ -13,7 +13,7 @@ def edge_boundary( G: Graph[_Node], nbunch1: Iterable[Incomplete], nbunch2: Iterable[Incomplete] | None = None, - data=False, + data: bool | Incomplete = False, keys: bool = False, default=None, ) -> Generator[tuple[_Node, _Node], None, None]: ... @@ -22,7 +22,7 @@ def edge_boundary( G: Graph[_Node], nbunch1: Iterable[Incomplete], nbunch2: Iterable[Incomplete] | None = None, - data=False, + data: bool | Incomplete = False, keys: bool = False, default=None, ) -> Generator[tuple[_Node, _Node, dict[str, Incomplete]], None, None]: ... @@ -31,7 +31,7 @@ def edge_boundary( G: Graph[_Node], nbunch1: Iterable[Incomplete], nbunch2: Iterable[Incomplete] | None = None, - data=False, + data: bool | Incomplete = False, keys: bool = False, default=None, ) -> Generator[tuple[_Node, _Node, dict[str, Incomplete]], None, None]: ... @@ -40,7 +40,7 @@ def edge_boundary( G: Graph[_Node], nbunch1: Iterable[Incomplete], nbunch2: Iterable[Incomplete] | None = None, - data=False, + data: bool | Incomplete = False, keys: bool = False, default: _U | None = None, ) -> Generator[tuple[_Node, _Node, dict[str, _U]], None, None]: ... @@ -49,7 +49,7 @@ def edge_boundary( G: Graph[_Node], nbunch1: Iterable[Incomplete], nbunch2: Iterable[Incomplete] | None = None, - data=False, + data: bool | Incomplete = False, keys: bool = False, default: _U | None = None, ) -> Generator[tuple[_Node, _Node, dict[str, _U]], None, None]: ... @@ -58,7 +58,7 @@ def edge_boundary( G: Graph[_Node], nbunch1: Iterable[Incomplete], nbunch2: Iterable[Incomplete] | None = None, - data=False, + data: bool | Incomplete = False, keys: bool = False, default=None, ) -> Generator[tuple[_Node, _Node, int], None, None]: ... @@ -67,7 +67,7 @@ def edge_boundary( G: Graph[_Node], nbunch1: Iterable[Incomplete], nbunch2: Iterable[Incomplete] | None = None, - data=False, + data: bool | Incomplete = False, keys: bool = False, default=None, ) -> Generator[tuple[_Node, _Node, int], None, None]: ... @@ -76,7 +76,7 @@ def edge_boundary( G: Graph[_Node], nbunch1: Iterable[Incomplete], nbunch2: Iterable[Incomplete] | None = None, - data=False, + data: bool | Incomplete = False, keys: bool = False, default=None, ) -> Generator[tuple[_Node, _Node, int, dict[str, Incomplete]], None, None]: ... @@ -85,7 +85,7 @@ def edge_boundary( G: Graph[_Node], nbunch1: Iterable[Incomplete], nbunch2: Iterable[Incomplete] | None = None, - data=False, + data: bool | Incomplete = False, keys: bool = False, default=None, ) -> Generator[tuple[_Node, _Node, int, dict[str, Incomplete]], None, None]: ... @@ -94,7 +94,7 @@ def edge_boundary( G: Graph[_Node], nbunch1: Iterable[Incomplete], nbunch2: Iterable[Incomplete] | None = None, - data=False, + data: bool | Incomplete = False, keys: bool = False, default: _U | None = None, ) -> Generator[tuple[_Node, _Node, int, dict[str, _U]], None, None]: ... @@ -103,7 +103,7 @@ def edge_boundary( G: Graph[_Node], nbunch1: Iterable[Incomplete], nbunch2: Iterable[Incomplete] | None = None, - data=False, + data: bool | Incomplete = False, keys: bool = False, default: _U | None = None, ) -> Generator[tuple[_Node, _Node, int, dict[str, _U]], None, None]: ... diff --git a/stubs/networkx/networkx/algorithms/centrality/closeness.pyi b/stubs/networkx/networkx/algorithms/centrality/closeness.pyi index 72201138a975..cf390e6a0c77 100644 --- a/stubs/networkx/networkx/algorithms/centrality/closeness.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/closeness.pyi @@ -1,4 +1,5 @@ -from _typeshed import Incomplete, SupportsGetItem +from _typeshed import Incomplete +from collections.abc import Mapping from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -13,7 +14,7 @@ def closeness_centrality( def incremental_closeness_centrality( G: Graph[_Node], edge: tuple[Incomplete], - prev_cc: SupportsGetItem[Incomplete, Incomplete] | None = None, + prev_cc: Mapping[Incomplete, Incomplete] | None = None, insertion: bool | None = True, wf_improved: bool | None = True, ) -> dict[_Node, float]: ... diff --git a/stubs/networkx/networkx/algorithms/centrality/eigenvector.pyi b/stubs/networkx/networkx/algorithms/centrality/eigenvector.pyi index d0e6f96b92cb..75ee56abc272 100644 --- a/stubs/networkx/networkx/algorithms/centrality/eigenvector.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/eigenvector.pyi @@ -1,4 +1,5 @@ -from _typeshed import Incomplete, SupportsGetItem +from _typeshed import Incomplete +from collections.abc import Mapping from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -10,7 +11,7 @@ def eigenvector_centrality( G: Graph[_Node], max_iter: int | None = 100, tol: float | None = 1e-06, - nstart: SupportsGetItem[Incomplete, Incomplete] | None = None, + nstart: Mapping[Incomplete, Incomplete] | None = None, weight: str | None = None, ) -> dict[Incomplete, float]: ... @_dispatchable diff --git a/stubs/networkx/networkx/algorithms/centrality/katz.pyi b/stubs/networkx/networkx/algorithms/centrality/katz.pyi index ca867e0d624a..c932be84faba 100644 --- a/stubs/networkx/networkx/algorithms/centrality/katz.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/katz.pyi @@ -1,4 +1,5 @@ from _typeshed import Incomplete, SupportsGetItem +from collections.abc import Iterable from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -12,7 +13,7 @@ def katz_centrality( beta: float | SupportsGetItem[Incomplete, Incomplete] | None = 1.0, max_iter: int | None = 1000, tol: float | None = 1e-06, - nstart: SupportsGetItem[Incomplete, Incomplete] | None = None, + nstart: Iterable[Incomplete] | None = None, normalized: bool | None = True, weight: str | None = None, ) -> dict[Incomplete, Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/centrality/percolation.pyi b/stubs/networkx/networkx/algorithms/centrality/percolation.pyi index cc5faab10f72..becea462a050 100644 --- a/stubs/networkx/networkx/algorithms/centrality/percolation.pyi +++ b/stubs/networkx/networkx/algorithms/centrality/percolation.pyi @@ -1,4 +1,5 @@ -from _typeshed import Incomplete, SupportsGetItem +from _typeshed import Incomplete +from collections.abc import Mapping from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -9,6 +10,6 @@ __all__ = ["percolation_centrality"] def percolation_centrality( G: Graph[_Node], attribute: str | None = "percolation", - states: SupportsGetItem[Incomplete, Incomplete] | None = None, + states: Mapping[Incomplete, Incomplete] | None = None, weight: str | None = None, ) -> dict[Incomplete, float]: ... diff --git a/stubs/networkx/networkx/algorithms/clique.pyi b/stubs/networkx/networkx/algorithms/clique.pyi index fc4203f7f449..2f873a64e301 100644 --- a/stubs/networkx/networkx/algorithms/clique.pyi +++ b/stubs/networkx/networkx/algorithms/clique.pyi @@ -29,11 +29,13 @@ def make_clique_bipartite( G: Graph[_Node], fpos: bool | None = None, create_using: Graph[_Node] | None = None, name=None ) -> Graph[_Node]: ... @overload -def node_clique_number( - G: Graph[_Node], nodes=None, cliques: Iterable[Incomplete] | None = None, separate_nodes=False +def node_clique_number( # type: ignore[overload-overlap] + G: Graph[_Node], nodes: Iterable[_Node] | None = None, cliques: Iterable[Incomplete] | None = None, separate_nodes=False ) -> dict[_Node, int]: ... @overload -def node_clique_number(G: Graph[_Node], nodes=None, cliques: Iterable[Incomplete] | None = None, separate_nodes=False) -> int: ... +def node_clique_number( + G: Graph[_Node], nodes: _Node, cliques: Iterable[Incomplete] | None = None, separate_nodes=False +) -> int: ... def number_of_cliques(G: Graph[_Node], nodes=None, cliques=None) -> int | dict[Incomplete, Incomplete]: ... @_dispatchable def max_weight_clique(G: Graph[_Node], weight="weight") -> tuple[list[Incomplete], int]: ... diff --git a/stubs/networkx/networkx/algorithms/community/kernighan_lin.pyi b/stubs/networkx/networkx/algorithms/community/kernighan_lin.pyi index 00133f83134e..055bdfe89aab 100644 --- a/stubs/networkx/networkx/algorithms/community/kernighan_lin.pyi +++ b/stubs/networkx/networkx/algorithms/community/kernighan_lin.pyi @@ -9,7 +9,7 @@ __all__ = ["kernighan_lin_bisection"] @_dispatchable def kernighan_lin_bisection( G: Graph[_Node], - partition: tuple[Incomplete] | None = None, + partition: tuple[Incomplete, Incomplete] | None = None, max_iter: int = 10, weight: str = "weight", seed: int | RandomState | None = None, diff --git a/stubs/networkx/networkx/algorithms/flow/mincost.pyi b/stubs/networkx/networkx/algorithms/flow/mincost.pyi index 7ca50162d01a..d0e3a94731ce 100644 --- a/stubs/networkx/networkx/algorithms/flow/mincost.pyi +++ b/stubs/networkx/networkx/algorithms/flow/mincost.pyi @@ -12,10 +12,10 @@ def min_cost_flow_cost( @_dispatchable def min_cost_flow( G: Graph[_Node], demand: str = "demand", capacity: str = "capacity", weight: str = "weight" -) -> dict[Incomplete, dict[Incomplete, Incomplete]]: ... +) -> tuple[int | Incomplete, dict[Incomplete, dict[Incomplete, Incomplete]]]: ... @_dispatchable def cost_of_flow(G: Graph[_Node], flowDict: SupportsGetItem[Incomplete, Incomplete], weight: str = "weight") -> int | float: ... @_dispatchable def max_flow_min_cost( G: Graph[_Node], s: str, t: str, capacity: str = "capacity", weight: str = "weight" -) -> dict[Incomplete, dict[Incomplete, Incomplete]]: ... +) -> tuple[int | Incomplete, dict[Incomplete, dict[Incomplete, Incomplete]]]: ... diff --git a/stubs/networkx/networkx/algorithms/isomorphism/ismags.pyi b/stubs/networkx/networkx/algorithms/isomorphism/ismags.pyi index 76b00f5fd01c..6856f2f12da5 100644 --- a/stubs/networkx/networkx/algorithms/isomorphism/ismags.pyi +++ b/stubs/networkx/networkx/algorithms/isomorphism/ismags.pyi @@ -1,6 +1,8 @@ from _typeshed import Incomplete from collections.abc import Generator +from ...classes.graph import Graph, _Node + __all__ = ["ISMAGS"] class ISMAGS: @@ -9,10 +11,10 @@ class ISMAGS: node_equality: Incomplete edge_equality: Incomplete - def __init__(self, graph, subgraph, node_match=None, edge_match=None, cache=None) -> None: ... + def __init__(self, graph: Graph[_Node], subgraph: Graph[_Node], node_match=None, edge_match=None, cache=None) -> None: ... def find_isomorphisms(self, symmetry: bool = True) -> Generator[Incomplete, Incomplete, Incomplete]: ... def largest_common_subgraph(self, symmetry: bool = True) -> Generator[Incomplete, Incomplete, None]: ... - def analyze_symmetry(self, graph, node_partitions, edge_colors): ... + def analyze_symmetry(self, graph: Graph[_Node], node_partitions, edge_colors): ... def is_isomorphic(self, symmetry: bool = False) -> bool: ... def subgraph_is_isomorphic(self, symmetry: bool = False) -> bool: ... def isomorphisms_iter(self, symmetry: bool = True) -> Generator[Incomplete, Incomplete, None]: ... diff --git a/stubs/networkx/networkx/algorithms/isomorphism/isomorphvf2.pyi b/stubs/networkx/networkx/algorithms/isomorphism/isomorphvf2.pyi index 47097ed0c177..ad2493c89af4 100644 --- a/stubs/networkx/networkx/algorithms/isomorphism/isomorphvf2.pyi +++ b/stubs/networkx/networkx/algorithms/isomorphism/isomorphvf2.pyi @@ -1,6 +1,8 @@ from _typeshed import Incomplete from collections.abc import Generator +from ...classes.graph import Graph, _Node + __all__ = ["GraphMatcher", "DiGraphMatcher"] class GraphMatcher: @@ -12,7 +14,7 @@ class GraphMatcher: old_recursion_limit: Incomplete test: str - def __init__(self, G1, G2) -> None: ... + def __init__(self, G1: Graph[_Node], G2: Graph[_Node]) -> None: ... def reset_recursion_limit(self) -> None: ... def candidate_pairs_iter(self) -> Generator[Incomplete, None, None]: ... core_1: Incomplete @@ -34,7 +36,7 @@ class GraphMatcher: def syntactic_feasibility(self, G1_node, G2_node): ... class DiGraphMatcher(GraphMatcher): - def __init__(self, G1, G2) -> None: ... + def __init__(self, G1: Graph[_Node], G2: Graph[_Node]) -> None: ... def candidate_pairs_iter(self) -> Generator[Incomplete, None, None]: ... core_1: Incomplete core_2: Incomplete diff --git a/stubs/networkx/networkx/algorithms/isomorphism/matchhelpers.pyi b/stubs/networkx/networkx/algorithms/isomorphism/matchhelpers.pyi index ce35ad716eda..a3799f4e2a8a 100644 --- a/stubs/networkx/networkx/algorithms/isomorphism/matchhelpers.pyi +++ b/stubs/networkx/networkx/algorithms/isomorphism/matchhelpers.pyi @@ -1,4 +1,5 @@ from _typeshed import Incomplete +from collections.abc import Callable, Iterable from types import FunctionType from networkx.utils.backends import _dispatchable @@ -18,23 +19,23 @@ __all__ = [ def copyfunc(f, name=None) -> FunctionType: ... def allclose(x, y, rtol: float = 1.0000000000000001e-05, atol=1e-08) -> bool: ... @_dispatchable -def categorical_node_match(attr, default): ... - -categorical_edge_match: Incomplete +def categorical_node_match(attr: str | Iterable[str], default): ... +# Same as categorical_node_match, but not dispatchable +def categorical_edge_match(attr: str | Iterable[str], default): ... @_dispatchable -def categorical_multiedge_match(attr, default): ... +def categorical_multiedge_match(attr: str | Iterable[str], default): ... @_dispatchable -def numerical_node_match(attr, default, rtol: float = 1e-05, atol: float = 1e-08): ... - -numerical_edge_match: Incomplete +def numerical_node_match(attr: str | Iterable[str], default, rtol: float = 1e-05, atol: float = 1e-08): ... +# Same as numerical_node_match, but not dispatchable +def numerical_edge_match(attr: str | Iterable[str], default, rtol: float = 1e-05, atol: float = 1e-08): ... @_dispatchable -def numerical_multiedge_match(attr, default, rtol: float = 1e-05, atol: float = 1e-08): ... +def numerical_multiedge_match(attr: str | Iterable[str], default, rtol: float = 1e-05, atol: float = 1e-08): ... @_dispatchable -def generic_node_match(attr, default, op): ... - -generic_edge_match: Incomplete +def generic_node_match(attr: str | Iterable[str], default, op: Callable[[Incomplete, Incomplete], Incomplete]): ... +# Same as generic_node_match, but not dispatchable +def generic_edge_match(attr: str | Iterable[str], default, op: Callable[[Incomplete, Incomplete], Incomplete]): ... @_dispatchable -def generic_multiedge_match(attr, default, op): ... +def generic_multiedge_match(attr: str | Iterable[str], default, op: Callable[[Incomplete, Incomplete], Incomplete]): ... diff --git a/stubs/networkx/networkx/algorithms/isomorphism/temporalisomorphvf2.pyi b/stubs/networkx/networkx/algorithms/isomorphism/temporalisomorphvf2.pyi index 7ab32a2abcb9..b0fea1026625 100644 --- a/stubs/networkx/networkx/algorithms/isomorphism/temporalisomorphvf2.pyi +++ b/stubs/networkx/networkx/algorithms/isomorphism/temporalisomorphvf2.pyi @@ -1,5 +1,6 @@ from _typeshed import Incomplete +from ...classes.graph import Graph, _Node from .isomorphvf2 import DiGraphMatcher, GraphMatcher __all__ = ["TimeRespectingGraphMatcher", "TimeRespectingDiGraphMatcher"] @@ -8,7 +9,7 @@ class TimeRespectingGraphMatcher(GraphMatcher): temporal_attribute_name: Incomplete delta: Incomplete - def __init__(self, G1, G2, temporal_attribute_name, delta) -> None: ... + def __init__(self, G1: Graph[_Node], G2: Graph[_Node], temporal_attribute_name, delta) -> None: ... def one_hop(self, Gx, Gx_node, neighbors): ... def two_hop(self, Gx, core_x, Gx_node, neighbors): ... def semantic_feasibility(self, G1_node, G2_node): ... @@ -17,7 +18,7 @@ class TimeRespectingDiGraphMatcher(DiGraphMatcher): temporal_attribute_name: Incomplete delta: Incomplete - def __init__(self, G1, G2, temporal_attribute_name, delta) -> None: ... + def __init__(self, G1: Graph[_Node], G2: Graph[_Node], temporal_attribute_name, delta) -> None: ... def get_pred_dates(self, Gx, Gx_node, core_x, pred): ... def get_succ_dates(self, Gx, Gx_node, core_x, succ): ... def one_hop(self, Gx, Gx_node, core_x, pred, succ): ... diff --git a/stubs/networkx/networkx/algorithms/isomorphism/vf2userfunc.pyi b/stubs/networkx/networkx/algorithms/isomorphism/vf2userfunc.pyi index 475020aa5b05..b522d21c09ed 100644 --- a/stubs/networkx/networkx/algorithms/isomorphism/vf2userfunc.pyi +++ b/stubs/networkx/networkx/algorithms/isomorphism/vf2userfunc.pyi @@ -1,5 +1,7 @@ from _typeshed import Incomplete +from collections.abc import Callable +from ...classes.graph import Graph, _Node from . import isomorphvf2 as vf2 __all__ = ["GraphMatcher", "DiGraphMatcher", "MultiGraphMatcher", "MultiDiGraphMatcher"] @@ -10,8 +12,14 @@ class GraphMatcher(vf2.GraphMatcher): G1_adj: Incomplete G2_adj: Incomplete - def __init__(self, G1, G2, node_match=None, edge_match=None) -> None: ... - semantic_feasibility: Incomplete + def __init__( + self, + G1: Graph[_Node], + G2: Graph[_Node], + node_match: Callable[..., Incomplete] | None = None, + edge_match: Callable[..., Incomplete] | None = None, + ) -> None: ... + def semantic_feasibility(self, G1_node, G2_node): ... class DiGraphMatcher(vf2.DiGraphMatcher): node_match: Incomplete @@ -19,7 +27,13 @@ class DiGraphMatcher(vf2.DiGraphMatcher): G1_adj: Incomplete G2_adj: Incomplete - def __init__(self, G1, G2, node_match=None, edge_match=None) -> None: ... + def __init__( + self, + G1: Graph[_Node], + G2: Graph[_Node], + node_match: Callable[..., Incomplete] | None = None, + edge_match: Callable[..., Incomplete] | None = None, + ) -> None: ... def semantic_feasibility(self, G1_node, G2_node): ... class MultiGraphMatcher(GraphMatcher): ... diff --git a/stubs/networkx/networkx/algorithms/planarity.pyi b/stubs/networkx/networkx/algorithms/planarity.pyi index 0cfc0a36135f..e5bd62eb0cd8 100644 --- a/stubs/networkx/networkx/algorithms/planarity.pyi +++ b/stubs/networkx/networkx/algorithms/planarity.pyi @@ -72,7 +72,7 @@ class LRPlanarity: lowpt_edge: Incomplete left_ref: Incomplete right_ref: Incomplete - embedding: Incomplete + embedding: PlanarEmbedding[Incomplete] def __init__(self, G: Graph[_Node]) -> None: ... def lr_planarity(self) -> PlanarEmbedding[Incomplete] | None: ... diff --git a/stubs/networkx/networkx/algorithms/tournament.pyi b/stubs/networkx/networkx/algorithms/tournament.pyi index 0fff43290acb..6ca969c6922a 100644 --- a/stubs/networkx/networkx/algorithms/tournament.pyi +++ b/stubs/networkx/networkx/algorithms/tournament.pyi @@ -15,6 +15,7 @@ __all__ = [ "tournament_matrix", ] +def index_satisfying(iterable, condition): ... @_dispatchable def is_tournament(G: Graph[_Node]) -> bool: ... @_dispatchable diff --git a/stubs/networkx/networkx/algorithms/tree/branchings.pyi b/stubs/networkx/networkx/algorithms/tree/branchings.pyi index 16cfa6a6eeaf..ef31f768b3cb 100644 --- a/stubs/networkx/networkx/algorithms/tree/branchings.pyi +++ b/stubs/networkx/networkx/algorithms/tree/branchings.pyi @@ -63,7 +63,13 @@ class ArborescenceIterator: partition_key: str init_partition: Incomplete - def __init__(self, G: DiGraph[_Node], weight: str = "weight", minimum: bool = True, init_partition=None) -> None: ... + def __init__( + self, + G: DiGraph[_Node], + weight: str = "weight", + minimum: bool = True, + init_partition: tuple[Incomplete, Incomplete] | None = None, + ) -> None: ... partition_queue: Incomplete def __iter__(self) -> Self: ... diff --git a/stubs/networkx/networkx/algorithms/tree/coding.pyi b/stubs/networkx/networkx/algorithms/tree/coding.pyi index 1559965dcded..78b31e7e8238 100644 --- a/stubs/networkx/networkx/algorithms/tree/coding.pyi +++ b/stubs/networkx/networkx/algorithms/tree/coding.pyi @@ -1,5 +1,5 @@ from _typeshed import Incomplete -from collections.abc import Iterable +from collections.abc import Collection from networkx.classes.graph import Graph, _Node from networkx.exception import NetworkXException @@ -12,8 +12,8 @@ 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: Collection[Incomplete], sensible_relabeling: bool = False): ... @_dispatchable def to_prufer_sequence(T: Graph[_Node]) -> list[Incomplete]: ... @_dispatchable -def from_prufer_sequence(sequence: Iterable[Incomplete]): ... +def from_prufer_sequence(sequence: Collection[Incomplete]): ... diff --git a/stubs/networkx/networkx/algorithms/tree/decomposition.pyi b/stubs/networkx/networkx/algorithms/tree/decomposition.pyi index f50ed7b684fc..6499fcea35a4 100644 --- a/stubs/networkx/networkx/algorithms/tree/decomposition.pyi +++ b/stubs/networkx/networkx/algorithms/tree/decomposition.pyi @@ -1,9 +1,7 @@ -from _typeshed import Incomplete - from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable __all__ = ["junction_tree"] @_dispatchable -def junction_tree(G: Graph[_Node]) -> Graph[Incomplete]: ... +def junction_tree(G: Graph[_Node]) -> Graph[_Node]: ... diff --git a/stubs/networkx/networkx/algorithms/voronoi.pyi b/stubs/networkx/networkx/algorithms/voronoi.pyi index 63f890bf2591..1abe370f2087 100644 --- a/stubs/networkx/networkx/algorithms/voronoi.pyi +++ b/stubs/networkx/networkx/algorithms/voronoi.pyi @@ -1,5 +1,5 @@ from _typeshed import Incomplete, SupportsGetItem -from collections.abc import Callable +from collections.abc import Callable, Collection from typing import Any from networkx.classes.graph import Graph, _Node @@ -10,6 +10,6 @@ __all__ = ["voronoi_cells"] @_dispatchable def voronoi_cells( G: Graph[_Node], - center_nodes: set[Incomplete], + center_nodes: Collection[Incomplete], weight: str | Callable[[Any, Any, SupportsGetItem[str, Any]], float | None] | None = "weight", ) -> dict[Incomplete, set[Incomplete]]: ... diff --git a/stubs/networkx/networkx/classes/function.pyi b/stubs/networkx/networkx/classes/function.pyi index 2cca12ee26df..5c7d384fc16e 100644 --- a/stubs/networkx/networkx/classes/function.pyi +++ b/stubs/networkx/networkx/classes/function.pyi @@ -67,14 +67,14 @@ def is_directed(G: DiGraph[Hashable]) -> Literal[True]: ... # type: ignore[misc @overload def is_directed(G: Graph[Hashable]) -> Literal[False]: ... def freeze(G: Graph[_Node]): ... -def is_frozen(G: Graph[Incomplete]) -> bool: ... +def is_frozen(G: Graph[_Node]) -> bool: ... def add_star(G_to_add_to, nodes_for_star, **attr) -> None: ... def add_path(G_to_add_to, nodes_for_path, **attr) -> None: ... def add_cycle(G_to_add_to, nodes_for_cycle, **attr) -> None: ... -def subgraph(G: Graph[_Node], nbunch): ... +def subgraph(G: Graph[_Node], nbunch: _NBunch[_Node]): ... def induced_subgraph(G: Graph[_Node], nbunch: _NBunch[_Node]) -> Graph[_Node]: ... -def edge_subgraph(G: Graph[_Node], edges): ... -def restricted_view(G: Graph[_Node], nodes, edges): ... +def edge_subgraph(G: Graph[_Node], edges: Iterable[Incomplete]): ... +def restricted_view(G: Graph[_Node], nodes: Iterable[Incomplete], edges: Iterable[Incomplete]): ... def to_directed(graph): ... def to_undirected(graph): ... def create_empty_copy(G: Graph[_Node], with_data: bool = True): ... @@ -170,4 +170,4 @@ def selfloop_edges( @_dispatchable def number_of_selfloops(G: Graph[Hashable]) -> int: ... def is_path(G: Graph[_Node], path: Iterable[Incomplete]) -> bool: ... -def path_weight(G: Graph[_Node], path, weight) -> int: ... +def path_weight(G: Graph[_Node], path: Iterable[Incomplete], weight: str) -> int: ... diff --git a/stubs/networkx/networkx/classes/reportviews.pyi b/stubs/networkx/networkx/classes/reportviews.pyi index b141f395feac..366a938f28ab 100644 --- a/stubs/networkx/networkx/classes/reportviews.pyi +++ b/stubs/networkx/networkx/classes/reportviews.pyi @@ -222,7 +222,11 @@ class OutMultiEdgeView(OutEdgeView[_Node]): __slots__ = () def __iter__(self) -> Iterator[tuple[_Node, _Node, Incomplete]]: ... # type: ignore[override] def __getitem__(self, e: tuple[_Node, _Node, Incomplete]) -> dict[str, Any]: ... # type: ignore[override] - dataview = OutMultiEdgeDataView + dataview: type[ # Including subtypes' possible return types for LSP + OutMultiEdgeDataView[Incomplete, Incomplete] + | MultiEdgeDataView[Incomplete, Incomplete] + | InMultiEdgeDataView[Incomplete, Incomplete] + ] @overload # type: ignore[override] # Has an additional `keys` keyword argument def __call__( # type: ignore[overload-overlap] self, nbunch: None = None, data: Literal[False] = False, *, default: Unused = None, keys: Literal[True] diff --git a/stubs/networkx/networkx/convert.pyi b/stubs/networkx/networkx/convert.pyi index 0f25eabffa87..1c17923afb50 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, Collection, Iterable +from collections.abc import Callable, Collection, Iterable, Mapping from networkx.classes.graph import Graph, _Data, _Node from networkx.utils.backends import _dispatchable @@ -25,7 +25,9 @@ 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]: ... +def from_dict_of_dicts( + d: Mapping[Incomplete, Mapping[Incomplete, Incomplete]], create_using=None, multigraph_input=False +) -> Graph[Incomplete]: ... @_dispatchable def to_edgelist(G: Graph[_Node], nodelist: Collection[_Node] | None = None): ... @_dispatchable diff --git a/stubs/networkx/networkx/convert_matrix.pyi b/stubs/networkx/networkx/convert_matrix.pyi index 53a0f816c4f5..b96869b1a6ba 100644 --- a/stubs/networkx/networkx/convert_matrix.pyi +++ b/stubs/networkx/networkx/convert_matrix.pyi @@ -80,9 +80,11 @@ def from_pandas_edgelist( edge_key: str | None = None, ) -> Graph[Incomplete]: ... @_dispatchable -def to_scipy_sparse_array(G: Graph[_Node], nodelist=None, dtype=None, weight="weight", format="csr"): ... +def to_scipy_sparse_array( + G: Graph[_Node], nodelist: Collection[_Node] | None = None, dtype=None, weight="weight", format="csr" +): ... @_dispatchable -def from_scipy_sparse_array(A, parallel_edges=False, create_using=None, edge_attribute="weight"): ... +def from_scipy_sparse_array(A, parallel_edges: bool = False, create_using=None, edge_attribute: str = "weight"): ... @_dispatchable def to_numpy_array( G: Graph[_Node], diff --git a/stubs/networkx/networkx/generators/atlas.pyi b/stubs/networkx/networkx/generators/atlas.pyi index 7b89477ab253..a17a5a5b24d8 100644 --- a/stubs/networkx/networkx/generators/atlas.pyi +++ b/stubs/networkx/networkx/generators/atlas.pyi @@ -17,6 +17,6 @@ NUM_GRAPHS: Final = 1253 ATLAS_FILE: Final[Traversable] @_dispatchable -def graph_atlas(i) -> Graph[Incomplete]: ... +def graph_atlas(i: int) -> Graph[Incomplete]: ... @_dispatchable def graph_atlas_g() -> list[Graph[Incomplete]]: ... diff --git a/stubs/networkx/networkx/generators/classic.pyi b/stubs/networkx/networkx/generators/classic.pyi index 5c46ad3a2add..d279d826f28f 100644 --- a/stubs/networkx/networkx/generators/classic.pyi +++ b/stubs/networkx/networkx/generators/classic.pyi @@ -1,6 +1,7 @@ from _typeshed import Incomplete +from collections.abc import Iterable -from networkx.classes import Graph +from networkx.classes.graph import Graph from networkx.utils.backends import _dispatchable __all__ = [ @@ -28,15 +29,15 @@ __all__ = [ ] @_dispatchable -def full_rary_tree(r, n, create_using=None): ... +def full_rary_tree(r: int, n: int, create_using=None): ... @_dispatchable def kneser_graph(n, k) -> Graph[Incomplete]: ... @_dispatchable -def balanced_tree(r, h, create_using=None): ... +def balanced_tree(r: int, h: int, create_using=None): ... @_dispatchable def barbell_graph(m1, m2, create_using=None): ... @_dispatchable -def binomial_tree(n, create_using=None): ... +def binomial_tree(n: int, create_using=None): ... @_dispatchable def complete_graph(n, create_using=None): ... @_dispatchable @@ -48,7 +49,7 @@ def cycle_graph(n, create_using=None): ... @_dispatchable def dorogovtsev_goltsev_mendes_graph(n, create_using=None): ... @_dispatchable -def empty_graph(n: Incomplete | int = 0, create_using=None, default=...): ... +def empty_graph(n: int | Iterable[Incomplete] = 0, create_using=None, default=...): ... @_dispatchable def ladder_graph(n, create_using=None): ... @_dispatchable @@ -56,16 +57,16 @@ def lollipop_graph(m, n, create_using=None): ... @_dispatchable def null_graph(create_using=None): ... @_dispatchable -def path_graph(n, create_using=None): ... +def path_graph(n: int | Iterable[Incomplete], create_using=None): ... @_dispatchable -def star_graph(n, create_using=None): ... +def star_graph(n: int | Iterable[Incomplete], create_using=None): ... @_dispatchable def tadpole_graph(m, n, create_using=None) -> Graph[Incomplete] | Incomplete: ... @_dispatchable def trivial_graph(create_using=None): ... @_dispatchable -def turan_graph(n, r): ... +def turan_graph(n: int, r: int): ... @_dispatchable -def wheel_graph(n, create_using=None): ... +def wheel_graph(n: int | Iterable[Incomplete], create_using=None): ... @_dispatchable def complete_multipartite_graph(*subset_sizes): ... diff --git a/stubs/networkx/networkx/generators/cographs.pyi b/stubs/networkx/networkx/generators/cographs.pyi index ba2edca7a2b6..d7af20579015 100644 --- a/stubs/networkx/networkx/generators/cographs.pyi +++ b/stubs/networkx/networkx/generators/cographs.pyi @@ -3,4 +3,4 @@ from networkx.utils.backends import _dispatchable __all__ = ["random_cograph"] @_dispatchable -def random_cograph(n, seed=None): ... +def random_cograph(n: int, seed=None): ... diff --git a/stubs/networkx/networkx/generators/community.pyi b/stubs/networkx/networkx/generators/community.pyi index 706b03dbd544..b67751821cf4 100644 --- a/stubs/networkx/networkx/generators/community.pyi +++ b/stubs/networkx/networkx/generators/community.pyi @@ -17,24 +17,24 @@ __all__ = [ ] @_dispatchable -def caveman_graph(l, k): ... +def caveman_graph(l: int, k: int): ... @_dispatchable -def connected_caveman_graph(l, k): ... +def connected_caveman_graph(l: int, k: int): ... @_dispatchable -def relaxed_caveman_graph(l, k, p, seed=None): ... +def relaxed_caveman_graph(l: int, k: int, p: float, seed=None): ... @_dispatchable -def random_partition_graph(sizes, p_in, p_out, seed=None, directed: bool = False): ... +def random_partition_graph(sizes: Collection[int], p_in: float, p_out: float, seed=None, directed: bool = False): ... @_dispatchable -def planted_partition_graph(l, k, p_in, p_out, seed=None, directed: bool = False): ... +def planted_partition_graph(l: int, k: int, p_in: float, p_out: float, seed=None, directed: bool = False): ... @_dispatchable -def gaussian_random_partition_graph(n, s, v, p_in, p_out, directed: bool = False, seed=None): ... +def gaussian_random_partition_graph(n: int, s: float, v: float, p_in: float, p_out: float, directed: bool = False, seed=None): ... @_dispatchable -def ring_of_cliques(num_cliques, clique_size): ... +def ring_of_cliques(num_cliques: int, clique_size: int): ... @_dispatchable -def windmill_graph(n, k): ... +def windmill_graph(n: int, k: int): ... @_dispatchable def stochastic_block_model( - sizes, + sizes: Collection[int], p, nodelist: Collection[Incomplete] | None = None, seed=None, @@ -44,16 +44,16 @@ def stochastic_block_model( ): ... @_dispatchable def LFR_benchmark_graph( - n, - tau1, - tau2, - mu, - average_degree=None, - min_degree=None, - max_degree=None, - min_community=None, - max_community=None, - tol: float = 1e-07, + n: int, + tau1: float, + tau2: float, + mu: float, + average_degree: float | None = None, + min_degree: int | None = None, + max_degree: int | None = None, + min_community: int | None = None, + max_community: int | None = None, + tol: float = 1.0e-7, max_iters: int = 500, seed=None, ): ... diff --git a/stubs/networkx/networkx/generators/degree_seq.pyi b/stubs/networkx/networkx/generators/degree_seq.pyi index 0378d273caaf..8f6a87e86af2 100644 --- a/stubs/networkx/networkx/generators/degree_seq.pyi +++ b/stubs/networkx/networkx/generators/degree_seq.pyi @@ -1,4 +1,5 @@ from _typeshed import Incomplete +from collections.abc import Collection from networkx.utils.backends import _dispatchable @@ -24,7 +25,7 @@ def directed_configuration_model( in_degree_sequence, out_degree_sequence, create_using=None, seed=None ) -> MultiDiGraph[Incomplete]: ... @_dispatchable -def expected_degree_graph(w, seed=None, selfloops: bool = True) -> Graph[Incomplete]: ... +def expected_degree_graph(w: Collection[float], seed=None, selfloops: bool = True) -> Graph[Incomplete]: ... @_dispatchable def havel_hakimi_graph(deg_sequence, create_using=None): ... @_dispatchable diff --git a/stubs/networkx/networkx/generators/directed.pyi b/stubs/networkx/networkx/generators/directed.pyi index dbddbecf23c0..2705f3889841 100644 --- a/stubs/networkx/networkx/generators/directed.pyi +++ b/stubs/networkx/networkx/generators/directed.pyi @@ -7,11 +7,11 @@ from ..classes import MultiDiGraph __all__ = ["gn_graph", "gnc_graph", "gnr_graph", "random_k_out_graph", "scale_free_graph"] @_dispatchable -def gn_graph(n, kernel=None, create_using=None, seed=None): ... +def gn_graph(n: int, kernel=None, create_using=None, seed=None): ... @_dispatchable -def gnr_graph(n, p, create_using=None, seed=None): ... +def gnr_graph(n: int, p: float, create_using=None, seed=None): ... @_dispatchable -def gnc_graph(n, create_using=None, seed=None): ... +def gnc_graph(n: int, create_using=None, seed=None): ... @_dispatchable def scale_free_graph( n, @@ -27,4 +27,4 @@ def scale_free_graph( @_dispatchable def random_uniform_k_out_graph(n: int, k: int, self_loops: bool = True, with_replacement: bool = True, seed=None): ... @_dispatchable -def random_k_out_graph(n, k, alpha, self_loops: bool = True, seed=None) -> MultiDiGraph[Incomplete]: ... +def random_k_out_graph(n: int, k: int, alpha: float, self_loops: bool = True, seed=None) -> MultiDiGraph[Incomplete]: ... diff --git a/stubs/networkx/networkx/generators/duplication.pyi b/stubs/networkx/networkx/generators/duplication.pyi index 387f761bea60..0212e9c3b060 100644 --- a/stubs/networkx/networkx/generators/duplication.pyi +++ b/stubs/networkx/networkx/generators/duplication.pyi @@ -7,6 +7,6 @@ from ..classes.graph import Graph __all__ = ["partial_duplication_graph", "duplication_divergence_graph"] @_dispatchable -def partial_duplication_graph(N, n, p, q, seed=None): ... +def partial_duplication_graph(N: int, n: int, p: float, q: float, seed=None): ... @_dispatchable -def duplication_divergence_graph(n, p, seed=None) -> Graph[Incomplete]: ... +def duplication_divergence_graph(n: int, p: float, seed=None) -> Graph[Incomplete]: ... diff --git a/stubs/networkx/networkx/generators/expanders.pyi b/stubs/networkx/networkx/generators/expanders.pyi index 5786272dced3..78b26f3a0132 100644 --- a/stubs/networkx/networkx/generators/expanders.pyi +++ b/stubs/networkx/networkx/generators/expanders.pyi @@ -11,7 +11,7 @@ __all__ = [ ] @_dispatchable -def margulis_gabber_galil_graph(n, create_using=None): ... +def margulis_gabber_galil_graph(n: int, create_using=None): ... @_dispatchable def chordal_cycle_graph(p, create_using=None): ... @_dispatchable diff --git a/stubs/networkx/networkx/generators/geometric.pyi b/stubs/networkx/networkx/generators/geometric.pyi index fcc25a9fd93e..5e1238bef16b 100644 --- a/stubs/networkx/networkx/generators/geometric.pyi +++ b/stubs/networkx/networkx/generators/geometric.pyi @@ -1,4 +1,5 @@ from _typeshed import Incomplete +from collections.abc import Iterable, Mapping from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -15,23 +16,62 @@ __all__ = [ ] @_dispatchable -def geometric_edges(G: Graph[_Node], radius, p: float = 2): ... +def geometric_edges(G: Graph[_Node], radius: float, p: float = 2): ... @_dispatchable -def random_geometric_graph(n, radius, dim: int = 2, pos=None, p: float = 2, seed=None): ... +def random_geometric_graph( + n: int | Iterable[Incomplete], + radius: float, + dim: int = 2, + pos: Mapping[Incomplete, Incomplete] | None = None, + p: float = 2, + seed=None, +): ... @_dispatchable -def soft_random_geometric_graph(n, radius, dim: int = 2, pos=None, p: float = 2, p_dist=None, seed=None): ... +def soft_random_geometric_graph( + n: int | Iterable[Incomplete], + radius: float, + dim: int = 2, + pos: Mapping[Incomplete, Incomplete] | None = None, + p: float = 2, + p_dist=None, + seed=None, +): ... @_dispatchable -def geographical_threshold_graph(n, theta, dim: int = 2, pos=None, weight=None, metric=None, p_dist=None, seed=None): ... +def geographical_threshold_graph( + n: int | Iterable[Incomplete], + theta, + dim: int = 2, + pos: Mapping[Incomplete, Incomplete] | None = None, + weight: Mapping[Incomplete, Incomplete] | None = None, + metric=None, + p_dist=None, + seed=None, +): ... @_dispatchable def waxman_graph( - n, beta: float = 0.4, alpha: float = 0.1, L=None, domain=(0, 0, 1, 1), metric=None, seed=None + n: int | Iterable[Incomplete], + beta: float = 0.4, + alpha: float = 0.1, + L: float | None = None, + domain=(0, 0, 1, 1), + metric=None, + seed=None, ) -> Graph[Incomplete]: ... # docstring marks p as int, but it still works with floats. So I think it's better for consistency @_dispatchable -def navigable_small_world_graph(n, p: float = 1, q: int = 1, r: float = 2, dim: int = 2, seed=None): ... +def navigable_small_world_graph(n: int, p: float = 1, q: int = 1, r: float = 2, dim: int = 2, seed=None): ... @_dispatchable -def thresholded_random_geometric_graph(n, radius, theta, dim: int = 2, pos=None, weight=None, p: float = 2, seed=None): ... +def thresholded_random_geometric_graph( + n: int | Iterable[Incomplete], + radius: float, + theta: float, + dim: int = 2, + pos: Mapping[Incomplete, Incomplete] | None = None, + weight: Mapping[Incomplete, Incomplete] | None = None, + p: float = 2, + seed=None, +): ... @_dispatchable def geometric_soft_configuration_graph( *, beta, n=None, gamma=None, mean_degree=None, kappas=None, seed=None diff --git a/stubs/networkx/networkx/generators/internet_as_graphs.pyi b/stubs/networkx/networkx/generators/internet_as_graphs.pyi index 05932bf9e32d..74b8753d6c1c 100644 --- a/stubs/networkx/networkx/generators/internet_as_graphs.pyi +++ b/stubs/networkx/networkx/generators/internet_as_graphs.pyi @@ -30,9 +30,9 @@ class AS_graph_generator: def choose_peer_pref_attach(self, node_list): ... def choose_node_pref_attach(self, node_list): ... def add_customer(self, i, j) -> None: ... - def add_node(self, i, kind, reg2prob, avg_deg, t_edge_prob): ... - def add_m_peering_link(self, m, to_kind) -> bool: ... - def add_cp_peering_link(self, cp, to_kind) -> bool: ... + def add_node(self, i, kind: str, reg2prob: float, avg_deg: float, t_edge_prob: float): ... + def add_m_peering_link(self, m, to_kind: str) -> bool: ... + def add_cp_peering_link(self, cp, to_kind: str) -> bool: ... regions: Incomplete def graph_regions(self, rn) -> None: ... def add_peering_links(self, from_kind, to_kind) -> None: ... diff --git a/stubs/networkx/networkx/generators/intersection.pyi b/stubs/networkx/networkx/generators/intersection.pyi index 271deaec7bc4..5897e64e1608 100644 --- a/stubs/networkx/networkx/generators/intersection.pyi +++ b/stubs/networkx/networkx/generators/intersection.pyi @@ -3,8 +3,8 @@ from networkx.utils.backends import _dispatchable __all__ = ["uniform_random_intersection_graph", "k_random_intersection_graph", "general_random_intersection_graph"] @_dispatchable -def uniform_random_intersection_graph(n, m, p, seed=None): ... +def uniform_random_intersection_graph(n: int, m: int, p: float, seed=None): ... @_dispatchable -def k_random_intersection_graph(n, m, k, seed=None): ... +def k_random_intersection_graph(n: int, m: int, k: float, seed=None): ... @_dispatchable -def general_random_intersection_graph(n, m, p, seed=None): ... +def general_random_intersection_graph(n: int, m: int, p, seed=None): ... diff --git a/stubs/networkx/networkx/generators/lattice.pyi b/stubs/networkx/networkx/generators/lattice.pyi index e82eb72ae6da..0e326fed87db 100644 --- a/stubs/networkx/networkx/generators/lattice.pyi +++ b/stubs/networkx/networkx/generators/lattice.pyi @@ -1,14 +1,16 @@ +from collections.abc import Iterable + from networkx.utils.backends import _dispatchable __all__ = ["grid_2d_graph", "grid_graph", "hypercube_graph", "triangular_lattice_graph", "hexagonal_lattice_graph"] @_dispatchable -def grid_2d_graph(m, n, periodic: bool = False, create_using=None): ... +def grid_2d_graph(m, n, periodic: bool | tuple[bool, bool] = False, create_using=None): ... @_dispatchable -def grid_graph(dim, periodic: bool = False): ... +def grid_graph(dim, periodic: bool | Iterable[bool] = False): ... @_dispatchable def hypercube_graph(n): ... @_dispatchable -def triangular_lattice_graph(m, n, periodic: bool = False, with_positions: bool = True, create_using=None): ... +def triangular_lattice_graph(m: int, n: int, periodic: bool = False, with_positions: bool = True, create_using=None): ... @_dispatchable -def hexagonal_lattice_graph(m, n, periodic: bool = False, with_positions: bool = True, create_using=None): ... +def hexagonal_lattice_graph(m: int, n: int, periodic: bool = False, with_positions: bool = True, create_using=None): ... diff --git a/stubs/networkx/networkx/generators/mycielski.pyi b/stubs/networkx/networkx/generators/mycielski.pyi index 24b24f026bd8..0bdab5b426ba 100644 --- a/stubs/networkx/networkx/generators/mycielski.pyi +++ b/stubs/networkx/networkx/generators/mycielski.pyi @@ -6,4 +6,4 @@ __all__ = ["mycielskian", "mycielski_graph"] @_dispatchable def mycielskian(G: Graph[_Node], iterations: int = 1): ... @_dispatchable -def mycielski_graph(n): ... +def mycielski_graph(n: int): ... diff --git a/stubs/networkx/networkx/generators/nonisomorphic_trees.pyi b/stubs/networkx/networkx/generators/nonisomorphic_trees.pyi index 281382b32d23..e53d3487f20c 100644 --- a/stubs/networkx/networkx/generators/nonisomorphic_trees.pyi +++ b/stubs/networkx/networkx/generators/nonisomorphic_trees.pyi @@ -6,6 +6,6 @@ from networkx.utils.backends import _dispatchable __all__ = ["nonisomorphic_trees", "number_of_nonisomorphic_trees"] @_dispatchable -def nonisomorphic_trees(order) -> Generator[list[Incomplete]]: ... +def nonisomorphic_trees(order: int) -> Generator[list[Incomplete]]: ... @_dispatchable -def number_of_nonisomorphic_trees(order): ... +def number_of_nonisomorphic_trees(order: int): ... diff --git a/stubs/networkx/networkx/generators/random_graphs.pyi b/stubs/networkx/networkx/generators/random_graphs.pyi index 10a3b070fead..ecdfb226941a 100644 --- a/stubs/networkx/networkx/generators/random_graphs.pyi +++ b/stubs/networkx/networkx/generators/random_graphs.pyi @@ -2,7 +2,7 @@ from _typeshed import Incomplete from networkx.utils.backends import _dispatchable -from ..classes.graph import Graph +from ..classes.graph import Graph, _Node __all__ = [ "fast_gnp_random_graph", @@ -27,40 +27,42 @@ __all__ = [ ] @_dispatchable -def fast_gnp_random_graph(n, p, seed=None, directed: bool = False): ... +def fast_gnp_random_graph(n: int, p: float, seed=None, directed: bool = False): ... @_dispatchable -def gnp_random_graph(n, p, seed=None, directed: bool = False): ... +def gnp_random_graph(n: int, p: float, seed=None, directed: bool = False): ... binomial_graph = gnp_random_graph erdos_renyi_graph = gnp_random_graph @_dispatchable -def dense_gnm_random_graph(n, m, seed=None): ... +def dense_gnm_random_graph(n: int, m: int, seed=None): ... @_dispatchable -def gnm_random_graph(n, m, seed=None, directed: bool = False): ... +def gnm_random_graph(n: int, m: int, seed=None, directed: bool = False): ... @_dispatchable -def newman_watts_strogatz_graph(n, k, p, seed=None): ... +def newman_watts_strogatz_graph(n: int, k: int, p: float, seed=None): ... @_dispatchable -def watts_strogatz_graph(n, k, p, seed=None): ... +def watts_strogatz_graph(n: int, k: int, p: float, seed=None): ... @_dispatchable -def connected_watts_strogatz_graph(n, k, p, tries: int = 100, seed=None): ... +def connected_watts_strogatz_graph(n: int, k: int, p: float, tries: int = 100, seed=None): ... @_dispatchable -def random_regular_graph(d, n, seed=None): ... +def random_regular_graph(d, n: int, seed=None): ... @_dispatchable -def barabasi_albert_graph(n, m, seed=None, initial_graph=None) -> Graph[Incomplete]: ... +def barabasi_albert_graph(n: int, m: int, seed=None, initial_graph: Graph[_Node] | None = None) -> Graph[_Node]: ... @_dispatchable -def dual_barabasi_albert_graph(n, m1, m2, p, seed=None, initial_graph=None) -> Graph[Incomplete]: ... +def dual_barabasi_albert_graph( + n: int, m1, m2, p: float, seed=None, initial_graph: Graph[_Node] | None = None +) -> Graph[_Node]: ... @_dispatchable -def extended_barabasi_albert_graph(n, m, p, q, seed=None) -> Graph[Incomplete]: ... +def extended_barabasi_albert_graph(n: int, m: int, p: float, q, seed=None) -> Graph[Incomplete]: ... @_dispatchable -def powerlaw_cluster_graph(n, m, p, seed=None): ... +def powerlaw_cluster_graph(n: int, m: int, p: float, seed=None): ... @_dispatchable -def random_lobster(n, p1, p2, seed=None): ... +def random_lobster(n: int, p1: float, p2: float, seed=None): ... @_dispatchable def random_shell_graph(constructor, seed=None): ... @_dispatchable -def random_powerlaw_tree(n, gamma: float = 3, seed=None, tries: int = 100): ... +def random_powerlaw_tree(n: int, gamma: float = 3, seed=None, tries: int = 100): ... @_dispatchable -def random_powerlaw_tree_sequence(n, gamma: float = 3, seed=None, tries: int = 100): ... +def random_powerlaw_tree_sequence(n: int, gamma: float = 3, seed=None, tries: int = 100): ... @_dispatchable -def random_kernel_graph(n, kernel_integral, kernel_root=None, seed=None): ... +def random_kernel_graph(n: int, kernel_integral, kernel_root=None, seed=None): ... diff --git a/stubs/networkx/networkx/generators/spectral_graph_forge.pyi b/stubs/networkx/networkx/generators/spectral_graph_forge.pyi index 7321e2ab7e21..f8034781b925 100644 --- a/stubs/networkx/networkx/generators/spectral_graph_forge.pyi +++ b/stubs/networkx/networkx/generators/spectral_graph_forge.pyi @@ -1,9 +1,7 @@ -from _typeshed import Incomplete - from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable __all__ = ["spectral_graph_forge"] @_dispatchable -def spectral_graph_forge(G: Graph[_Node], alpha, transformation: str = "identity", seed=None) -> Graph[Incomplete]: ... +def spectral_graph_forge(G: Graph[_Node], alpha: float, transformation: str = "identity", seed=None) -> Graph[_Node]: ... diff --git a/stubs/networkx/networkx/generators/triads.pyi b/stubs/networkx/networkx/generators/triads.pyi index 4e85d0677afa..66fb47f93757 100644 --- a/stubs/networkx/networkx/generators/triads.pyi +++ b/stubs/networkx/networkx/generators/triads.pyi @@ -9,4 +9,4 @@ __all__ = ["triad_graph"] TRIAD_EDGES: Final[dict[str, list[str]]] @_dispatchable -def triad_graph(triad_name) -> DiGraph[Incomplete]: ... +def triad_graph(triad_name: str) -> DiGraph[Incomplete]: ... diff --git a/stubs/networkx/networkx/lazy_imports.pyi b/stubs/networkx/networkx/lazy_imports.pyi index c5bc64e495c0..c6d82cb4b897 100644 --- a/stubs/networkx/networkx/lazy_imports.pyi +++ b/stubs/networkx/networkx/lazy_imports.pyi @@ -1,8 +1,10 @@ import types +from _typeshed import Incomplete +from collections.abc import Mapping __all__ = ["attach", "_lazy_import"] -def attach(module_name, submodules=None, submod_attrs=None): ... +def attach(module_name: str, submodules: set[str] | None = None, submod_attrs: Mapping[str, Incomplete] | None = None): ... class DelayedImportErrorModule(types.ModuleType): def __init__(self, frame_data, *args, **kwargs) -> None: ... diff --git a/stubs/networkx/networkx/linalg/attrmatrix.pyi b/stubs/networkx/networkx/linalg/attrmatrix.pyi index 90b19c231e4d..a717a6239c0a 100644 --- a/stubs/networkx/networkx/linalg/attrmatrix.pyi +++ b/stubs/networkx/networkx/linalg/attrmatrix.pyi @@ -1,5 +1,5 @@ from _typeshed import Incomplete -from collections.abc import Collection +from collections.abc import Callable, Collection from typing import Any, Literal from networkx._typing import Array2D @@ -13,8 +13,10 @@ __all__ = ["attr_matrix", "attr_sparse_matrix"] @_dispatchable def attr_matrix( G: Graph[_Node], - edge_attr: str | None = None, - node_attr: str | None = None, # runtime also accepts `Callable[[_Node], object]`, but it is not documented + edge_attr: str | Callable[[Incomplete, Incomplete], Incomplete] | None = None, + node_attr: ( + str | Callable[[Incomplete], Incomplete] | None + ) = None, # runtime also accepts `Callable[[_Node], object]`, but it is not documented normalized: bool = False, # runtime also accepts `Callable[[_Node, _Node], object]`, but it is not documented rc_order: Collection[_Node] | None = None, dtype: DTypeLike | None = None, @@ -28,8 +30,10 @@ def attr_matrix( @_dispatchable def attr_sparse_matrix( G: Graph[_Node], - edge_attr: str | None = None, - node_attr: str | None = None, # runtime also accepts `Callable[[_Node], object]`, but it is not documented + edge_attr: str | Callable[[Incomplete, Incomplete], Incomplete] | None = None, + node_attr: ( + str | Callable[[Incomplete], Incomplete] | None + ) = None, # runtime also accepts `Callable[[_Node], object]`, but it is not documented normalized: bool = False, # runtime also accepts `Callable[[_Node, _Node], object]`, but it is not documented rc_order: Collection[_Node] | None = None, dtype: DTypeLike | None = None, diff --git a/stubs/networkx/networkx/readwrite/adjlist.pyi b/stubs/networkx/networkx/readwrite/adjlist.pyi index a4f2c6188186..9fd6feee2119 100644 --- a/stubs/networkx/networkx/readwrite/adjlist.pyi +++ b/stubs/networkx/networkx/readwrite/adjlist.pyi @@ -8,6 +8,8 @@ __all__ = ["generate_adjlist", "write_adjlist", "parse_adjlist", "read_adjlist"] def generate_adjlist(G: Graph[_Node], delimiter: str = " ") -> Generator[str, None, None]: ... def write_adjlist(G: Graph[_Node], path, comments: str = "#", delimiter: str = " ", encoding: str = "utf-8") -> None: ... @_dispatchable -def parse_adjlist(lines, comments: str = "#", delimiter=None, create_using=None, nodetype=None): ... +def parse_adjlist(lines, comments: str = "#", delimiter: str | None = None, create_using=None, nodetype=None): ... @_dispatchable -def read_adjlist(path, comments: str = "#", delimiter=None, create_using=None, nodetype=None, encoding: str = "utf-8"): ... +def read_adjlist( + path, comments: str = "#", delimiter: str | None = None, create_using=None, nodetype=None, encoding: str = "utf-8" +): ... diff --git a/stubs/networkx/networkx/readwrite/edgelist.pyi b/stubs/networkx/networkx/readwrite/edgelist.pyi index 1ae09b2b4f49..9124d8cb67e0 100644 --- a/stubs/networkx/networkx/readwrite/edgelist.pyi +++ b/stubs/networkx/networkx/readwrite/edgelist.pyi @@ -13,20 +13,24 @@ __all__ = [ "write_weighted_edgelist", ] -def generate_edgelist(G: Graph[_Node], delimiter: str = " ", data: bool = True) -> Generator[Incomplete, None, None]: ... +def generate_edgelist( + G: Graph[_Node], delimiter: str = " ", data: bool | Incomplete = True +) -> Generator[Incomplete, None, None]: ... def write_edgelist( - G: Graph[_Node], path, comments: str = "#", delimiter: str = " ", data: bool = True, encoding: str = "utf-8" + G: Graph[_Node], path, comments: str = "#", delimiter: str = " ", data: bool | Incomplete = True, encoding: str = "utf-8" ) -> None: ... @_dispatchable -def parse_edgelist(lines, comments: str = "#", delimiter=None, create_using=None, nodetype=None, data: bool = True): ... +def parse_edgelist( + lines, comments: str = "#", delimiter: str | None = None, create_using=None, nodetype=None, data: bool | Incomplete = True +): ... @_dispatchable def read_edgelist( path, comments: str = "#", - delimiter=None, + delimiter: str | None = None, create_using=None, nodetype=None, - data: bool = True, + data: bool | Incomplete = True, edgetype=None, encoding: str = "utf-8", ): ... @@ -35,5 +39,5 @@ def write_weighted_edgelist( ) -> None: ... @_dispatchable def read_weighted_edgelist( - path, comments: str = "#", delimiter=None, create_using=None, nodetype=None, encoding: str = "utf-8" + path, comments: str = "#", delimiter: str | None = None, create_using=None, nodetype=None, encoding: str = "utf-8" ): ... diff --git a/stubs/networkx/networkx/readwrite/gexf.pyi b/stubs/networkx/networkx/readwrite/gexf.pyi index 32825bfa608b..8a23f501a545 100644 --- a/stubs/networkx/networkx/readwrite/gexf.pyi +++ b/stubs/networkx/networkx/readwrite/gexf.pyi @@ -15,7 +15,7 @@ def generate_gexf( def read_gexf(path, node_type=None, relabel: bool = False, version: str = "1.2draft"): ... class GEXF: - versions: Incomplete + versions: dict[str, dict[str, str]] xml_type: Incomplete python_type: Incomplete def construct_types(self) -> None: ... diff --git a/stubs/networkx/networkx/readwrite/gml.pyi b/stubs/networkx/networkx/readwrite/gml.pyi index ca73eb3cd4a2..0a3a37886f3f 100644 --- a/stubs/networkx/networkx/readwrite/gml.pyi +++ b/stubs/networkx/networkx/readwrite/gml.pyi @@ -1,5 +1,5 @@ from _typeshed import Incomplete -from collections.abc import Generator +from collections.abc import Callable, Generator, Iterable from enum import Enum from typing import Final, Generic, NamedTuple, TypeVar @@ -14,9 +14,11 @@ def escape(text): ... def unescape(text): ... def literal_destringizer(rep: str): ... @_dispatchable -def read_gml(path, label: str = "label", destringizer=None): ... +def read_gml(path, label: str = "label", destringizer: Callable[[Incomplete], Incomplete] | None = None): ... @_dispatchable -def parse_gml(lines, label: str = "label", destringizer=None): ... +def parse_gml( + lines: str | Iterable[str], label: str = "label", destringizer: Callable[[Incomplete], Incomplete] | None = None +): ... class Pattern(Enum): KEYS = 0 @@ -37,5 +39,7 @@ LIST_START_VALUE: Final = "_networkx_list_start" def parse_gml_lines(lines, label, destringizer): ... def literal_stringizer(value) -> str: ... -def generate_gml(G: Graph[_Node], stringizer=None) -> Generator[Incomplete, Incomplete, None]: ... -def write_gml(G: Graph[_Node], path, stringizer=None) -> None: ... +def generate_gml( + G: Graph[_Node], stringizer: Callable[[Incomplete], str] | None = None +) -> Generator[Incomplete, Incomplete, None]: ... +def write_gml(G: Graph[_Node], path, stringizer: Callable[[Incomplete], str] | None = None) -> None: ... diff --git a/stubs/networkx/networkx/readwrite/graph6.pyi b/stubs/networkx/networkx/readwrite/graph6.pyi index 31445344352e..fc0db6e969aa 100644 --- a/stubs/networkx/networkx/readwrite/graph6.pyi +++ b/stubs/networkx/networkx/readwrite/graph6.pyi @@ -8,10 +8,10 @@ __all__ = ["from_graph6_bytes", "read_graph6", "to_graph6_bytes", "write_graph6" @_dispatchable def from_graph6_bytes(bytes_in) -> Graph[Incomplete]: ... -def to_graph6_bytes(G: Graph[_Node], nodes=None, header: bool = True): ... +def to_graph6_bytes(G: Graph[_Node], nodes: Iterable[Incomplete] | None = None, header: bool = True): ... @_dispatchable def read_graph6(path): ... -def write_graph6(G: Graph[_Node], path, nodes=None, header: bool = True): ... +def write_graph6(G: Graph[_Node], path, nodes: Iterable[Incomplete] | None = None, header: bool = True): ... def write_graph6_file(G: Graph[_Node], f, nodes: Iterable[Incomplete] | None = None, header: bool = True): ... def data_to_n(data): ... def n_to_data(n): ... diff --git a/stubs/networkx/networkx/readwrite/graphml.pyi b/stubs/networkx/networkx/readwrite/graphml.pyi index ffe71779ae6f..a936d98e090e 100644 --- a/stubs/networkx/networkx/readwrite/graphml.pyi +++ b/stubs/networkx/networkx/readwrite/graphml.pyi @@ -40,7 +40,7 @@ def generate_graphml( @_dispatchable def read_graphml(path, node_type=..., edge_key_type=..., force_multigraph: bool = False): ... @_dispatchable -def parse_graphml(graphml_string, node_type=..., edge_key_type=..., force_multigraph: bool = False): ... +def parse_graphml(graphml_string: str, node_type=..., edge_key_type=..., force_multigraph: bool = False): ... class GraphML: NS_GRAPHML: Final[str] diff --git a/stubs/networkx/networkx/readwrite/json_graph/adjacency.pyi b/stubs/networkx/networkx/readwrite/json_graph/adjacency.pyi index 0fb7df4efe64..3def7a4088f7 100644 --- a/stubs/networkx/networkx/readwrite/json_graph/adjacency.pyi +++ b/stubs/networkx/networkx/readwrite/json_graph/adjacency.pyi @@ -1,3 +1,5 @@ +from _typeshed import Incomplete +from collections.abc import Mapping from typing import Any from networkx.classes.graph import Graph, _Node @@ -6,6 +8,8 @@ from networkx.utils.backends import _dispatchable __all__ = ["adjacency_data", "adjacency_graph"] # Any: Complex type union -def adjacency_data(G: Graph[_Node], attrs={"id": "id", "key": "key"}) -> dict[str, Any]: ... +def adjacency_data(G: Graph[_Node], attrs: Mapping[str, Incomplete] = {"id": "id", "key": "key"}) -> dict[str, Any]: ... @_dispatchable -def adjacency_graph(data, directed: bool = False, multigraph: bool = True, attrs={"id": "id", "key": "key"}): ... +def adjacency_graph( + data, directed: bool = False, multigraph: bool = True, attrs: Mapping[str, Incomplete] = {"id": "id", "key": "key"} +): ... diff --git a/stubs/networkx/networkx/readwrite/json_graph/cytoscape.pyi b/stubs/networkx/networkx/readwrite/json_graph/cytoscape.pyi index 7fb98fa14ca8..f15d510ea33a 100644 --- a/stubs/networkx/networkx/readwrite/json_graph/cytoscape.pyi +++ b/stubs/networkx/networkx/readwrite/json_graph/cytoscape.pyi @@ -1,3 +1,5 @@ +from _typeshed import Incomplete +from collections.abc import Mapping from typing import Any from networkx.classes.graph import Graph, _Node @@ -8,4 +10,4 @@ __all__ = ["cytoscape_data", "cytoscape_graph"] # Any: Complex type union def cytoscape_data(G: Graph[_Node], name: str = "name", ident: str = "id") -> dict[str, Any]: ... @_dispatchable -def cytoscape_graph(data, name: str = "name", ident: str = "id"): ... +def cytoscape_graph(data: Mapping[str, Incomplete], name: str = "name", ident: str = "id"): ... diff --git a/stubs/networkx/networkx/readwrite/json_graph/node_link.pyi b/stubs/networkx/networkx/readwrite/json_graph/node_link.pyi index 19cd0e1ca5dc..1c2aecfecfd8 100644 --- a/stubs/networkx/networkx/readwrite/json_graph/node_link.pyi +++ b/stubs/networkx/networkx/readwrite/json_graph/node_link.pyi @@ -1,3 +1,5 @@ +from _typeshed import Incomplete +from collections.abc import Mapping from typing import overload from typing_extensions import deprecated @@ -36,10 +38,9 @@ def node_link_data( ): ... @_dispatchable def node_link_graph( - data, + data: Mapping[str, Incomplete], directed: bool = False, multigraph: bool = True, - attrs=None, *, source: str = "source", target: str = "target", diff --git a/stubs/networkx/networkx/readwrite/json_graph/tree.pyi b/stubs/networkx/networkx/readwrite/json_graph/tree.pyi index 8b389c5bf242..b28287f69e20 100644 --- a/stubs/networkx/networkx/readwrite/json_graph/tree.pyi +++ b/stubs/networkx/networkx/readwrite/json_graph/tree.pyi @@ -1,3 +1,6 @@ +from _typeshed import Incomplete +from collections.abc import Mapping + from networkx.classes.digraph import DiGraph from networkx.classes.graph import _Node from networkx.utils.backends import _dispatchable @@ -6,4 +9,4 @@ __all__ = ["tree_data", "tree_graph"] def tree_data(G: DiGraph[_Node], root, ident: str = "id", children: str = "children"): ... @_dispatchable -def tree_graph(data, ident: str = "id", children: str = "children"): ... +def tree_graph(data: Mapping[str, Incomplete], ident: str = "id", children: str = "children"): ... diff --git a/stubs/networkx/networkx/readwrite/leda.pyi b/stubs/networkx/networkx/readwrite/leda.pyi index 733005d1ce64..5df28f467ebc 100644 --- a/stubs/networkx/networkx/readwrite/leda.pyi +++ b/stubs/networkx/networkx/readwrite/leda.pyi @@ -1,3 +1,5 @@ +from collections.abc import Iterable + from networkx.utils.backends import _dispatchable __all__ = ["read_leda", "parse_leda"] @@ -5,4 +7,4 @@ __all__ = ["read_leda", "parse_leda"] @_dispatchable def read_leda(path, encoding: str = "UTF-8"): ... @_dispatchable -def parse_leda(lines): ... +def parse_leda(lines: str | Iterable[str]): ... diff --git a/stubs/networkx/networkx/readwrite/multiline_adjlist.pyi b/stubs/networkx/networkx/readwrite/multiline_adjlist.pyi index ba5e0ad89858..4b1a04f6a262 100644 --- a/stubs/networkx/networkx/readwrite/multiline_adjlist.pyi +++ b/stubs/networkx/networkx/readwrite/multiline_adjlist.pyi @@ -6,10 +6,20 @@ from networkx.utils.backends import _dispatchable __all__ = ["generate_multiline_adjlist", "write_multiline_adjlist", "parse_multiline_adjlist", "read_multiline_adjlist"] def generate_multiline_adjlist(G: Graph[_Node], delimiter: str = " ") -> Generator[str, None, None]: ... -def write_multiline_adjlist(G: Graph[_Node], path, delimiter=" ", comments="#", encoding="utf-8") -> None: ... +def write_multiline_adjlist( + G: Graph[_Node], path, delimiter: str = " ", comments: str = "#", encoding: str = "utf-8" +) -> None: ... @_dispatchable -def parse_multiline_adjlist(lines, comments: str = "#", delimiter=None, create_using=None, nodetype=None, edgetype=None): ... +def parse_multiline_adjlist( + lines, comments: str = "#", delimiter: str | None = None, create_using=None, nodetype=None, edgetype=None +): ... @_dispatchable def read_multiline_adjlist( - path, comments: str = "#", delimiter=None, create_using=None, nodetype=None, edgetype=None, encoding: str = "utf-8" + path, + comments: str = "#", + delimiter: str | None = None, + create_using=None, + nodetype=None, + edgetype=None, + encoding: str = "utf-8", ): ... diff --git a/stubs/networkx/networkx/readwrite/pajek.pyi b/stubs/networkx/networkx/readwrite/pajek.pyi index f51b8cd6815a..a42ddaffd01b 100644 --- a/stubs/networkx/networkx/readwrite/pajek.pyi +++ b/stubs/networkx/networkx/readwrite/pajek.pyi @@ -1,5 +1,5 @@ from _typeshed import Incomplete -from collections.abc import Generator +from collections.abc import Generator, Iterable from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -11,5 +11,5 @@ def write_pajek(G: Graph[_Node], path, encoding: str = "UTF-8") -> None: ... @_dispatchable def read_pajek(path, encoding: str = "UTF-8"): ... @_dispatchable -def parse_pajek(lines): ... +def parse_pajek(lines: str | Iterable[str]): ... def make_qstr(t): ... diff --git a/stubs/networkx/networkx/readwrite/sparse6.pyi b/stubs/networkx/networkx/readwrite/sparse6.pyi index 68ba4718d743..0b26c6fc7b31 100644 --- a/stubs/networkx/networkx/readwrite/sparse6.pyi +++ b/stubs/networkx/networkx/readwrite/sparse6.pyi @@ -1,4 +1,5 @@ from _typeshed import Incomplete +from collections.abc import Iterable from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -6,8 +7,8 @@ from networkx.utils.backends import _dispatchable __all__ = ["from_sparse6_bytes", "read_sparse6", "to_sparse6_bytes", "write_sparse6"] @_dispatchable -def from_sparse6_bytes(string) -> Graph[Incomplete]: ... -def to_sparse6_bytes(G: Graph[_Node], nodes=None, header: bool = True): ... +def from_sparse6_bytes(string: str) -> Graph[Incomplete]: ... +def to_sparse6_bytes(G: Graph[_Node], nodes: Iterable[Incomplete] | None = None, header: bool = True): ... @_dispatchable def read_sparse6(path): ... def write_sparse6(G: Graph[_Node], path, nodes=None, header: bool = True) -> None: ... diff --git a/stubs/networkx/networkx/utils/decorators.pyi b/stubs/networkx/networkx/utils/decorators.pyi index c12cc5421171..f4ace0642ba8 100644 --- a/stubs/networkx/networkx/utils/decorators.pyi +++ b/stubs/networkx/networkx/utils/decorators.pyi @@ -1,22 +1,25 @@ from _typeshed import Incomplete from collections.abc import Callable +from pathlib import Path from typing import NamedTuple +from .misc import _RandomState + __all__ = ["not_implemented_for", "open_file", "nodes_or_number", "np_random_state", "py_random_state", "argmap"] def not_implemented_for(*graph_types): ... -def open_file(path_arg, mode: str = "r"): ... +def open_file(path_arg: str | Path | Incomplete, mode: str = "r"): ... def nodes_or_number(which_args): ... -def np_random_state(random_state_argument): ... -def py_random_state(random_state_argument): ... +def np_random_state(random_state_argument: _RandomState): ... +def py_random_state(random_state_argument: _RandomState): ... class argmap: - def __init__(self, func, *args, try_finally: bool = False) -> None: ... - def __call__(self, f) -> Callable[..., Incomplete]: ... - def compile(self, f) -> Callable[..., Incomplete]: ... - def assemble(self, f): ... + def __init__(self, func: Callable[..., Incomplete], *args, try_finally: bool = False) -> None: ... + def __call__(self, f: Callable[..., Incomplete]) -> Callable[..., Incomplete]: ... + def compile(self, f: Callable[..., Incomplete]) -> Callable[..., Incomplete]: ... + def assemble(self, f: Callable[..., Incomplete]): ... @classmethod - def signature(cls, f): ... + def signature(cls, f: Callable[..., Incomplete]): ... class Signature(NamedTuple): name: Incomplete diff --git a/stubs/networkx/networkx/utils/random_sequence.pyi b/stubs/networkx/networkx/utils/random_sequence.pyi index e2985019248d..6055c02e6a3f 100644 --- a/stubs/networkx/networkx/utils/random_sequence.pyi +++ b/stubs/networkx/networkx/utils/random_sequence.pyi @@ -8,7 +8,7 @@ __all__ = [ ] def powerlaw_sequence(n, exponent: float = 2.0, seed=None): ... -def zipf_rv(alpha, xmin: int = 1, seed=None) -> int: ... +def zipf_rv(alpha: float, xmin: int = 1, seed=None) -> int: ... def cumulative_distribution(distribution): ... def discrete_sequence(n, distribution=None, cdistribution=None, seed=None): ... def random_weighted_sample(mapping, k, seed=None): ...