Skip to content

[networkx] Preserve the node type in isolates() - #16902

Open
HowXu wants to merge 1 commit into
python:mainfrom
HowXu:fix/networkx-isolates-node-type
Open

HowXu wants to merge 1 commit into
python:mainfrom
HowXu:fix/networkx-isolates-node-type

Conversation

@HowXu

@HowXu HowXu commented Nov 25, 2026

Copy link
Copy Markdown

Related to #14031

Summary

Change the return type of networkx.isolates() from Iterator[Incomplete] to Iterator[_Node]
According to NetworkX implementation yields nodes from the input graph, so the iterator should preserve their type.

Test

With mypy on Python 3.12, this assertion failed before the change (Any instead of str) and passes afterward:

from typing import assert_type
import networkx as nx

def check_isolates(graph: nx.Graph[str]) -> None:
      assert_type(next(nx.isolates(graph)), str)

@github-actions

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

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.

1 participant