-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Correct type annotations on NetworkX DiGraphs #14595
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -41,10 +41,10 @@ class NodeView(Mapping[_Node, dict[str, Any]], AbstractSet[_Node]): | |||||||||||||||||
def __getitem__(self, n: _Node) -> dict[str, Any]: ... | ||||||||||||||||||
def __contains__(self, n: object) -> bool: ... | ||||||||||||||||||
@overload | ||||||||||||||||||
def __call__(self, data: Literal[False] = False, default=None) -> Iterator[_Node]: ... | ||||||||||||||||||
def __call__(self, data: Literal[False] = False, default=None) -> Self: ... | ||||||||||||||||||
@overload | ||||||||||||||||||
def __call__(self, data: Literal[True] | str, default=None) -> Iterator[tuple[_Node, dict[str, Any]]]: ... | ||||||||||||||||||
def data(self, data: bool | str = True, default=None) -> NodeDataView[_Node]: ... | ||||||||||||||||||
def __call__(self, data: Literal[True] | str, default=None) -> Self: ... | ||||||||||||||||||
def data(self, data: bool | str = True, default=None) -> Self: ... | ||||||||||||||||||
|
||||||||||||||||||
class NodeDataView(AbstractSet[_Node]): | ||||||||||||||||||
def __init__(self, nodedict: Mapping[str, Incomplete], data: bool | str = False, default=None) -> None: ... | ||||||||||||||||||
|
@@ -55,7 +55,10 @@ class NodeDataView(AbstractSet[_Node]): | |||||||||||||||||
|
||||||||||||||||||
class DiDegreeView(Generic[_Node]): | ||||||||||||||||||
def __init__(self, G: Graph[_Node], nbunch: _NBunch[_Node] = None, weight: None | bool | str = None) -> None: ... | ||||||||||||||||||
def __call__(self, nbunch: _NBunch[_Node] = None, weight: None | bool | str = None) -> int | DiDegreeView[_Node]: ... | ||||||||||||||||||
@overload | ||||||||||||||||||
def __call__(self, nbunch: None = None, weight: None | bool | str = None) -> int: ... # type: ignore[overload-overlap] | ||||||||||||||||||
@overload | ||||||||||||||||||
def __call__(self, nbunch: None | Iterable[_Node], weight: None | bool | str = None) -> Self: ... | ||||||||||||||||||
Comment on lines
+58
to
+61
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The overlap error is correct here. I also think it's inverted since
Suggested change
![]() There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right; the overload should be specialized to
(ignoring, like we have been, that it could actually return |
||||||||||||||||||
def __getitem__(self, n: _Node) -> float: ... | ||||||||||||||||||
def __iter__(self) -> Iterator[tuple[_Node, float]]: ... | ||||||||||||||||||
def __len__(self) -> int: ... | ||||||||||||||||||
|
Uh oh!
There was an error while loading. Please reload this page.