-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
networkx: All return types from python-type-stubs #14256
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
Merged
srittau
merged 7 commits into
python:main
from
Avasam:networkx-return-type-annotations-from-python-type-stubs
Jul 8, 2025
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
4a6f83d
Finished migrating all return types
Avasam 99c280b
Merge branch 'main' of https://github.com/python/typeshed into networ…
Avasam 359d750
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] b891c71
Fixes post-merge
Avasam 5b3674f
Merge branch 'networkx-return-type-annotations-from-python-type-stubs…
Avasam d5c889e
Update stubs/networkx/networkx/algorithms/bipartite/edgelist.pyi
Avasam f7fcb64
Merge branch 'main' into networkx-return-type-annotations-from-python…
Avasam File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 4 additions & 2 deletions
6
stubs/networkx/networkx/algorithms/approximation/dominating_set.pyi
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,11 @@ | ||
| from _typeshed import Incomplete | ||
|
|
||
| from networkx.classes.graph import Graph, _Node | ||
| from networkx.utils.backends import _dispatchable | ||
|
|
||
| __all__ = ["min_weighted_dominating_set", "min_edge_dominating_set"] | ||
|
|
||
| @_dispatchable | ||
| def min_weighted_dominating_set(G: Graph[_Node], weight: str | None = None): ... | ||
| def min_weighted_dominating_set(G: Graph[_Node], weight: str | None = None) -> set[Incomplete]: ... | ||
| @_dispatchable | ||
| def min_edge_dominating_set(G: Graph[_Node]): ... | ||
| def min_edge_dominating_set(G: Graph[_Node]) -> set[Incomplete]: ... |
5 changes: 4 additions & 1 deletion
5
stubs/networkx/networkx/algorithms/approximation/kcomponents.pyi
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,10 @@ | ||
| from _typeshed import Incomplete | ||
| from collections import defaultdict | ||
|
|
||
| from networkx.classes.graph import Graph, _Node | ||
| from networkx.utils.backends import _dispatchable | ||
|
|
||
| __all__ = ["k_components"] | ||
|
|
||
| @_dispatchable | ||
| def k_components(G: Graph[_Node], min_density: float = 0.95): ... | ||
| def k_components(G: Graph[_Node], min_density: float = 0.95) -> defaultdict[Incomplete, list[Incomplete]]: ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,9 @@ | ||
| from _typeshed import Incomplete | ||
|
|
||
| from networkx.classes.graph import Graph, _Node | ||
| from networkx.utils.backends import _dispatchable | ||
|
|
||
| __all__ = ["min_maximal_matching"] | ||
|
|
||
| @_dispatchable | ||
| def min_maximal_matching(G: Graph[_Node]): ... | ||
| def min_maximal_matching(G: Graph[_Node]) -> set[Incomplete]: ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
stubs/networkx/networkx/algorithms/approximation/vertex_cover.pyi
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,9 @@ | ||
| from _typeshed import Incomplete | ||
|
|
||
| from networkx.classes.graph import Graph, _Node | ||
| from networkx.utils.backends import _dispatchable | ||
|
|
||
| __all__ = ["min_weighted_vertex_cover"] | ||
|
|
||
| @_dispatchable | ||
| def min_weighted_vertex_cover(G: Graph[_Node], weight: str | None = None): ... | ||
| def min_weighted_vertex_cover(G: Graph[_Node], weight: str | None = None) -> set[Incomplete]: ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,13 @@ | ||
| from _typeshed import Incomplete | ||
|
|
||
| from networkx.classes.graph import Graph, _Node | ||
| from networkx.utils.backends import _dispatchable | ||
|
|
||
| __all__ = ["degree_centrality", "betweenness_centrality", "closeness_centrality"] | ||
|
|
||
| @_dispatchable | ||
| def degree_centrality(G: Graph[_Node], nodes): ... | ||
| def degree_centrality(G: Graph[_Node], nodes) -> dict[Incomplete, Incomplete]: ... | ||
| @_dispatchable | ||
| def betweenness_centrality(G: Graph[_Node], nodes): ... | ||
| def betweenness_centrality(G: Graph[_Node], nodes) -> dict[Incomplete, Incomplete]: ... | ||
| @_dispatchable | ||
| def closeness_centrality(G: Graph[_Node], nodes, normalized: bool | None = True): ... | ||
| def closeness_centrality(G: Graph[_Node], nodes, normalized: bool | None = True) -> dict[Incomplete, Incomplete]: ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,9 @@ | ||
| from _typeshed import Incomplete | ||
|
|
||
| from networkx.classes.graph import Graph, _Node | ||
| from networkx.utils.backends import _dispatchable | ||
|
|
||
| __all__ = ["spectral_bipartivity"] | ||
|
|
||
| @_dispatchable | ||
| def spectral_bipartivity(G: Graph[_Node], nodes=None, weight: str = "weight"): ... | ||
| def spectral_bipartivity(G: Graph[_Node], nodes=None, weight: str = "weight") -> float | dict[Incomplete, Incomplete]: ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 5 additions & 1 deletion
6
stubs/networkx/networkx/algorithms/centrality/current_flow_closeness.pyi
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,13 @@ | ||
| from _typeshed import Incomplete | ||
|
|
||
| from networkx.classes.graph import Graph, _Node | ||
| from networkx.utils.backends import _dispatchable | ||
|
|
||
| __all__ = ["current_flow_closeness_centrality", "information_centrality"] | ||
|
|
||
| @_dispatchable | ||
| def current_flow_closeness_centrality(G: Graph[_Node], weight: str | None = None, dtype: type = ..., solver: str = "lu"): ... | ||
| def current_flow_closeness_centrality( | ||
| G: Graph[_Node], weight: str | None = None, dtype: type = ..., solver: str = "lu" | ||
| ) -> dict[Incomplete, float]: ... | ||
|
|
||
| information_centrality = current_flow_closeness_centrality |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, should we return
Any?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I added this comment initially because I probably added
Anyas well, but I think you could actually represent the return type with overloads based on theformatparam. So it's more "incomplete", than "unrepresentable".