From 9d59d6a856a7452c971cd70b900e6a7439a007dd Mon Sep 17 00:00:00 2001 From: Ian Henderson Date: Fri, 6 Nov 2026 18:34:27 -0800 Subject: [PATCH] [networkx] use Graph[_Node] for Incomplete graph-returning stubs --- stubs/networkx/networkx/algorithms/core.pyi | 12 +++++------- .../networkx/networkx/algorithms/operators/unary.pyi | 3 +-- stubs/networkx/networkx/algorithms/tree/mst.pyi | 8 ++++---- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/stubs/networkx/networkx/algorithms/core.pyi b/stubs/networkx/networkx/algorithms/core.pyi index f32aade116df..fbdcdad44ce5 100644 --- a/stubs/networkx/networkx/algorithms/core.pyi +++ b/stubs/networkx/networkx/algorithms/core.pyi @@ -9,20 +9,18 @@ __all__ = ["core_number", "k_core", "k_shell", "k_crust", "k_corona", "k_truss", @_dispatchable def core_number(G: Graph[_Node]) -> dict[Incomplete, Incomplete]: ... @_dispatchable -def k_core( - G: Graph[_Node], k: int | None = None, core_number: Mapping[Incomplete, Incomplete] | None = None -) -> Graph[Incomplete]: ... +def k_core(G: Graph[_Node], k: int | None = None, core_number: Mapping[Incomplete, Incomplete] | None = None) -> Graph[_Node]: ... @_dispatchable def k_shell( G: Graph[_Node], k: int | None = None, core_number: Mapping[Incomplete, Incomplete] | None = None -) -> Graph[Incomplete]: ... +) -> Graph[_Node]: ... @_dispatchable def k_crust( G: Graph[_Node], k: int | None = None, core_number: Mapping[Incomplete, Incomplete] | None = None -) -> Graph[Incomplete]: ... +) -> Graph[_Node]: ... @_dispatchable -def k_corona(G: Graph[_Node], k: int | None, core_number: Mapping[Incomplete, Incomplete] | None = None) -> Graph[Incomplete]: ... +def k_corona(G: Graph[_Node], k: int | None, core_number: Mapping[Incomplete, Incomplete] | None = None) -> Graph[_Node]: ... @_dispatchable -def k_truss(G: Graph[_Node], k: int) -> Graph[Incomplete]: ... +def k_truss(G: Graph[_Node], k: int) -> Graph[_Node]: ... @_dispatchable def onion_layers(G: Graph[_Node]) -> dict[Incomplete, Incomplete]: ... diff --git a/stubs/networkx/networkx/algorithms/operators/unary.pyi b/stubs/networkx/networkx/algorithms/operators/unary.pyi index 11a8f76ae663..f407a98dd436 100644 --- a/stubs/networkx/networkx/algorithms/operators/unary.pyi +++ b/stubs/networkx/networkx/algorithms/operators/unary.pyi @@ -1,4 +1,3 @@ -from _typeshed import Incomplete from collections.abc import Hashable from typing import TypeVar @@ -10,6 +9,6 @@ _G = TypeVar("_G", bound=Graph[Hashable]) __all__ = ["complement", "reverse"] @_dispatchable -def complement(G: Graph[_Node]) -> Graph[Incomplete]: ... +def complement(G: Graph[_Node]) -> Graph[_Node]: ... @_dispatchable def reverse(G: _G, copy: bool = True) -> _G: ... diff --git a/stubs/networkx/networkx/algorithms/tree/mst.pyi b/stubs/networkx/networkx/algorithms/tree/mst.pyi index dc175b1cb1f0..b8c4822a931a 100644 --- a/stubs/networkx/networkx/algorithms/tree/mst.pyi +++ b/stubs/networkx/networkx/algorithms/tree/mst.pyi @@ -69,19 +69,19 @@ def maximum_spanning_edges( @_dispatchable def minimum_spanning_tree( G: Graph[_Node], weight: str = "weight", algorithm: str = "kruskal", ignore_nan: bool = False -) -> Graph[Incomplete]: ... +) -> Graph[_Node]: ... @_dispatchable def partition_spanning_tree( G: Graph[_Node], minimum: bool = True, weight: str = "weight", partition: str = "partition", ignore_nan: bool = False -) -> Graph[Incomplete]: ... +) -> Graph[_Node]: ... @_dispatchable def maximum_spanning_tree( G: Graph[_Node], weight: str = "weight", algorithm: str = "kruskal", ignore_nan: bool = False -) -> Graph[Incomplete]: ... +) -> Graph[_Node]: ... @_dispatchable def random_spanning_tree( G: Graph[_Node], weight: str | None = None, *, multiplicative=True, seed: int | RandomState | None = None -) -> Graph[Incomplete]: ... +) -> Graph[_Node]: ... class SpanningTreeIterator: @dataclass(order=True)