Skip to content

Commit 6501d32

Browse files
committed
enhance graphviz_draw type hint
1 parent aea56cf commit 6501d32

File tree

1 file changed

+54
-5
lines changed

1 file changed

+54
-5
lines changed

rustworkx/visualization/graphviz.pyi

Lines changed: 54 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,66 @@ import typing
1010
from rustworkx.rustworkx import PyGraph, PyDiGraph
1111

1212
if typing.TYPE_CHECKING:
13-
from PIL import Image # type: ignore
13+
from PIL.Image import Image
14+
Method: typing.TypeAlias = typing.Literal["twopi", "neato", "circo", "fdp", "sfdp", "dot"]
15+
ImageType: typing.TypeAlias = typing.Literal[
16+
"canon",
17+
"cmap",
18+
"cmapx",
19+
"cmapx_np",
20+
"dia",
21+
"dot",
22+
"fig",
23+
"gd",
24+
"gd2",
25+
"gif",
26+
"hpgl",
27+
"imap",
28+
"imap_np",
29+
"ismap",
30+
"jpe",
31+
"jpeg",
32+
"jpg",
33+
"mif",
34+
"mp",
35+
"pcl",
36+
"pdf",
37+
"pic",
38+
"plain",
39+
"plain-ext",
40+
"png",
41+
"ps",
42+
"ps2",
43+
"svg",
44+
"svgz",
45+
"vml",
46+
"vmlzvrml",
47+
"vtx",
48+
"wbmp",
49+
"xdor",
50+
"xlib",
51+
]
1452

1553
_S = typing.TypeVar("_S")
1654
_T = typing.TypeVar("_T")
1755

56+
@typing.overload
1857
def graphviz_draw(
1958
graph: PyDiGraph[_S, _T] | PyGraph[_S, _T],
2059
node_attr_fn: typing.Callable[[_S], dict[str, str]] | None = ...,
2160
edge_attr_fn: typing.Callable[[_T], dict[str, str]] | None = ...,
2261
graph_attr: dict[str, str] | None = ...,
23-
filename: str | None = ...,
24-
image_type: str | None = ...,
25-
method: str | None = ...,
26-
) -> Image | None: ...
62+
filename: None = ...,
63+
image_type: ImageType | None = ...,
64+
method: Method | None = ...,
65+
) -> Image: ...
66+
@typing.overload
67+
def graphviz_draw(
68+
graph: PyDiGraph[_S, _T] | PyGraph[_S, _T],
69+
node_attr_fn: typing.Callable[[_S], dict[str, str]] | None = ...,
70+
edge_attr_fn: typing.Callable[[_T], dict[str, str]] | None = ...,
71+
graph_attr: dict[str, str] | None = ...,
72+
filename: str = ...,
73+
image_type: ImageType | None = ...,
74+
method: Method | None = ...,
75+
) -> None: ...

0 commit comments

Comments
 (0)