Skip to content

[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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
Next Next commit
[networkx] More precise annotation for nested tuples
  • Loading branch information
AckslD committed Jun 16, 2025
commit e5b9e8de03e5e1e9db696353e15d76de9c7e3fd4
5 changes: 4 additions & 1 deletion stubs/networkx/networkx/algorithms/tree/coding.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from _typeshed import Incomplete
from typing import TypeAlias
from collections.abc import Iterable

from networkx.classes.graph import Graph, _Node
Expand All @@ -7,12 +8,14 @@ from networkx.utils.backends import _dispatchable

__all__ = ["from_nested_tuple", "from_prufer_sequence", "NotATree", "to_nested_tuple", "to_prufer_sequence"]

_NestedTuple: TypeAlias = tuple['_NestedTuple', ...]

class NotATree(NetworkXException): ...

@_dispatchable
def to_nested_tuple(T: Graph[_Node], root: _Node, canonical_form: bool = False): ...
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While we're here...

Suggested change
def to_nested_tuple(T: Graph[_Node], root: _Node, canonical_form: bool = False): ...
def to_nested_tuple(T: Graph[_Node], root: _Node, canonical_form: bool = False) -> _NestedTuple: ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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
Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy