Skip to content

Commit

Permalink
Remove Optional and Union for new union syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanIsCoding committed Oct 18, 2023
1 parent fc4a939 commit 82c90d6
Show file tree
Hide file tree
Showing 14 changed files with 207 additions and 211 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ exclude = [

[tool.ruff.per-file-ignores]
"rustworkx/__init__.py" = ["F405", "F403"]
"*.pyi" = ["F403", "F405", "PYI001", "UP007"]
"*.pyi" = ["F403", "F405", "PYI001"]

[tool.cibuildwheel]
manylinux-x86_64-image = "manylinux2014"
Expand Down
30 changes: 15 additions & 15 deletions rustworkx/centrality.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@ from .iterators import *
from .graph import PyGraph
from .digraph import PyDiGraph

from typing import Optional, TypeVar, Callable
from typing import TypeVar, Callable

_S = TypeVar("_S")
_T = TypeVar("_T")

def digraph_eigenvector_centrality(
graph: PyDiGraph[_S, _T],
/,
weight_fn: Optional[Callable[[_T], float]] = ...,
weight_fn: Callable[[_T], float] | None = ...,
default_weight: float = ...,
max_iter: int = ...,
tol: float = ...,
) -> CentralityMapping: ...
def graph_eigenvector_centrality(
graph: PyGraph[_S, _T],
/,
weight_fn: Optional[Callable[[_T], float]] = ...,
weight_fn: Callable[[_T], float] | None = ...,
default_weight: float = ...,
max_iter: int = ...,
tol: float = ...,
Expand Down Expand Up @@ -71,20 +71,20 @@ def graph_closeness_centrality(
def digraph_katz_centrality(
graph: PyDiGraph[_S, _T],
/,
alpha: Optional[float] = ...,
beta: Optional[float] = ...,
weight_fn: Optional[Callable[[_T], float]] = ...,
default_weight: Optional[float] = ...,
max_iter: Optional[int] = ...,
tol: Optional[float] = ...,
alpha: float | None = ...,
beta: float | None = ...,
weight_fn: Callable[[_T], float] | None = ...,
default_weight: float | None = ...,
max_iter: int | None = ...,
tol: float | None = ...,
) -> CentralityMapping: ...
def graph_katz_centrality(
graph: PyGraph[_S, _T],
/,
alpha: Optional[float] = ...,
beta: Optional[float] = ...,
weight_fn: Optional[Callable[[_T], float]] = ...,
default_weight: Optional[float] = ...,
max_iter: Optional[int] = ...,
tol: Optional[float] = ...,
alpha: float | None = ...,
beta: float | None = ...,
weight_fn: Callable[[_T], float] | None = ...,
default_weight: float | None = ...,
max_iter: int | None = ...,
tol: float | None = ...,
) -> CentralityMapping: ...
42 changes: 21 additions & 21 deletions rustworkx/connectivity.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ from .iterators import *
from .graph import PyGraph
from .digraph import PyDiGraph

from typing import Optional, TypeVar, Callable, Iterator
from typing import TypeVar, Callable, Iterator

_S = TypeVar("_S")
_T = TypeVar("_T")
Expand All @@ -31,63 +31,63 @@ def weakly_connected_components(graph: PyDiGraph, /) -> list[set[int]]: ...
def digraph_adjacency_matrix(
graph: PyDiGraph[_S, _T],
/,
weight_fn: Optional[Callable[[_T], float]] = ...,
weight_fn: Callable[[_T], float] | None = ...,
default_weight: float = ...,
null_value: float = ...,
parallel_edge: str = ...,
) -> np.ndarray: ...
def graph_adjacency_matrix(
graph: PyGraph[_S, _T],
/,
weight_fn: Optional[Callable[[_T], float]] = ...,
weight_fn: Callable[[_T], float] | None = ...,
default_weight: float = ...,
null_value: float = ...,
parallel_edge: str = ...,
) -> np.ndarray: ...
def cycle_basis(graph: PyGraph, /, root: Optional[int] = ...) -> list[list[int]]: ...
def cycle_basis(graph: PyGraph, /, root: int | None = ...) -> list[list[int]]: ...
def articulation_points(graph: PyGraph, /) -> set[int]: ...
def biconnected_components(graph: PyGraph, /) -> BiconnectedComponents: ...
def chain_decomposition(graph: PyGraph, /, source: Optional[int] = ...) -> Chains: ...
def chain_decomposition(graph: PyGraph, /, source: int | None = ...) -> Chains: ...
def digraph_find_cycle(
graph: PyDiGraph[_S, _T],
/,
source: Optional[int] = ...,
) -> Edgelist: ...
def digraph_complement(graph: PyDiGraph[_S, _T], /) -> PyDiGraph[_S, Optional[_T]]: ...
source: int | None = ...,
) -> EdgeList: ...
def digraph_complement(graph: PyDiGraph[_S, _T], /) -> PyDiGraph[_S, _T | None]: ...
def graph_complement(
graph: PyGraph[_S, _T],
/,
) -> PyGraph[_S, Optional[_T]]: ...
) -> PyGraph[_S, _T | None]: ...
def digraph_all_simple_paths(
graph: PyDiGraph,
origin: int,
to: int,
/,
min_depth: Optional[int] = ...,
cutoff: Optional[int] = ...,
min_depth: int | None = ...,
cutoff: int | None = ...,
) -> list[list[int]]: ...
def graph_all_simple_paths(
graph: PyGraph,
origin: int,
to: int,
/,
min_depth: Optional[int] = ...,
cutoff: Optional[int] = ...,
min_depth: int | None = ...,
cutoff: int | None = ...,
) -> list[list[int]]: ...
def digraph_all_pairs_all_simple_paths(
graph: PyDiGraph,
/,
min_depth: Optional[int] = ...,
cutoff: Optional[int] = ...,
min_depth: int | None = ...,
cutoff: int | None = ...,
) -> AllPairsMultiplePathMapping: ...
def graph_all_pairs_all_simple_paths(
graph: PyGraph,
/,
min_depth: Optional[int] = ...,
cutoff: Optional[int] = ...,
min_depth: int | None = ...,
cutoff: int | None = ...,
) -> AllPairsMultiplePathMapping: ...
def digraph_longest_simple_path(graph: PyDiGraph, /) -> Optional[NodeIndices]: ...
def graph_longest_simple_path(graph: PyGraph, /) -> Optional[NodeIndices]: ...
def digraph_longest_simple_path(graph: PyDiGraph, /) -> NodeIndices | None: ...
def graph_longest_simple_path(graph: PyGraph, /) -> NodeIndices | None: ...
def digraph_core_number(
graph: PyDiGraph,
/,
Expand All @@ -99,6 +99,6 @@ def graph_core_number(
def stoer_wagner_min_cut(
graph: PyGraph[_S, _T],
/,
weight_fn: Optional[Callable[[_T], float]] = ...,
) -> Optional[tuple[float, NodeIndices]]: ...
weight_fn: Callable[[_T], float] | None = ...,
) -> tuple[float, NodeIndices] | None: ...
def simple_cycles(graph: PyDiGraph, /) -> Iterator[NodeIndices]: ...
8 changes: 4 additions & 4 deletions rustworkx/dag_algo.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from .iterators import *
from .digraph import PyDiGraph

from typing import Optional, TypeVar, Callable, Union
from typing import TypeVar, Callable

_S = TypeVar("_S")
_T = TypeVar("_T")
Expand All @@ -27,10 +27,10 @@ def collect_bicolor_runs(
color_fn: Callable[[_T], int],
) -> list[list[_S]]: ...
def dag_longest_path(
graph: PyDiGraph[_S, _T], /, weight_fn: Optional[Callable[[int, int, _T], int]] = ...
graph: PyDiGraph[_S, _T], /, weight_fn: Callable[[int, int, _T], int] | None = ...
) -> NodeIndices: ...
def dag_longest_path_length(
graph: PyDiGraph[_S, _T], /, weight_fn: Optional[Callable[[int, int, _T], int]] = ...
graph: PyDiGraph[_S, _T], /, weight_fn: Callable[[int, int, _T], int] | None = ...
) -> int: ...
def dag_weighted_longest_path(
graph: PyDiGraph[_S, _T],
Expand All @@ -55,4 +55,4 @@ def layers(
first_layer: list[int],
/,
index_output: bool = ...,
) -> Union[list[_S], list[int]]: ...
) -> list[_S] | list[int]: ...
38 changes: 19 additions & 19 deletions rustworkx/isomorphism.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ from .iterators import *
from .graph import PyGraph
from .digraph import PyDiGraph

from typing import Optional, TypeVar, Callable, Iterator
from typing import TypeVar, Callable, Iterator

_S = TypeVar("_S")
_T = TypeVar("_T")
Expand All @@ -22,59 +22,59 @@ def digraph_is_isomorphic(
first: PyDiGraph[_S, _T],
second: PyDiGraph[_S, _T],
/,
node_matcher: Optional[Callable[[_S, _S], bool]] = ...,
edge_matcher: Optional[Callable[[_T, _T], bool]] = ...,
node_matcher: Callable[[_S, _S], bool] | None = ...,
edge_matcher: Callable[[_T, _T], bool] | None = ...,
id_order: bool = ...,
call_limit: Optional[int] = ...,
call_limit: int | None = ...,
) -> bool: ...
def graph_is_isomorphic(
first: PyGraph[_S, _T],
second: PyGraph[_S, _T],
/,
node_matcher: Optional[Callable[[_S, _S], bool]] = ...,
edge_matcher: Optional[Callable[[_T, _T], bool]] = ...,
node_matcher: Callable[[_S, _S], bool] | None = ...,
edge_matcher: Callable[[_T, _T], bool] | None = ...,
id_order: bool = ...,
call_limit: Optional[int] = ...,
call_limit: int | None = ...,
) -> bool: ...
def digraph_is_subgraph_isomorphic(
first: PyDiGraph[_S, _T],
second: PyDiGraph[_S, _T],
/,
node_matcher: Optional[Callable[[_S, _S], bool]] = ...,
edge_matcher: Optional[Callable[[_T, _T], bool]] = ...,
node_matcher: Callable[[_S, _S], bool] | None = ...,
edge_matcher: Callable[[_T, _T], bool] | None = ...,
id_order: bool = ...,
induced: bool = ...,
call_limit: Optional[int] = ...,
call_limit: int | None = ...,
) -> bool: ...
def graph_is_subgraph_isomorphic(
first: PyGraph[_S, _T],
second: PyGraph[_S, _T],
/,
node_matcher: Optional[Callable[[_S, _S], bool]] = ...,
edge_matcher: Optional[Callable[[_T, _T], bool]] = ...,
node_matcher: Callable[[_S, _S], bool] | None = ...,
edge_matcher: Callable[[_T, _T], bool] | None = ...,
id_order: bool = ...,
induced: bool = ...,
call_limit: Optional[int] = ...,
call_limit: int | None = ...,
) -> bool: ...
def digraph_vf2_mapping(
first: PyDiGraph[_S, _T],
second: PyDiGraph[_S, _T],
/,
node_matcher: Optional[Callable[[_S, _S], bool]] = ...,
edge_matcher: Optional[Callable[[_T, _T], bool]] = ...,
node_matcher: Callable[[_S, _S], bool] | None = ...,
edge_matcher: Callable[[_T, _T], bool] | None = ...,
id_order: bool = ...,
subgraph: bool = ...,
induced: bool = ...,
call_limit: Optional[int] = ...,
call_limit: int | None = ...,
) -> Iterator[NodeMap]: ...
def graph_vf2_mapping(
first: PyGraph[_S, _T],
second: PyGraph[_S, _T],
/,
node_matcher: Optional[Callable[[_S, _S], bool]] = ...,
edge_matcher: Optional[Callable[[_T, _T], bool]] = ...,
node_matcher: Callable[[_S, _S], bool] | None = ...,
edge_matcher: Callable[[_T, _T], bool] | None = ...,
id_order: bool = ...,
subgraph: bool = ...,
induced: bool = ...,
call_limit: Optional[int] = ...,
call_limit: int | None = ...,
) -> Iterator[NodeMap]: ...
Loading

0 comments on commit 82c90d6

Please sign in to comment.