Skip to content

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

Open
cristianchiriac wants to merge 1 commit into
python:mainfrom
cristianchiriac:networkx-graph-node-typevar
Open

cristianchiriac wants to merge 1 commit into
python:mainfrom
cristianchiriac:networkx-graph-node-typevar

Conversation

@cristianchiriac

Copy link
Copy Markdown

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.
@github-actions

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

This branch has not been deployed

No deployments
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

1 participant