Skip to content

Commit bb244d3

Browse files
authored
[networkx] Fix a few annotations in AtlasView and Graph (#13656)
1 parent ec5246b commit bb244d3

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

stubs/networkx/networkx/classes/coreviews.pyi

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ _U = TypeVar("_U")
77
_V = TypeVar("_V")
88

99
class AtlasView(Mapping[_T, dict[_U, _V]]):
10+
def __getstate__(self) -> dict[str, Mapping[_T, dict[_U, _V]]]: ...
11+
def __setstate__(self, state: dict[str, Mapping[_T, dict[_U, _V]]]) -> None: ...
1012
def __init__(self, d: Mapping[_T, dict[_U, _V]]) -> None: ...
1113
def __len__(self) -> int: ...
1214
def __iter__(self) -> Iterator[_T]: ...
1315
def __getitem__(self, key: _T) -> dict[_U, _V]: ...
14-
def copy(self) -> Self: ...
16+
def copy(self) -> dict[_T, dict[_U, _V]]: ...
1517

1618
class AdjacencyView(AtlasView[_T, _U, _V]): ...
1719
class MultiAdjacencyView(AdjacencyView[_T, _U, _V]): ...

stubs/networkx/networkx/classes/graph.pyi

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ class Graph(Collection[_Node]):
4545
def name(self) -> str: ...
4646
@name.setter
4747
def name(self, s: str) -> None: ...
48-
def __getitem__(self, n: _Node) -> AtlasView[_Node, _Node, dict[str, Incomplete]]: ...
48+
def __getitem__(self, n: _Node) -> AtlasView[_Node, str, Any]: ...
4949
def __iter__(self) -> Iterator[_Node]: ...
5050
def __contains__(self, n: object) -> bool: ...
5151
def __len__(self) -> int: ...
52-
def add_node(self, node_for_adding: _Node, **attr) -> None: ...
52+
def add_node(self, node_for_adding: _Node, **attr: Any) -> None: ... # attr: Set or change node attributes using key=value
5353
def add_nodes_from(self, nodes_for_adding: Iterable[_NodePlus[_Node]], **attr) -> None: ...
5454
def remove_node(self, n: _Node) -> None: ...
5555
def remove_nodes_from(self, nodes: Iterable[_Node]) -> None: ...
@@ -58,7 +58,8 @@ class Graph(Collection[_Node]):
5858
def number_of_nodes(self) -> int: ...
5959
def order(self) -> int: ...
6060
def has_node(self, n: _Node) -> bool: ...
61-
def add_edge(self, u_of_edge: _Node, v_of_edge: _Node, **attr) -> None: ...
61+
# attr: Edge data (or labels or objects) can be assigned using keyword arguments
62+
def add_edge(self, u_of_edge: _Node, v_of_edge: _Node, **attr: Any) -> None: ...
6263
def add_edges_from(self, ebunch_to_add: Iterable[_EdgePlus[_Node]], **attr) -> None: ...
6364
def add_weighted_edges_from(
6465
self, ebunch_to_add: Iterable[tuple[_Node, _Node, Incomplete]], weight: str = "weight", **attr

0 commit comments

Comments
 (0)