Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add annotations for MultiDiGraph #13319

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions stubs/networkx/networkx/classes/multidigraph.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class MultiDiGraph(MultiGraph[_Node], DiGraph[_Node]):
@cached_property
def pred(self) -> MultiAdjacencyView[_Node, _Node, dict[str, Incomplete]]: ...
@cached_property
def edges(self) -> OutMultiEdgeView[_Node]: ...
@cached_property
def out_edges(self) -> OutMultiEdgeView[_Node]: ...
@cached_property
def in_edges(self) -> OutMultiEdgeView[_Node]: ...
Expand Down
48 changes: 39 additions & 9 deletions stubs/networkx/networkx/classes/reportviews.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -110,36 +110,66 @@ class EdgeView(OutEdgeView[_Node]): ...
class InEdgeView(OutEdgeView[_Node]): ...

class OutMultiEdgeView(OutEdgeView[_Node]):
def __iter__(self) -> Iterator[tuple[_Node, _Node, Incomplete]]: ... # type: ignore[override]
def __getitem__(self, e: tuple[_Node, _Node, Incomplete]) -> dict[str, Any]: ... # type: ignore[override]
@overload # type: ignore[override] # Has an additional `keys` keyword argument
def __call__(
def __call__( # type: ignore[overload-overlap]
self, nbunch: None = None, data: Literal[False] = False, *, default: Unused = None, keys: Literal[True]
) -> Self: ...
@overload
def __call__(
self, nbunch: _NBunch[_Node], data: Literal[True], *, default: None = None, keys: bool = False
) -> OutMultiEdgeDataView[_Node, tuple[_Node, _Node, dict[str, Incomplete]]]: ...
self, nbunch: _NBunch[_Node] = None, data: Literal[False] = False, *, default: None = None, keys: Literal[False] = False
) -> OutMultiEdgeDataView[_Node, tuple[_Node, _Node]]: ...
@overload
def __call__(
self, nbunch: _Node | Iterable[_Node], data: Literal[False] = False, *, default: None = None, keys: Literal[True]
) -> OutMultiEdgeDataView[_Node, tuple[_Node, _Node, Incomplete]]: ...
@overload
def __call__(
self, nbunch: _NBunch[_Node] = None, *, data: Literal[True], default: None = None, keys: Literal[True]
) -> OutMultiEdgeDataView[_Node, tuple[_Node, _Node, Incomplete, dict[str, Incomplete]]]: ...
@overload
def __call__(
self, nbunch: _NBunch[_Node], data: Literal[True], *, default: None = None, keys: Literal[True]
) -> OutMultiEdgeDataView[_Node, tuple[_Node, _Node, Incomplete, dict[str, Incomplete]]]: ...
@overload
def __call__(
self, nbunch: _NBunch[_Node] = None, *, data: Literal[True], default: None = None, keys: bool = False
self, nbunch: _NBunch[_Node] = None, *, data: Literal[True], default: None = None, keys: Literal[False] = False
) -> OutMultiEdgeDataView[_Node, tuple[_Node, _Node, dict[str, Incomplete]]]: ...
@overload
def __call__(
self, nbunch: _NBunch[_Node], data: str, *, default: _U | None = None, keys: bool = False
self, nbunch: _NBunch[_Node], data: str, *, default: _U | None = None, keys: Literal[False] = False
) -> OutMultiEdgeDataView[_Node, tuple[_Node, _Node, _U]]: ...
@overload
def __call__(
self, nbunch: _NBunch[_Node] = None, *, data: str, default: _U | None = None, keys: bool = False
self, nbunch: _NBunch[_Node] = None, *, data: str, default: _U | None = None, keys: Literal[True]
) -> OutMultiEdgeDataView[_Node, tuple[_Node, _Node, Incomplete, _U]]: ...
@overload
def __call__(
self, nbunch: _NBunch[_Node] = None, *, data: str, default: _U | None = None, keys: Literal[False] = False
) -> OutMultiEdgeDataView[_Node, tuple[_Node, _Node, _U]]: ...
@overload # type: ignore[override]
def data(self, data: Literal[False], default: Unused = None, nbunch: None = None, *, keys: Literal[True]) -> Self: ...
@overload
def data(self, data: Literal[False], default: Unused = None, nbunch: None = None, keys: Literal[False] = False) -> Self: ...
def data(
self, data: Literal[False], default: None = None, nbunch: _NBunch[_Node] = None, keys: Literal[False] = False
) -> OutMultiEdgeDataView[_Node, tuple[_Node, _Node]]: ...
@overload
def data(
self, data: Literal[True] = True, default: None = None, nbunch: _NBunch[_Node] = None, keys: bool = False
self, data: Literal[True] = True, default: None = None, nbunch: _NBunch[_Node] = None, keys: Literal[False] = False
) -> OutMultiEdgeDataView[_Node, tuple[_Node, _Node, dict[str, Incomplete]]]: ...
@overload
def data(
self, data: str, default: _U | None = None, nbunch: _NBunch[_Node] = None, keys: bool = False
self, data: Literal[True] = True, default: None = None, nbunch: _NBunch[_Node] = None, *, keys: Literal[True]
) -> OutMultiEdgeDataView[_Node, tuple[_Node, _Node, Incomplete, dict[str, Incomplete]]]: ...
@overload
def data(
self, data: str, default: _U | None = None, nbunch: _NBunch[_Node] = None, keys: Literal[False] = False
) -> OutMultiEdgeDataView[_Node, tuple[_Node, _Node, _U]]: ...
@overload
def data(
self, data: str, default: _U | None = None, nbunch: _NBunch[_Node] = None, *, keys: Literal[True]
) -> OutMultiEdgeDataView[_Node, tuple[_Node, _Node, Incomplete, _U]]: ...

class MultiEdgeView(OutMultiEdgeView[_Node]): ...
class InMultiEdgeView(OutMultiEdgeView[_Node]): ...
Loading