Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
networkx: overload + TypeVar
  • Loading branch information
hunterhogan committed Aug 18, 2025
commit 8f6140d236e253f1bceeadaac5cc862a8b78af99
5 changes: 4 additions & 1 deletion stubs/networkx/networkx/classes/graph.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@ class Graph(Collection[_Node]):
def neighbors(self, n: _Node) -> Iterator[_Node]: ...
@cached_property
def edges(self) -> EdgeView[_Node]: ...
def get_edge_data(self, u: _Node, v: _Node, default: _DefaultT | None = None) -> dict[str, Any] | _DefaultT: ...
@overload
def get_edge_data(self, u: _Node, v: _Node, default: None = None) -> dict[str, Any] | None: ...
@overload
def get_edge_data(self, u: _Node, v: _Node, default: _DefaultT) -> dict[str, Any] | _DefaultT: ...
# default: any Python object
def adjacency(self) -> Iterator[tuple[_Node, dict[_Node, dict[str, Any]]]]: ...
@cached_property
Expand Down
19 changes: 13 additions & 6 deletions stubs/networkx/networkx/classes/multigraph.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,25 @@ class MultiGraph(Graph[_Node]):
def remove_edge(self, u: _Node, v: _Node, key: Hashable | None = None) -> None: ...
def has_edge(self, u: _Node, v: _Node, key: Hashable | None = None) -> bool: ...
@overload # type: ignore[override]
def get_edge_data(
self, u: _Node, v: _Node, key: Hashable, default: _DefaultT | None = None
) -> dict[str, Any] | _DefaultT: ...
def get_edge_data(self, u: _Node, v: _Node, key: Hashable, default: None = None) -> dict[str, Any] | None: ...
# key : hashable identifier, optional (default=None).
# Returns : The edge attribute dictionary.
@overload # type: ignore[override]
def get_edge_data(self, u: _Node, v: _Node, key: Hashable, default: _DefaultT) -> dict[str, Any] | _DefaultT: ...
# key : hashable identifier, optional (default=None).
# default : any Python object (default=None). Value to return if the specific edge (u, v, key) is not found.
# Returns: The edge attribute dictionary.
# Returns : The edge attribute dictionary.
@overload
def get_edge_data(
self, u: _Node, v: _Node, key: None = None, default: None = None
) -> dict[Hashable, dict[str, Any] | None]: ...
# Returns : A dictionary mapping edge keys to attribute dictionaries for each of those edges if no specific key is provided.
@overload
def get_edge_data(
self, u: _Node, v: _Node, key: None = None, default: _DefaultT | None = None
self, u: _Node, v: _Node, key: None = None, *, default: _DefaultT
) -> dict[Hashable, dict[str, Any] | _DefaultT]: ...
# default : any Python object (default=None). Value to return if there are no edges between u and v and no key is specified.
# Returns: A dictionary mapping edge keys to attribute dictionaries for each of those edges if no specific key is provided.
# Returns : A dictionary mapping edge keys to attribute dictionaries for each of those edges if no specific key is provided.
def copy(self, as_view: bool = False) -> MultiGraph[_Node]: ...
def to_directed(self, as_view: bool = False) -> MultiDiGraph[_Node]: ...
def to_undirected(self, as_view: bool = False) -> MultiGraph[_Node]: ...
Expand Down
Loading