Skip to content

Commit 94fe857

Browse files
authored
networkx: fix and complete functions related to the dot interface (#14600)
1 parent ca44e4c commit 94fe857

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

stubs/networkx/networkx/drawing/nx_agraph.pyi

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,14 @@ class _SupportsOpen(Protocol[_ModeT_contra, _FileT_co]):
1717

1818
@_dispatchable
1919
def from_agraph(
20-
A: AGraph, create_using: Graph[_Node] | type[Graph[_Node]] | None = None
21-
) -> Graph[_Node]: ... # type of node cannot be known statically
20+
A: AGraph, create_using: Graph[str] | type[Graph[str]] | None = None # TODO: add overloads on `create_using`
21+
) -> Graph[str]: ...
2222
def to_agraph(N: Graph[_Node]) -> AGraph: ...
2323
def write_dot(
2424
G: Graph[_Node], path: str | IO[str] | IO[bytes] | _SupportsOpen[OpenTextModeWriting, IO[str] | IO[bytes]]
2525
) -> None: ...
2626
@_dispatchable
27-
def read_dot(
28-
path: str | IO[str] | IO[bytes] | _SupportsOpen[OpenTextModeReading, IO[str] | IO[bytes]],
29-
) -> Graph[Any]: ... # type of node cannot be known statically
27+
def read_dot(path: str | IO[str] | IO[bytes] | _SupportsOpen[OpenTextModeReading, IO[str] | IO[bytes]]) -> Graph[str]: ...
3028
def graphviz_layout(
3129
G: Graph[_Node], prog: str = "neato", root: str | None = None, args: str = ""
3230
) -> dict[_Node, tuple[float, float]]: ...

stubs/networkx/networkx/drawing/nx_pydot.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def write_dot(G: Graph[_Node], path: str | PathLike[Any] | SupportsWrite[str]) -
1212
@_dispatchable
1313
def read_dot(path: str | PathLike[Any] | SupportsRead[str]) -> Graph[str]: ...
1414
@_dispatchable
15-
def from_pydot(P: Dot): ...
15+
def from_pydot(P: Dot) -> Graph[str]: ...
1616
def to_pydot(N: Graph[_Node]) -> Dot: ...
17-
def graphviz_layout(G: Graph[_Node], prog: str = "neato", root: _Node | None = None): ...
18-
def pydot_layout(G: Graph[_Node], prog: str = "neato", root: _Node | None = None): ...
17+
def graphviz_layout(G: Graph[_Node], prog: str = "neato", root: _Node | None = None) -> dict[_Node, tuple[float, float]]: ...
18+
def pydot_layout(G: Graph[_Node], prog: str = "neato", root: _Node | None = None) -> dict[_Node, tuple[float, float]]: ...

0 commit comments

Comments
 (0)