diff --git a/stubs/networkx/networkx/relabel.pyi b/stubs/networkx/networkx/relabel.pyi index 5607b6e08149..d8d2c1b608a6 100644 --- a/stubs/networkx/networkx/relabel.pyi +++ b/stubs/networkx/networkx/relabel.pyi @@ -1,4 +1,4 @@ -from collections.abc import Hashable, Mapping +from collections.abc import Callable, Hashable, Mapping from typing import Literal, TypeVar, overload from networkx.classes.digraph import DiGraph @@ -13,13 +13,15 @@ _Y = TypeVar("_Y", bound=Hashable) __all__ = ["convert_node_labels_to_integers", "relabel_nodes"] @overload -def relabel_nodes(G: MultiDiGraph[_X], mapping: Mapping[_X, _Y], copy: bool = True) -> MultiDiGraph[_X | _Y]: ... +def relabel_nodes( + G: MultiDiGraph[_X], mapping: Mapping[_X, _Y] | Callable[[_X], _Y], copy: bool = True +) -> MultiDiGraph[_X | _Y]: ... @overload -def relabel_nodes(G: DiGraph[_X], mapping: Mapping[_X, _Y], copy: bool = True) -> DiGraph[_X | _Y]: ... +def relabel_nodes(G: DiGraph[_X], mapping: Mapping[_X, _Y] | Callable[[_X], _Y], copy: bool = True) -> DiGraph[_X | _Y]: ... @overload -def relabel_nodes(G: MultiGraph[_X], mapping: Mapping[_X, _Y], copy: bool = True) -> MultiGraph[_X | _Y]: ... +def relabel_nodes(G: MultiGraph[_X], mapping: Mapping[_X, _Y] | Callable[[_X], _Y], copy: bool = True) -> MultiGraph[_X | _Y]: ... @overload -def relabel_nodes(G: Graph[_X], mapping: Mapping[_X, _Y], copy: bool = True) -> Graph[_X | _Y]: ... +def relabel_nodes(G: Graph[_X], mapping: Mapping[_X, _Y] | Callable[[_X], _Y], copy: bool = True) -> Graph[_X | _Y]: ... @_dispatchable def convert_node_labels_to_integers(