FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[networkx] Accept any node type in graph functions that took Graph[Hashable] by cristianchiriac · Pull Request #16557 · python/typeshed · GitHub

Repository navigation

[networkx] Accept any node type in graph functions that took Graph[Hashable] - #16557

Merged
JelleZijlstra merged 1 commit into
python:mainfrom
cristianchiriac:networkx-graph-node-typevar
Oct 20, 2026
Merged

JelleZijlstra merged 1 commit into
python:mainfrom
cristianchiriac:networkx-graph-node-typevar

Conversation

Copy link
Copy Markdown
Contributor

Fixes #16543.

Graph is invariant in its node type, so the functions in networkx/classes/function.pyi that took Graph[Hashable] (set_node_attributes(..., name=...), set_edge_attributes(..., name=None), is_directed, is_empty, number_of_selfloops) rejected a Graph[str]; they now use _Node like the rest of the module.

Upstream: networkx/classes/function.py

Agent: Claude Code

…shable]

Graph is invariant in its node type, so Graph[Hashable] rejected
Graph[str] and similar graphs. Use the _Node type variable, like the
other functions in the module.

Copy link
Copy Markdown
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

scipy-stubs (https://github.com/scipy/scipy-stubs)
+ tests/misc/test_submodules_empty.pyi:3: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports

JelleZijlstra merged commit caeb62f into python:main Oct 20, 2026
74 checks passed
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect variance for nx.set_node_attributes

2 participants


Back | FazBrowse Home | New Git URL