Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
eb2b783
Merged networkx stubs from python-type-stubs
Avasam May 13, 2025
67402d1
Replace `: Incomplete | None = None` with `=None`
Avasam May 13, 2025
2037be3
Fix failing tests
Avasam May 13, 2025
16f2a66
Support `requires_python` in `runtests.py`
Avasam May 13, 2025
1dad75f
Support `requires_python` in `runtests.py`
Avasam May 13, 2025
1f6be6e
Merge branch 'main' of https://github.com/python/typeshed into networ…
Avasam May 13, 2025
d487295
Merge branch 'main' of https://github.com/python/typeshed into networ…
Avasam May 14, 2025
72cf2c9
Discard changes to stubs/networkx/networkx/drawing/nx_agraph.pyi
Avasam May 14, 2025
e17709f
Update stubs/networkx/networkx/classes/multidigraph.pyi
Avasam May 14, 2025
47f5f7c
Update stubs/networkx/networkx/classes/digraph.pyi
Avasam May 14, 2025
73dbdbf
Remove accidental extra symbols
Avasam May 16, 2025
8aa5a56
Merge branch 'main' of https://github.com/python/typeshed into networ…
Avasam May 16, 2025
a092752
Replace `Graph[Incomplete]` with `Graph[_Node]`
Avasam May 22, 2025
8ab7313
Merge branch 'main' of https://github.com/python/typeshed into networ…
Avasam May 22, 2025
071e34d
Merge branch 'main' of https://github.com/python/typeshed into networ…
Avasam May 26, 2025
f52e0ce
Merge branch 'main' of https://github.com/python/typeshed into networ…
Avasam Jul 25, 2025
6409a80
Pass tests
Avasam Jul 25, 2025
39f5442
Merge branch 'main' into networkx-merge-from-python-type-stubs
Avasam Aug 5, 2025
33f6249
Discard changes to stubs/networkx/networkx/classes/digraph.pyi
Avasam Aug 20, 2025
cba33cc
Discard changes to stubs/networkx/networkx/classes/graph.pyi
Avasam Aug 20, 2025
fc0104b
Discard changes to stubs/networkx/networkx/classes/multidigraph.pyi
Avasam Aug 20, 2025
764a6d2
Discard changes to stubs/networkx/networkx/classes/multigraph.pyi
Avasam Aug 20, 2025
2ba94b7
Update stubs/networkx/networkx/classes/reportviews.pyi
Avasam Aug 20, 2025
f43c212
Merge branch 'main' of https://github.com/python/typeshed into networ…
Avasam Aug 20, 2025
5bcdc2c
Update stubs/networkx/networkx/algorithms/approximation/traveling_sal…
Avasam Aug 20, 2025
53989c5
Merge branch 'main' of https://github.com/python/typeshed into networ…
Avasam Aug 20, 2025
7c89025
Merge branch 'main' into networkx-merge-from-python-type-stubs
Avasam Sep 26, 2025
26c884f
Merge branch 'main' of https://github.com/python/typeshed into networ…
Avasam Oct 3, 2025
c83ac31
Merge branch 'main' into networkx-merge-from-python-type-stubs
Avasam Nov 3, 2025
3729186
Merge branch 'main' of https://github.com/python/typeshed into networ…
Avasam Dec 20, 2025
213708e
Post-merge fixes
Avasam Dec 20, 2025
19365f2
Merge branch 'main' of https://github.com/python/typeshed into networ…
Avasam Nov 3, 2026
5b969a0
Post-merge fixes
Avasam Nov 3, 2026
0315a11
Address some self-reviews
Avasam Nov 3, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion stubs/networkx/networkx/algorithms/approximation/maxcut.pyi
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -12,5 +13,8 @@ def randomized_partitioning(
) -> tuple[float, tuple[set[Incomplete], set[Incomplete]]]: ...
@_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,
) -> tuple[float, tuple[set[Incomplete], set[Incomplete]]]: ...
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...
24 changes: 14 additions & 10 deletions stubs/networkx/networkx/algorithms/bipartite/edgelist.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from _typeshed import Incomplete, StrPath, SupportsRead, SupportsWrite
from collections.abc import Collection, Generator, Iterable
from collections.abc import Callable, Collection, Generator, Iterable

