Skip to content

Commit 60c91f3

Browse files
authored
Enhance annotation for Graph.add_weighted_edges_from
Enhance annotation for `Graph.add_weighted_edges_from` The current [`3.6.1.20260303`](https://github.com/python/typeshed/blob/50ec9108eb191ab96d9ab766e506a7c680d5f3d6/stubs/networkx/networkx/classes/graph.pyi#L74) textual description states: > ebunch_to_add: container of edges >Each edge given in the list or container will be added to the > graph. > The edges must be given as 3-tuples (u, v, w) where w is a > number. However 1. `w` can be a `Decimal` (which is still a number) or 2. even `None` (which is not a number), but the used `add_edges_from` and `add_edges` methods process it fine. Change the annotation to reflect these.
1 parent 50ec910 commit 60c91f3

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

stubs/networkx/networkx/classes/graph.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from collections.abc import Callable, Collection, Hashable, Iterable, Iterator, MutableMapping
2+
from decimal import Decimal
23
from functools import cached_property
34
from typing import Any, ClassVar, TypeVar, overload
45
from typing_extensions import Self, TypeAlias
@@ -71,7 +72,7 @@ class Graph(Collection[_Node]):
7172
def add_edges_from(self, ebunch_to_add: Iterable[_EdgePlus[_Node]], **attr: Any) -> None: ...
7273
# attr: Edge data (or labels or objects) can be assigned using keyword arguments
7374
def add_weighted_edges_from(
74-
self, ebunch_to_add: Iterable[tuple[_Node, _Node, float]], weight: str = "weight", **attr: Any
75+
self, ebunch_to_add: Iterable[tuple[_Node, _Node, float|Decimal|None]], weight: str = "weight", **attr: Any
7576
) -> None: ...
7677
# attr: Edge attributes to add/update for all edges.
7778
def remove_edge(self, u: _Node, v: _Node) -> None: ...

0 commit comments

Comments
 (0)