Skip to content

Commit 43596e2

Browse files
committed
[networkx] add type hints for networkx.utils.union_find.UnionFind
1 parent f1359a6 commit 43596e2

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed
Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
from _typeshed import Incomplete
2-
from collections.abc import Generator, Iterator
1+
from collections.abc import Generator, Iterable, Iterator, Mapping
2+
from typing import Generic, TypeVar
33

4-
class UnionFind:
5-
parents: Incomplete
6-
weights: Incomplete
7-
def __init__(self, elements=None) -> None: ...
8-
def __getitem__(self, object): ...
9-
def __iter__(self) -> Iterator[Incomplete]: ...
10-
def to_sets(self) -> Generator[Incomplete, Incomplete, None]: ...
11-
def union(self, *objects): ...
4+
_T = TypeVar("_T")
5+
6+
class UnionFind(Generic[_T]):
7+
parents: Mapping[_T, _T]
8+
weights: Mapping[_T, int]
9+
def __init__(self, elements: Iterable[_T] | None = None) -> None: ...
10+
def __getitem__(self, object: _T) -> _T: ...
11+
def __iter__(self) -> Iterator[_T]: ...
12+
def to_sets(self) -> Generator[set[_T]]: ...
13+
def union(self, *objects: _T) -> None: ...

0 commit comments

Comments
 (0)