from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
Expand All @@ -12,28 +12,32 @@ def write_edgelist(
path: StrPath | SupportsWrite[bytes],
comments: str = "#",
delimiter: str = " ",
data: bool = True,
data: bool | Collection[Incomplete] = True, # Not Iterable: iterated more than once, one-shot iterables give wrong results
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 | Collection[Incomplete] = True, # Not Iterable: iterated more than once, one-shot iterables give wrong results
) -> Generator[str]: ...
@_dispatchable
def parse_edgelist(
lines: Iterable[str],
comments: str | None = "#",
comments: str = "#",
delimiter: str | None = None,
create_using: Graph[_Node] | type[Graph[_Node]] | None = None,
nodetype: type[Incomplete] | None = None,
data: bool | Collection[tuple[str, type[Incomplete]]] = True,
nodetype: Callable[[str], Incomplete] | None = None,
data: bool | Collection[tuple[str, Callable[[str], Incomplete]]] = True,
) -> Graph[Incomplete]: ...
@_dispatchable
def read_edgelist(
path: StrPath | SupportsRead[bytes],
comments: str | None = "#",
comments: str = "#",
delimiter: str | None = None,
create_using: Graph[Incomplete] | type[Graph[Incomplete]] | None = None,
nodetype=None,
data: bool | Collection[tuple[str, type[Incomplete]]] = True,
nodetype: Callable[[str], Incomplete] | None = None,
data: bool | Collection[tuple[str, Callable[[str], Incomplete]]] = True,
edgetype=None,
encoding: str | None = "utf-8",
encoding: str = "utf-8",
) -> Graph[Incomplete]: ...
15 changes: 7 additions & 8 deletions stubs/networkx/networkx/algorithms/bipartite/generators.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from _typeshed import Incomplete
from collections.abc import Iterable
from collections.abc import Sequence

