Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify Any for PyGraph and PyDiGraph type annotations for pyright compatibility #1246

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
fixes:
- |
Enhanced the compatibility of the type annotations with `pyright` in strict
mode. See `issue 1242 <https://github.com/Qiskit/rustworkx/issues/1242>`__ for
more details.
42 changes: 22 additions & 20 deletions rustworkx/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -273,13 +273,13 @@ _DijkstraVisitor = TypeVar("_DijkstraVisitor", bound=visit.DijkstraVisitor)
class PyDAG(Generic[_S, _T], PyDiGraph[_S, _T]): ...

def distance_matrix(
graph: PyGraph | PyDiGraph,
graph: PyGraph[Any, Any] | PyDiGraph[Any, Any],
mtreinish marked this conversation as resolved.
Show resolved Hide resolved
parallel_threshold: int = ...,
as_undirected: bool = ...,
null_value: float = ...,
) -> np.ndarray: ...
def unweighted_average_shortest_path_length(
graph: PyGraph | PyDiGraph,
graph: PyGraph[Any, Any] | PyDiGraph[Any, Any],
parallel_threshold: int = ...,
disconnected: bool = ...,
) -> float: ...
Expand All @@ -290,7 +290,7 @@ def adjacency_matrix(
null_value: float = ...,
) -> np.ndarray: ...
def all_simple_paths(
graph: PyGraph | PyDiGraph,
graph: PyGraph[Any, Any] | PyDiGraph[Any, Any],
from_: int,
to: int,
min_depth: int | None = ...,
Expand Down Expand Up @@ -337,7 +337,7 @@ def all_pairs_dijkstra_shortest_paths(
edge_cost_fn: Callable[[_T], float] | None,
) -> AllPairsPathMapping: ...
def all_pairs_all_simple_paths(
graph: PyGraph | PyDiGraph,
graph: PyGraph[Any, Any] | PyDiGraph[Any, Any],
min_depth: int | None = ...,
cutoff: int | None = ...,
) -> AllPairsMultiplePathMapping: ...
Expand Down Expand Up @@ -444,7 +444,9 @@ def spring_layout(
center: tuple[float, float] | None = ...,
seed: int | None = ...,
) -> Pos2DMapping: ...
def networkx_converter(graph: Any, keep_attributes: bool = ...) -> PyGraph | PyDiGraph: ...
def networkx_converter(
graph: Any, keep_attributes: bool = ...
) -> PyGraph[Any, Any] | PyDiGraph[Any, Any]: ...
def bipartite_layout(
graph: PyGraph[_S, _T] | PyDiGraph[_S, _T],
first_nodes,
Expand Down Expand Up @@ -543,36 +545,36 @@ def union(
) -> PyDiGraph[_S, _T]: ...
@overload
def tensor_product(
first: PyGraph,
second: PyGraph,
) -> tuple[PyGraph, ProductNodeMap]: ...
first: PyGraph[Any, Any],
second: PyGraph[Any, Any],
) -> tuple[PyGraph[Any, Any], ProductNodeMap]: ...
@overload
def tensor_product(
first: PyDiGraph,
second: PyDiGraph,
) -> tuple[PyDiGraph, ProductNodeMap]: ...
first: PyDiGraph[Any, Any],
second: PyDiGraph[Any, Any],
) -> tuple[PyDiGraph[Any, Any], ProductNodeMap]: ...
@overload
def cartesian_product(
first: PyGraph,
second: PyGraph,
) -> tuple[PyGraph, ProductNodeMap]: ...
first: PyGraph[Any, Any],
second: PyGraph[Any, Any],
) -> tuple[PyGraph[Any, Any], ProductNodeMap]: ...
@overload
def cartesian_product(
first: PyDiGraph,
second: PyDiGraph,
) -> tuple[PyDiGraph, ProductNodeMap]: ...
first: PyDiGraph[Any, Any],
second: PyDiGraph[Any, Any],
) -> tuple[PyDiGraph[Any, Any], ProductNodeMap]: ...
def bfs_search(
graph: PyGraph | PyDiGraph,
graph: PyGraph[Any, Any] | PyDiGraph[Any, Any],
source: Sequence[int] | None,
visitor: _BFSVisitor,
) -> None: ...
def dfs_search(
graph: PyGraph | PyDiGraph,
graph: PyGraph[Any, Any] | PyDiGraph[Any, Any],
source: Sequence[int] | None,
visitor: _DFSVisitor,
) -> None: ...
def dijkstra_search(
graph: PyGraph | PyDiGraph,
graph: PyGraph[Any, Any] | PyDiGraph[Any, Any],
source: Sequence[int] | None,
weight_fn: Callable[[Any], float],
visitor: _DijkstraVisitor,
Expand Down
Loading