Repository navigation
Conversation
…e `algorithms` Graph parameters annotated as `Graph[_Node]` only accept the default `dict[str, Any]` node and edge data, so graphs with other `Mapping` data types are rejected by functions that never look at the data. Type them as `Graph[_Node, _NodeData, _EdgeData]` in `classes.function`, `convert`, `convert_matrix`, `generators`, `linalg`, `readwrite` and `utils`, as already done for `classes` and `drawing`. Return types of graph-building functions are unchanged; `edge_subgraph()` and `restricted_view()` now return the input graph's type. Part of python#16365. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This comment has been minimized.
This comment has been minimized.
The other networkx test cases carry the -py312 suffix because numpy's stubs no longer type-check under --python-version 3.10/3.11, and the strict test-case pyright config reports partially unknown types for functions whose return is unannotated or typed with scipy. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This comment has been minimized.
This comment has been minimized.
Contributor
|
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
This branch has not been deployed
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
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.
Part of #16365, following up on #16371.
Preserve NetworkX node and edge data type parameters in graph inputs outside networkx.algorithms, including view return types for edge_subgraph and restricted_view. Functions that create new graphs retain their upstream return types.
The selfloop_edges overloads that also use _U retain Any data parameters to avoid TypeVar default-ordering errors. Merged current main while preserving its FloatInt annotations, scalar attribute overloads, and concrete graph return types.
Agent assistance: Claude Code for the original change; Codex for the merge, review updates, and validation.