from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
Expand All @@ -20,26 +19,26 @@ __all__ = [
def complete_bipartite_graph(n1, n2, create_using: Graph[_Node] | type[Graph[_Node]] | None = None): ...
@_dispatchable
def configuration_model(
aseq: Iterable[Incomplete],
bseq: Iterable[Incomplete],
aseq: Sequence[int],
bseq: Sequence[int],
create_using: Graph[_Node] | type[Graph[_Node]] | None = None,
seed: int | RandomState | None = None,
): ...
@_dispatchable
def havel_hakimi_graph(
aseq: Iterable[Incomplete], bseq: Iterable[Incomplete], create_using: Graph[_Node] | type[Graph[_Node]] | None = None
aseq: Sequence[int], bseq: Sequence[int], create_using: Graph[_Node] | type[Graph[_Node]] | None = None
): ...
@_dispatchable
def reverse_havel_hakimi_graph(
aseq: Iterable[Incomplete], bseq: Iterable[Incomplete], create_using: Graph[_Node] | type[Graph[_Node]] | None = None
aseq: Sequence[int], bseq: Sequence[int], create_using: Graph[_Node] | type[Graph[_Node]] | None = None
): ...
@_dispatchable
def alternating_havel_hakimi_graph(
aseq: Iterable[Incomplete], bseq: Iterable[Incomplete], create_using: Graph[_Node] | type[Graph[_Node]] | None = None
aseq: Sequence[int], bseq: Sequence[int], create_using: Graph[_Node] | type[Graph[_Node]] | None = None
): ...
@_dispatchable
def preferential_attachment_graph(
aseq: Iterable[Incomplete],
aseq: Sequence[int],
p: float,
create_using: Graph[_Node] | type[Graph[_Node]] | None = None,
seed: int | RandomState | None = None,
Expand Down
10 changes: 5 additions & 5 deletions stubs/networkx/networkx/algorithms/bipartite/matrix.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from _typeshed import Incomplete
from collections.abc import Iterable
from collections.abc import Collection

import numpy as np
from networkx.classes.graph import Graph, _Node
Expand All @@ -10,8 +10,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: np.dtype[Incomplete] | None = None,
weight: str | None = "weight",
format: str = "csr",
Expand All @@ -22,6 +22,6 @@ def from_biadjacency_matrix(
create_using: Graph[_Node] | type[Graph[_Node]] | None = None,
edge_attribute: str = "weight",
*,
row_order: Iterable[Incomplete] | None = None,
column_order: Iterable[Incomplete] | None = None,
row_order: Collection[Incomplete] | None = None,
column_order: Collection[Incomplete] | None = None,
) -> Graph[Incomplete]: ...
24 changes: 18 additions & 6 deletions stubs/networkx/networkx/algorithms/bipartite/projection.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from _typeshed import Incomplete
from collections.abc import Callable, Iterable
from collections.abc import Callable, Collection

from networkx.classes.graph import Graph, _Node
from networkx.utils.backends import _dispatchable
Expand All @@ -13,14 +13,26 @@ __all__ = [
]

@_dispatchable
def projected_graph(B: Graph[_Node], nodes: Iterable[Incomplete], multigraph: bool = False) -> Graph[Incomplete]: ...
def projected_graph(
B: Graph[_Node],
nodes: Collection[Incomplete], # Not Iterable: iterated more than once, one-shot iterables give wrong results
multigraph: bool = False,
) -> Graph[Incomplete]: ...
@_dispatchable
def weighted_projected_graph(B: Graph[_Node], nodes: Iterable[Incomplete], ratio: bool = False) -> Graph[Incomplete]: ...
def weighted_projected_graph(B: Graph[_Node], nodes: Collection[Incomplete], ratio: bool = False) -> Graph[Incomplete]: ...
@_dispatchable
def collaboration_weighted_projected_graph(B: Graph[_Node], nodes: Iterable[Incomplete]) -> Graph[Incomplete]: ...
def collaboration_weighted_projected_graph(
B: Graph[_Node], nodes: Collection[Incomplete] # Not Iterable: iterated more than once, one-shot iterables give wrong results
) -> Graph[Incomplete]: ...
@_dispatchable
def overlap_weighted_projected_graph(B: Graph[_Node], nodes: Iterable[Incomplete], jaccard: bool = True) -> Graph[Incomplete]: ...
def overlap_weighted_projected_graph(
B: Graph[_Node],
nodes: Collection[Incomplete], # Not Iterable: iterated more than once, one-shot iterables give wrong results
jaccard: bool = True,
) -> Graph[Incomplete]: ...
@_dispatchable
def generic_weighted_projected_graph(
B: Graph[_Node], nodes: Iterable[Incomplete], weight_function: Callable[..., Incomplete] | None = None
B: Graph[_Node],
nodes: Collection[Incomplete], # Not Iterable: iterated more than once, one-shot iterables give wrong results
weight_function: Callable[..., Incomplete] | None = None,
) -> Graph[Incomplete]: ...
22 changes: 11 additions & 11 deletions stubs/networkx/networkx/algorithms/boundary.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def edge_boundary(
G: Graph[_Node],
nbunch1: Iterable[Incomplete],
nbunch2: Iterable[Incomplete] | None = None,
data=False,
data: bool | str = False,
keys: bool = False,
default=None,
) -> Generator[tuple[_Node, _Node]]: ...
Expand All @@ -22,7 +22,7 @@ def edge_boundary(
G: Graph[_Node],
nbunch1: Iterable[Incomplete],
nbunch2: Iterable[Incomplete] | None = None,
data=False,
data: bool | str = False,
keys: bool = False,
default=None,
) -> Generator[tuple[_Node, _Node, dict[str, Incomplete]]]: ...
Expand All @@ -31,7 +31,7 @@ def edge_boundary(
G: Graph[_Node],
nbunch1: Iterable[Incomplete],
nbunch2: Iterable[Incomplete] | None = None,
data=False,
data: bool | str = False,
keys: bool = False,
default=None,
) -> Generator[tuple[_Node, _Node, dict[str, Incomplete]]]: ...
Expand All @@ -40,7 +40,7 @@ def edge_boundary(
G: Graph[_Node],
nbunch1: Iterable[Incomplete],
nbunch2: Iterable[Incomplete] | None = None,
data=False,
data: bool | str = False,
keys: bool = False,
default: _U | None = None,
) -> Generator[tuple[_Node, _Node, dict[str, _U]]]: ...
Expand All @@ -49,7 +49,7 @@ def edge_boundary(
G: Graph[_Node],
nbunch1: Iterable[Incomplete],
nbunch2: Iterable[Incomplete] | None = None,
data=False,
data: bool | str = False,
keys: bool = False,
default: _U | None = None,
) -> Generator[tuple[_Node, _Node, dict[str, _U]]]: ...
Expand All @@ -58,7 +58,7 @@ def edge_boundary(
G: Graph[_Node],
nbunch1: Iterable[Incomplete],
nbunch2: Iterable[Incomplete] | None = None,
data=False,
data: bool | str = False,
keys: bool = False,
default=None,
) -> Generator[tuple[_Node, _Node, int]]: ...
Expand All @@ -67,7 +67,7 @@ def edge_boundary(
G: Graph[_Node],
nbunch1: Iterable[Incomplete],
nbunch2: Iterable[Incomplete] | None = None,
data=False,
data: bool | str = False,
keys: bool = False,
default=None,
) -> Generator[tuple[_Node, _Node, int]]: ...
Expand All @@ -76,7 +76,7 @@ def edge_boundary(
G: Graph[_Node],
nbunch1: Iterable[Incomplete],
nbunch2: Iterable[Incomplete] | None = None,
data=False,
data: bool | str = False,
keys: bool = False,
default=None,
) -> Generator[tuple[_Node, _Node, int, dict[str, Incomplete]]]: ...
Expand All @@ -85,7 +85,7 @@ def edge_boundary(
G: Graph[_Node],
nbunch1: Iterable[Incomplete],
nbunch2: Iterable[Incomplete] | None = None,
data=False,
data: bool | str = False,
keys: bool = False,
default=None,
) -> Generator[tuple[_Node, _Node, int, dict[str, Incomplete]]]: ...
Expand All @@ -94,7 +94,7 @@ def edge_boundary(
G: Graph[_Node],
nbunch1: Iterable[Incomplete],
nbunch2: Iterable[Incomplete] | None = None,
data=False,
data: bool | str = False,
keys: bool = False,
default: _U | None = None,
) -> Generator[tuple[_Node, _Node, int, dict[str, _U]]]: ...
Expand All @@ -103,7 +103,7 @@ def edge_boundary(
G: Graph[_Node],
nbunch1: Iterable[Incomplete],
nbunch2: Iterable[Incomplete] | None = None,
data=False,
data: bool | str = False,
keys: bool = False,
default: _U | None = None,
) -> Generator[tuple[_Node, _Node, int, dict[str, _U]]]: ...
Expand Down
8 changes: 5 additions & 3 deletions stubs/networkx/networkx/algorithms/clique.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ def make_clique_bipartite(
) -> 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: list[_Node] | _Node | None = None, cliques: Iterable[Incomplete] | None = None
Expand Down
12 changes: 11 additions & 1 deletion stubs/networkx/networkx/algorithms/isomorphism/ismags.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ from _typeshed import Incomplete
from collections.abc import Callable, Generator, Hashable, Iterable
from typing import Any

from ...classes.graph import Graph

__all__ = ["ISMAGS"]

def are_all_equal(iterable: Iterable[Any]) -> bool: ...
Expand All @@ -21,7 +23,15 @@ class ISMAGS:
graph: Incomplete
subgraph: Incomplete

def __init__(self, graph, subgraph, node_match=None, edge_match=None, cache=None) -> None: ...
def __init__(
self,
# Any: graph and subgraph can have unrelated node and data types
graph: Graph[Any, Any, Any],
subgraph: Graph[Any, Any, Any],
node_match=None,
edge_match=None,
cache=None,
) -> None: ...
def create_aligned_partitions(self, thing_matcher, sg_things, g_things): ...
def find_isomorphisms(self, symmetry: bool = True) -> Generator[Incomplete, Incomplete, Incomplete]: ...
def largest_common_subgraph(self, symmetry: bool = True) -> Generator[Incomplete, Incomplete]: ...
Expand Down
18 changes: 16 additions & 2 deletions stubs/networkx/networkx/algorithms/isomorphism/isomorphvf2.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
from _typeshed import Incomplete
from collections.abc import Generator
from typing import Any

from ...classes.digraph import DiGraph
from ...classes.graph import Graph

__all__ = ["GraphMatcher", "DiGraphMatcher"]

Expand All @@ -12,7 +16,12 @@ class GraphMatcher:
old_recursion_limit: Incomplete
test: str

def __init__(self, G1, G2) -> None: ...
def __init__(
self,
# Any: G1 and G2 can have unrelated node and data types
G1: Graph[Any, Any, Any],
G2: Graph[Any, Any, Any],
) -> None: ...
def reset_recursion_limit(self) -> None: ...
def candidate_pairs_iter(self) -> Generator[Incomplete]: ...
core_1: Incomplete
Expand All @@ -34,7 +43,12 @@ class GraphMatcher:
def syntactic_feasibility(self, G1_node, G2_node): ...

class DiGraphMatcher(GraphMatcher):
def __init__(self, G1, G2) -> None: ...
def __init__(
self,
# Any: G1 and G2 can have unrelated node and data types
G1: DiGraph[Any, Any, Any],
G2: DiGraph[Any, Any, Any],
) -> None: ...
def candidate_pairs_iter(self) -> Generator[Incomplete]: ...
core_1: Incomplete
core_2: Incomplete
Expand Down
Loading
Loading