-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finalize type signatures and enforce for all future functions
This commit adds the last few missing type hints (primarily the generators module) and switches the CI configuration over to enforce that the library is completely type hinted. This makes it a CI error if a function or method is added that doesn't include type hints. This is all built on the hard work of @IvanIsCoding who built up all the type hinting infrastructure and stub files for the majority of rustworkx. This is just the last piece to enforce the library is fully typed moving forward. Co-authored-by: Ivan Carvalho <[email protected]>
- Loading branch information
1 parent
27c88f6
commit e1582cf
Showing
6 changed files
with
161 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
# This code is licensed under the Apache License, Version 2.0. You may | ||
# obtain a copy of this license in the LICENSE.txt file in the root directory | ||
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. | ||
# | ||
# Any modifications or derivative works of this code must retain this | ||
# copyright notice, and modified files need to carry a notice indicating | ||
# that they have been altered from the originals. | ||
|
||
# This file contains only type annotations for PyO3 functions and classes | ||
# For implementation details, see __init__.py and src/shortest_path/mod.rs | ||
|
||
import numpy as np | ||
|
||
from .iterators import * | ||
from .graph import PyGraph | ||
from .digraph import PyDiGraph | ||
|
||
from typing import Sequence, Any | ||
|
||
def cycle_graph( | ||
num_nodes: int | None = ..., weights: Sequence[Any] | None = ..., multigraph: bool = ... | ||
) -> PyGraph: ... | ||
def directed_cycle_graph( | ||
num_nodes: int | None = ..., | ||
weights: Sequence[Any] | None = ..., | ||
bidirectional: bool = ..., | ||
multigraph: bool = ..., | ||
) -> PyDiGraph: ... | ||
def path_graph( | ||
num_nodes: int | None = ..., weights: Sequence[Any] | None = ..., multigraph: bool = ... | ||
) -> PyGraph: ... | ||
def directed_path_graph( | ||
num_nodes: int | None = ..., | ||
weights: Sequence[Any] | None = ..., | ||
bidirectional: bool = ..., | ||
multigraph: bool = ..., | ||
) -> PyDiGraph: ... | ||
def star_graph( | ||
num_nodes: int | None = ..., weights: Sequence[Any] | None = ..., multigraph: bool = ... | ||
) -> PyGraph: ... | ||
def directed_star_graph( | ||
num_nodes: int | None = ..., | ||
weights: Sequence[Any] | None = ..., | ||
inward: bool = ..., | ||
bidirectional: bool = ..., | ||
multigraph: bool = ..., | ||
) -> PyDiGraph: ... | ||
def mesh_graph( | ||
num_nodes: int | None = ..., weights: Sequence[Any] | None = ..., multigraph: bool = ... | ||
) -> PyGraph: ... | ||
def directed_mesh_graph( | ||
num_nodes: int | None = ..., | ||
weights: Sequence[Any] | None = ..., | ||
multigraph: bool = ..., | ||
) -> PyDiGraph: ... | ||
def grid_graph( | ||
rows: int | None = ..., | ||
cols: int | None = ..., | ||
weights: Sequence[Any] | None = ..., | ||
multigraph: bool = ..., | ||
) -> PyGraph: ... | ||
def directed_grid_graph( | ||
rows: int | None = ..., | ||
cols: int | None = ..., | ||
weights: Sequence[Any] | None = ..., | ||
bidirectional: bool = ..., | ||
multigraph: bool = ..., | ||
) -> PyDiGraph: ... | ||
def heavy_square_graph(d: int, multigraph: bool = ...) -> PyGraph: ... | ||
def directed_heavy_square_graph( | ||
d: int, | ||
bidirectional: bool = ..., | ||
multigraph: bool = ..., | ||
) -> PyDiGraph: ... | ||
def heavy_hex_graph(d: int, multigraph: bool = ...) -> PyGraph: ... | ||
def directed_heavy_hex_graph( | ||
d: int, | ||
bidirectional: bool = ..., | ||
multigraph: bool = ..., | ||
) -> PyDiGraph: ... | ||
def binomial_tree_graph( | ||
order: int, weights: Sequence[Any] | None = ..., multigraph: bool = ... | ||
) -> PyGraph: ... | ||
def directed_binomial_tree_graph( | ||
order: int, | ||
weights: Sequence[Any] | None = ..., | ||
bidirectional: bool = ..., | ||
multigraph: bool = ..., | ||
) -> PyDiGraph: ... | ||
def full_rary_tree( | ||
branching_factor: int, | ||
num_nodes: int, | ||
weights: Sequence[Any] | None = ..., | ||
multigraph: bool = ..., | ||
) -> PyGraph: ... | ||
def hexagonal_lattice_graph(rows: int, cols: int, multigraph: bool = ...) -> PyGraph: ... | ||
def directed_hexagonal_lattice_graph( | ||
rows: int, | ||
cols: int, | ||
bidirectional: bool = ..., | ||
multigraph: bool = ..., | ||
) -> PyDiGraph: ... | ||
def lollipop_graph( | ||
num_mesh_nodes: int | None = ..., | ||
num_path_nodes: int | None = ..., | ||
mesh_weights: Sequence[Any] | None = ..., | ||
path_weights: Sequence[Any] | None = ..., | ||
multigraph: bool = ..., | ||
) -> PyGraph: ... | ||
def barbell_graph( | ||
num_mesh_nodes: int | None = ..., | ||
num_path_nodes: int | None = ..., | ||
multigraph: bool = ..., | ||
mesh_weights: Sequence[Any] | None = ..., | ||
path_weights: Sequence[Any] | None = ..., | ||
) -> PyGraph: ... | ||
def generalized_petersen_graph( | ||
n: int, | ||
k: int, | ||
multigraph: bool = ..., | ||
) -> PyGraph: ... | ||
def empty_graph(n: int, multigraph: bool = ...) -> PyGraph: | ||
..., | ||
|
||
def directed_empty_graph(n: int, multigraph: bool = ...) -> PyDiGraph: | ||
..., | ||
|
||
def complete_graph( | ||
num_nodes: int | None = ..., weights: Sequence[Any] | None = ..., multigraph: bool = ... | ||
) -> PyGraph: ... | ||
def directed_complete_graph( | ||
num_nodes: int | None = ..., | ||
weights: Sequence[Any] | None = ..., | ||
multigraph: bool = ..., | ||
) -> PyDiGraph: ... |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +0,0 @@ | ||
partial | ||
This file contains 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
This file contains 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