-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[networkx] More precise annotation for nested tuples #14287
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
base: main
Are you sure you want to change the base?
Changes from 2 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 | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,18 +1,21 @@ | ||||||||||||
from _typeshed import Incomplete | ||||||||||||
from collections.abc import Iterable | ||||||||||||
from typing import TypeAlias | ||||||||||||
|
||||||||||||
from networkx.classes.graph import Graph, _Node | ||||||||||||
from networkx.exception import NetworkXException | ||||||||||||
from networkx.utils.backends import _dispatchable | ||||||||||||
|
||||||||||||
__all__ = ["from_nested_tuple", "from_prufer_sequence", "NotATree", "to_nested_tuple", "to_prufer_sequence"] | ||||||||||||
|
||||||||||||
_NestedTuple: TypeAlias = tuple[_NestedTuple, ...] | ||||||||||||
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.
Huh, apparently that's correct: Nevermind then! Sorry for the noise :-) 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. Unless my understanding is wrong, there should indeed be no other types but only nested tuples: 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. No worries, thanks for taking a look :) 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. I was gonna ask the same question. And made the same assumption in my initial comment. Could you add a comment here pointing to that documentation ?
Suggested change
Feel free to reword. (as a side note, you could write Otherwise LGTM. |
||||||||||||
|
||||||||||||
class NotATree(NetworkXException): ... | ||||||||||||
|
||||||||||||
@_dispatchable | ||||||||||||
def to_nested_tuple(T: Graph[_Node], root: _Node, canonical_form: bool = False): ... | ||||||||||||
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. While we're here...
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. Sounds good, I wasn't sure if the return hints were left out for a reason |
||||||||||||
@_dispatchable | ||||||||||||
def from_nested_tuple(sequence: tuple[Incomplete, ...], sensible_relabeling: bool = False): ... | ||||||||||||
def from_nested_tuple(sequence: _NestedTuple, sensible_relabeling: bool = False): ... | ||||||||||||
@_dispatchable | ||||||||||||
def to_prufer_sequence(T: Graph[_Node]): ... | ||||||||||||
@_dispatchable | ||||||||||||
|
Uh oh!
There was an error while loading. Please reload this page.