From 108d6a1bc088fdd40a32d8295a76c494784b27da Mon Sep 17 00:00:00 2001 From: Matthew Treinish Date: Wed, 31 May 2023 15:42:00 -0400 Subject: [PATCH 1/2] Bump pyo3 and rust numpy version to 0.19.0 Pyo3 0.19.0 and rust-numpy 0.19.0 were just released. This commit updates the version used in rustworkx to these latest releases. At the same time this updates usage of text signature for classes that was deprecated in 0.19.0 release. While not fatal for normal builds this would have failed clippy in CI because we treat warnings as errors. --- Cargo.lock | 30 +++++++++++++++--------------- Cargo.toml | 4 ++-- src/digraph.rs | 3 +-- src/graph.rs | 3 +-- src/toposort.rs | 3 +-- 5 files changed, 20 insertions(+), 23 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e0ed61b78f..14bbda7640 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -228,9 +228,9 @@ dependencies = [ [[package]] name = "memoffset" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d61c719bcfbcf5d62b3a09efa6088de8c54bc0bfcd3ea7ae39fcc186108b8de1" +checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" dependencies = [ "autocfg", ] @@ -335,9 +335,9 @@ dependencies = [ [[package]] name = "numpy" -version = "0.18.0" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96b0fee4571867d318651c24f4a570c3f18408cf95f16ccb576b3ce85496a46e" +checksum = "437213adf41bbccf4aeae535fbfcdad0f6fed241e1ae182ebe97fa1f3ce19389" dependencies = [ "libc", "ndarray", @@ -414,16 +414,16 @@ dependencies = [ [[package]] name = "pyo3" -version = "0.18.3" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3b1ac5b3731ba34fdaa9785f8d74d17448cd18f30cf19e0c7e7b1fdb5272109" +checksum = "cffef52f74ec3b1a1baf295d9b8fcc3070327aefc39a6d00656b13c1d0b8885c" dependencies = [ "cfg-if", "hashbrown", "indexmap", "indoc", "libc", - "memoffset 0.8.0", + "memoffset 0.9.0", "num-bigint", "num-complex 0.4.3", "parking_lot", @@ -435,9 +435,9 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.18.3" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cb946f5ac61bb61a5014924910d936ebd2b23b705f7a4a3c40b05c720b079a3" +checksum = "713eccf888fb05f1a96eb78c0dbc51907fee42b3377272dc902eb38985f418d5" dependencies = [ "once_cell", "target-lexicon", @@ -445,9 +445,9 @@ dependencies = [ [[package]] name = "pyo3-ffi" -version = "0.18.3" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd4d7c5337821916ea2a1d21d1092e8443cf34879e53a0ac653fbb98f44ff65c" +checksum = "5b2ecbdcfb01cbbf56e179ce969a048fd7305a66d4cdf3303e0da09d69afe4c3" dependencies = [ "libc", "pyo3-build-config", @@ -455,9 +455,9 @@ dependencies = [ [[package]] name = "pyo3-macros" -version = "0.18.3" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9d39c55dab3fc5a4b25bbd1ac10a2da452c4aca13bb450f22818a002e29648d" +checksum = "b78fdc0899f2ea781c463679b20cb08af9247febc8d052de941951024cd8aea0" dependencies = [ "proc-macro2", "pyo3-macros-backend", @@ -467,9 +467,9 @@ dependencies = [ [[package]] name = "pyo3-macros-backend" -version = "0.18.3" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97daff08a4c48320587b5224cc98d609e3c27b6d437315bd40b605c98eeb5918" +checksum = "60da7b84f1227c3e2fe7593505de274dcf4c8928b4e0a1c23d551a14e4e80a0f" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 0a7fafa3de..7894eecfd9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,7 @@ crate-type = ["cdylib"] ahash = "0.8.0" petgraph = "0.6.3" fixedbitset = "0.4.2" -numpy = "0.18.0" +numpy = "0.19.0" rand = "0.8" rand_pcg = "0.3" rayon = "1.6" @@ -36,7 +36,7 @@ serde_json = "1.0" rustworkx-core = { path = "rustworkx-core", version = "=0.13.0" } [dependencies.pyo3] -version = "0.18.3" +version = "0.19.0" features = ["extension-module", "hashbrown", "num-bigint", "num-complex", "indexmap"] [dependencies.hashbrown] diff --git a/src/digraph.rs b/src/digraph.rs index a0d63b09c0..353da8504b 100644 --- a/src/digraph.rs +++ b/src/digraph.rs @@ -173,7 +173,6 @@ use super::dag_algo::is_directed_acyclic_graph; /// :attr:`~.PyDiGraph.attrs` attribute. This can be any Python object. If /// it is not specified :attr:`~.PyDiGraph.attrs` will be set to ``None``. #[pyclass(mapping, module = "rustworkx", subclass)] -#[pyo3(text_signature = "(/, check_cycle=False, multigraph=True, attrs=None)")] #[derive(Clone)] pub struct PyDiGraph { pub graph: StablePyGraph, @@ -285,7 +284,7 @@ impl PyDiGraph { #[pymethods] impl PyDiGraph { #[new] - #[pyo3(signature=(check_cycle=false, multigraph=true, attrs=None))] + #[pyo3(signature=(check_cycle=false, multigraph=true, attrs=None), text_signature="(/, check_cycle=False, multigraph=True, attrs=None)")] fn new(py: Python, check_cycle: bool, multigraph: bool, attrs: Option) -> Self { PyDiGraph { graph: StablePyGraph::::new(), diff --git a/src/graph.rs b/src/graph.rs index d57fbb3215..75165cc4c1 100644 --- a/src/graph.rs +++ b/src/graph.rs @@ -136,7 +136,6 @@ use petgraph::visit::{ /// :attr:`~.PyGraph.attrs` attribute. This can be any Python object. If /// it is not specified :attr:`~.PyGraph.attrs` will be set to ``None``. #[pyclass(mapping, module = "rustworkx", subclass)] -#[pyo3(text_signature = "(/, multigraph=True, attrs=None)")] #[derive(Clone)] pub struct PyGraph { pub graph: StablePyGraph, @@ -181,7 +180,7 @@ impl PyGraph { #[pymethods] impl PyGraph { #[new] - #[pyo3(signature=(multigraph=true, attrs=None))] + #[pyo3(signature=(multigraph=true, attrs=None), text_signature = "(/, multigraph=True, attrs=None)")] fn new(py: Python, multigraph: bool, attrs: Option) -> Self { PyGraph { graph: StablePyGraph::::default(), diff --git a/src/toposort.rs b/src/toposort.rs index 7dcb1932a5..e91b45314a 100644 --- a/src/toposort.rs +++ b/src/toposort.rs @@ -62,7 +62,6 @@ enum NodeState { /// it's set to ``False``, topological sorter will output as many nodes /// as possible until cycles block more progress. By default is ``True``. #[pyclass(module = "rustworkx")] -#[pyo3(text_signature = "(graph, /, check_cycle=True)")] pub struct TopologicalSorter { dag: Py, ready_nodes: Vec, @@ -75,7 +74,7 @@ pub struct TopologicalSorter { #[pymethods] impl TopologicalSorter { #[new] - #[pyo3(signature=(dag, check_cycle=true))] + #[pyo3(signature=(dag, check_cycle=true), text_signature = "(graph, /, check_cycle=True)")] fn new(py: Python, dag: Py, check_cycle: bool) -> PyResult { { let dag = &dag.borrow(py); From 72d7ca1b014277d48feff358ae2b217d52c1635a Mon Sep 17 00:00:00 2001 From: Matthew Treinish Date: Thu, 1 Jun 2023 07:42:41 -0400 Subject: [PATCH 2/2] Make _dt optional in iterators --- rustworkx/iterators.pyi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rustworkx/iterators.pyi b/rustworkx/iterators.pyi index 81840d84ba..e0d32c2f80 100644 --- a/rustworkx/iterators.pyi +++ b/rustworkx/iterators.pyi @@ -23,6 +23,7 @@ from typing import ( Tuple, overload, final, + Optional, ) from abc import ABC from collections.abc import Sequence @@ -68,7 +69,7 @@ class RustworkxCustomVecIter(Generic[T_co], Sequence[T_co], ABC): def __len__(self) -> int: ... def __ne__(self, other: object) -> bool: ... def __setstate__(self, state: Sequence[T_co]) -> None: ... - def __array__(self, _dt: np.dtype = ...) -> np.ndarray: ... + def __array__(self, _dt: Optional[np.dtype] = ...) -> np.ndarray: ... class RustworkxCustomHashMapIter(Generic[S, T_co], Mapping[S, T_co], ABC): def __init__(self) -> None: ...