From 4471c4c10e2d48b8b0a9103fe84f66cde131819e Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Thu, 9 Mar 2023 11:55:39 -0500 Subject: [PATCH 001/241] Subset and superset --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/lib.rs | 10 +++++++++- tests/test_hash_trie_set.py | 11 ++++++++++- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 20e0e06..bc69793 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -187,7 +187,7 @@ dependencies = [ [[package]] name = "rpds-py" -version = "0.6.0" +version = "0.6.1" dependencies = [ "pyo3", "rpds", diff --git a/Cargo.toml b/Cargo.toml index d0d7924..122a35b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rpds-py" -version = "0.6.0" +version = "0.6.1" edition = "2021" [lib] diff --git a/src/lib.rs b/src/lib.rs index d69bd1e..c6db530 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -272,6 +272,10 @@ impl<'source> FromPyObject<'source> for HashTrieSetPy { } } +fn is_subset(one: &HashTrieSet, two: &HashTrieSet) -> bool { + one.iter().all(|v| two.contains(v)) +} + #[pymethods] impl HashTrieSetPy { #[new] @@ -331,11 +335,15 @@ impl HashTrieSetPy { fn __richcmp__(&self, other: &Self, op: CompareOp, py: Python<'_>) -> PyResult { match op { CompareOp::Eq => Ok((self.inner.size() == other.inner.size() - && self.inner.iter().all(|k| other.inner.contains(k))) + && is_subset(&self.inner, &other.inner)) .into_py(py)), CompareOp::Ne => Ok((self.inner.size() != other.inner.size() || self.inner.iter().any(|k| !other.inner.contains(k))) .into_py(py)), + CompareOp::Lt => Ok((self.inner.size() < other.inner.size() + && is_subset(&self.inner, &other.inner)) + .into_py(py)), + CompareOp::Le => Ok(is_subset(&self.inner, &other.inner).into_py(py)), _ => Ok(py.NotImplemented()), } } diff --git a/tests/test_hash_trie_set.py b/tests/test_hash_trie_set.py index 39a9be3..0816765 100644 --- a/tests/test_hash_trie_set.py +++ b/tests/test_hash_trie_set.py @@ -112,7 +112,6 @@ def test_supports_set_operations(): assert s1.symmetric_difference(s2) == s1 ^ s2 -@pytest.mark.xfail(reason="Can't figure out inheriting collections.abc yet") def test_supports_set_comparisons(): s1 = HashTrieSet([1, 2, 3]) s3 = HashTrieSet([1, 2]) @@ -171,3 +170,13 @@ def test_more_eq(): assert not (HashTrieSet([o, o]) != HashTrieSet([o, o])) assert not (HashTrieSet([o]) != HashTrieSet([o, o])) assert not (HashTrieSet() != HashTrieSet([])) + + +def test_more_set_comparisons(): + s = HashTrieSet([1, 2, 3]) + + assert s == s + assert not (s < s) + assert s <= s + assert not (s > s) + assert s >= s From 91fac5bd7dcd56e576b111a981acaa7327b070f1 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Mon, 20 Mar 2023 11:55:47 -0400 Subject: [PATCH 002/241] Use the threadsafe rpds structures by default. We should probably have separate APIs to expose each (of course there are already lots of things missing from these bindings) but for now doing this doesn't seem to have a huge performance impact from simple microbenchmarks, whereas without this, you can't share a global Python HashTrieMap across multiple threads at all. --- Cargo.lock | 14 ++++++++++++-- Cargo.toml | 3 ++- src/lib.rs | 50 ++++++++++++++++++++++++++------------------------ 3 files changed, 40 insertions(+), 27 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bc69793..df9ac19 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11,6 +11,15 @@ dependencies = [ "static_assertions", ] +[[package]] +name = "archery" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6cd774058b1b415c4855d8b86436c04bf050c003156fe24bc326fb3fe75c343" +dependencies = [ + "static_assertions", +] + [[package]] name = "autocfg" version = "1.1.0" @@ -182,13 +191,14 @@ version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "66262ea963eff99163e6b741fbc3417a52cc13074728c1047e9911789df9b000" dependencies = [ - "archery", + "archery 0.4.0", ] [[package]] name = "rpds-py" -version = "0.6.1" +version = "0.7.0" dependencies = [ + "archery 0.5.0", "pyo3", "rpds", ] diff --git a/Cargo.toml b/Cargo.toml index 122a35b..67fb05b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rpds-py" -version = "0.6.1" +version = "0.7.0" edition = "2021" [lib] @@ -9,6 +9,7 @@ crate-type = ["cdylib"] [dependencies] rpds = "0.12.0" +archery = "0.5.0" [dependencies.pyo3] version = "0.18.1" diff --git a/src/lib.rs b/src/lib.rs index c6db530..1c164b4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,7 +6,7 @@ use pyo3::pyclass::CompareOp; use pyo3::types::{PyDict, PyIterator, PyTuple, PyType}; use pyo3::{exceptions::PyKeyError, types::PyMapping}; use pyo3::{prelude::*, AsPyPointer}; -use rpds::{HashTrieMap, HashTrieSet, List}; +use rpds::{HashTrieMap, HashTrieMapSync, HashTrieSet, HashTrieSetSync, List, ListSync}; #[derive(Clone, Debug)] struct Key { @@ -55,20 +55,20 @@ impl<'source> FromPyObject<'source> for Key { } #[repr(transparent)] -#[pyclass(name = "HashTrieMap", module = "rpds", frozen, mapping, unsendable)] +#[pyclass(name = "HashTrieMap", module = "rpds", frozen, mapping)] struct HashTrieMapPy { - inner: HashTrieMap, + inner: HashTrieMapSync, } -impl From> for HashTrieMapPy { - fn from(map: HashTrieMap) -> Self { +impl From> for HashTrieMapPy { + fn from(map: HashTrieMapSync) -> Self { HashTrieMapPy { inner: map } } } impl<'source> FromPyObject<'source> for HashTrieMapPy { fn extract(ob: &'source PyAny) -> PyResult { - let mut ret = HashTrieMap::new(); + let mut ret = HashTrieMap::new_sync(); if let Ok(mapping) = ob.downcast::() { for each in mapping.items()?.iter()? { let (k, v): (Key, PyObject) = each?.extract()?; @@ -94,7 +94,7 @@ impl HashTrieMapPy { map = value; } else { map = HashTrieMapPy { - inner: HashTrieMap::new(), + inner: HashTrieMap::new_sync(), }; } if let Some(kwds) = kwds { @@ -239,7 +239,7 @@ impl HashTrieMapPy { } } -#[pyclass(module = "rpds", unsendable)] +#[pyclass(module = "rpds")] struct KeyIterator { inner: IntoIter, } @@ -256,14 +256,14 @@ impl KeyIterator { } #[repr(transparent)] -#[pyclass(name = "HashTrieSet", module = "rpds", frozen, unsendable)] +#[pyclass(name = "HashTrieSet", module = "rpds", frozen)] struct HashTrieSetPy { - inner: HashTrieSet, + inner: HashTrieSetSync, } impl<'source> FromPyObject<'source> for HashTrieSetPy { fn extract(ob: &'source PyAny) -> PyResult { - let mut ret = HashTrieSet::new(); + let mut ret = HashTrieSet::new_sync(); for each in ob.iter()? { let k: Key = each?.extract()?; ret.insert_mut(k); @@ -272,7 +272,7 @@ impl<'source> FromPyObject<'source> for HashTrieSetPy { } } -fn is_subset(one: &HashTrieSet, two: &HashTrieSet) -> bool { +fn is_subset(one: &HashTrieSetSync, two: &HashTrieSetSync) -> bool { one.iter().all(|v| two.contains(v)) } @@ -284,7 +284,7 @@ impl HashTrieSetPy { value } else { HashTrieSetPy { - inner: HashTrieSet::new(), + inner: HashTrieSet::new_sync(), } } } @@ -383,8 +383,8 @@ impl HashTrieSetPy { } fn intersection(&self, other: &Self) -> HashTrieSetPy { - let mut inner: HashTrieSet = HashTrieSet::new(); - let larger: &HashTrieSet; + let mut inner: HashTrieSetSync = HashTrieSet::new_sync(); + let larger: &HashTrieSetSync; let iter; if self.inner.size() > other.inner.size() { larger = &self.inner; @@ -402,7 +402,7 @@ impl HashTrieSetPy { } fn symmetric_difference(&self, other: &Self) -> HashTrieSetPy { - let mut inner: HashTrieSet; + let mut inner: HashTrieSetSync; let iter; if self.inner.size() > other.inner.size() { inner = self.inner.clone(); @@ -422,7 +422,7 @@ impl HashTrieSetPy { } fn union(&self, other: &Self) -> HashTrieSetPy { - let mut inner: HashTrieSet; + let mut inner: HashTrieSetSync; let iter; if self.inner.size() > other.inner.size() { inner = self.inner.clone(); @@ -451,20 +451,20 @@ impl HashTrieSetPy { } #[repr(transparent)] -#[pyclass(name = "List", module = "rpds", frozen, sequence, unsendable)] +#[pyclass(name = "List", module = "rpds", frozen, sequence)] struct ListPy { - inner: List, + inner: ListSync, } -impl From> for ListPy { - fn from(elements: List) -> Self { +impl From> for ListPy { + fn from(elements: ListSync) -> Self { ListPy { inner: elements } } } impl<'source> FromPyObject<'source> for ListPy { fn extract(ob: &'source PyAny) -> PyResult { - let mut ret = List::new(); + let mut ret = List::new_sync(); let reversed = PyModule::import(ob.py(), "builtins")?.getattr("reversed")?; let rob: &PyIterator = reversed.call1((ob,))?.iter()?; for each in rob { @@ -483,7 +483,9 @@ impl ListPy { if elements.len() == 1 { ret = elements.get_item(0)?.extract()?; } else { - ret = ListPy { inner: List::new() }; + ret = ListPy { + inner: List::new_sync(), + }; if elements.len() > 1 { for each in (0..elements.len()).rev() { ret.inner @@ -567,7 +569,7 @@ impl ListPy { } } -#[pyclass(module = "rpds", unsendable)] +#[pyclass(module = "rpds")] struct ListIterator { inner: IntoIter, } From 1b8ddef111558b5e3db2f2daa2ff153a782716d3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 Mar 2023 19:10:24 +0000 Subject: [PATCH 003/241] Bump rpds from 0.12.0 to 0.13.0 Bumps [rpds](https://github.com/orium/rpds) from 0.12.0 to 0.13.0. - [Release notes](https://github.com/orium/rpds/releases) - [Changelog](https://github.com/orium/rpds/blob/master/release-notes.md) - [Commits](https://github.com/orium/rpds/compare/v0.12.0...v0.13.0) --- updated-dependencies: - dependency-name: rpds dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Cargo.lock | 17 ++++------------- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index df9ac19..87b58dc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,15 +2,6 @@ # It is not intended for manual editing. version = 3 -[[package]] -name = "archery" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a8da9bc4c4053ee067669762bcaeea6e241841295a2b6c948312dad6ef4cc02" -dependencies = [ - "static_assertions", -] - [[package]] name = "archery" version = "0.5.0" @@ -187,18 +178,18 @@ dependencies = [ [[package]] name = "rpds" -version = "0.12.0" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66262ea963eff99163e6b741fbc3417a52cc13074728c1047e9911789df9b000" +checksum = "9bd6ce569b15c331b1e5fd8cf6adb0bf240678b5f0cdc4d0f41e11683f6feba9" dependencies = [ - "archery 0.4.0", + "archery", ] [[package]] name = "rpds-py" version = "0.7.0" dependencies = [ - "archery 0.5.0", + "archery", "pyo3", "rpds", ] diff --git a/Cargo.toml b/Cargo.toml index 67fb05b..639cf93 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ name = "rpds" crate-type = ["cdylib"] [dependencies] -rpds = "0.12.0" +rpds = "0.13.0" archery = "0.5.0" [dependencies.pyo3] From bb7264c86e006b74b30c10436913ae4616e5cb76 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Mon, 20 Mar 2023 15:25:11 -0400 Subject: [PATCH 004/241] Do a release for rpds 0.13.0 --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 87b58dc..7d04ace 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -187,7 +187,7 @@ dependencies = [ [[package]] name = "rpds-py" -version = "0.7.0" +version = "0.7.1" dependencies = [ "archery", "pyo3", diff --git a/Cargo.toml b/Cargo.toml index 639cf93..1cfff42 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rpds-py" -version = "0.7.0" +version = "0.7.1" edition = "2021" [lib] From 36fd1b9eb7496d3c9ae9c88cfdce7d9c405b8229 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Sat, 25 Mar 2023 17:32:51 -0400 Subject: [PATCH 005/241] Exclude bots from release notes. --- .github/release.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .github/release.yml diff --git a/.github/release.yml b/.github/release.yml new file mode 100644 index 0000000..9d1e098 --- /dev/null +++ b/.github/release.yml @@ -0,0 +1,5 @@ +changelog: + exclude: + authors: + - dependabot + - pre-commit-ci From 740dd9394d85ea2ea607481fb20938059b19c9e5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 Mar 2023 19:04:50 +0000 Subject: [PATCH 006/241] Bump pyo3 from 0.18.1 to 0.18.2 Bumps [pyo3](https://github.com/pyo3/pyo3) from 0.18.1 to 0.18.2. - [Release notes](https://github.com/pyo3/pyo3/releases) - [Changelog](https://github.com/PyO3/pyo3/blob/main/CHANGELOG.md) - [Commits](https://github.com/pyo3/pyo3/compare/v0.18.1...v0.18.2) --- updated-dependencies: - dependency-name: pyo3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 20 ++++++++++---------- Cargo.toml | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7d04ace..3a7c1d2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -100,9 +100,9 @@ dependencies = [ [[package]] name = "pyo3" -version = "0.18.1" +version = "0.18.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06a3d8e8a46ab2738109347433cb7b96dffda2e4a218b03ef27090238886b147" +checksum = "cfb848f80438f926a9ebddf0a539ed6065434fd7aae03a89312a9821f81b8501" dependencies = [ "cfg-if", "indoc", @@ -117,9 +117,9 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.18.1" +version = "0.18.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75439f995d07ddfad42b192dfcf3bc66a7ecfd8b4a1f5f6f046aa5c2c5d7677d" +checksum = "98a42e7f42e917ce6664c832d5eee481ad514c98250c49e0b03b20593e2c7ed0" dependencies = [ "once_cell", "target-lexicon", @@ -127,9 +127,9 @@ dependencies = [ [[package]] name = "pyo3-ffi" -version = "0.18.1" +version = "0.18.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "839526a5c07a17ff44823679b68add4a58004de00512a95b6c1c98a6dcac0ee5" +checksum = "a0707f0ab26826fe4ccd59b69106e9df5e12d097457c7b8f9c0fd1d2743eec4d" dependencies = [ "libc", "pyo3-build-config", @@ -137,9 +137,9 @@ dependencies = [ [[package]] name = "pyo3-macros" -version = "0.18.1" +version = "0.18.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd44cf207476c6a9760c4653559be4f206efafb924d3e4cbf2721475fc0d6cc5" +checksum = "978d18e61465ecd389e1f235ff5a467146dc4e3c3968b90d274fe73a5dd4a438" dependencies = [ "proc-macro2", "pyo3-macros-backend", @@ -149,9 +149,9 @@ dependencies = [ [[package]] name = "pyo3-macros-backend" -version = "0.18.1" +version = "0.18.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc1f43d8e30460f36350d18631ccf85ded64c059829208fe680904c65bcd0a4c" +checksum = "8e0e1128f85ce3fca66e435e08aa2089a2689c1c48ce97803e13f63124058462" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 1cfff42..48cd77f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,5 +12,5 @@ rpds = "0.13.0" archery = "0.5.0" [dependencies.pyo3] -version = "0.18.1" +version = "0.18.2" features = ["abi3-py38"] From 7babfd257b6d1f70cf4ae108678657d3cee15fa4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Apr 2023 19:04:33 +0000 Subject: [PATCH 007/241] Bump pyo3 from 0.18.2 to 0.18.3 Bumps [pyo3](https://github.com/pyo3/pyo3) from 0.18.2 to 0.18.3. - [Release notes](https://github.com/pyo3/pyo3/releases) - [Changelog](https://github.com/PyO3/pyo3/blob/main/CHANGELOG.md) - [Commits](https://github.com/pyo3/pyo3/compare/v0.18.2...v0.18.3) --- updated-dependencies: - dependency-name: pyo3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 20 ++++++++++---------- Cargo.toml | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3a7c1d2..bf11c94 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -100,9 +100,9 @@ dependencies = [ [[package]] name = "pyo3" -version = "0.18.2" +version = "0.18.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfb848f80438f926a9ebddf0a539ed6065434fd7aae03a89312a9821f81b8501" +checksum = "e3b1ac5b3731ba34fdaa9785f8d74d17448cd18f30cf19e0c7e7b1fdb5272109" dependencies = [ "cfg-if", "indoc", @@ -117,9 +117,9 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.18.2" +version = "0.18.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98a42e7f42e917ce6664c832d5eee481ad514c98250c49e0b03b20593e2c7ed0" +checksum = "9cb946f5ac61bb61a5014924910d936ebd2b23b705f7a4a3c40b05c720b079a3" dependencies = [ "once_cell", "target-lexicon", @@ -127,9 +127,9 @@ dependencies = [ [[package]] name = "pyo3-ffi" -version = "0.18.2" +version = "0.18.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0707f0ab26826fe4ccd59b69106e9df5e12d097457c7b8f9c0fd1d2743eec4d" +checksum = "fd4d7c5337821916ea2a1d21d1092e8443cf34879e53a0ac653fbb98f44ff65c" dependencies = [ "libc", "pyo3-build-config", @@ -137,9 +137,9 @@ dependencies = [ [[package]] name = "pyo3-macros" -version = "0.18.2" +version = "0.18.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978d18e61465ecd389e1f235ff5a467146dc4e3c3968b90d274fe73a5dd4a438" +checksum = "a9d39c55dab3fc5a4b25bbd1ac10a2da452c4aca13bb450f22818a002e29648d" dependencies = [ "proc-macro2", "pyo3-macros-backend", @@ -149,9 +149,9 @@ dependencies = [ [[package]] name = "pyo3-macros-backend" -version = "0.18.2" +version = "0.18.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e0e1128f85ce3fca66e435e08aa2089a2689c1c48ce97803e13f63124058462" +checksum = "97daff08a4c48320587b5224cc98d609e3c27b6d437315bd40b605c98eeb5918" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 48cd77f..fa7ee4f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,5 +12,5 @@ rpds = "0.13.0" archery = "0.5.0" [dependencies.pyo3] -version = "0.18.2" +version = "0.18.3" features = ["abi3-py38"] From e44e36ae30505f51d9af1cff4fb2664cc2d3ed8c Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Mon, 17 Apr 2023 15:32:59 -0400 Subject: [PATCH 008/241] Update pre-commit hooks. --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7f80ec6..77c6ea5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -29,12 +29,12 @@ repos: hooks: - id: pyupgrade - repo: https://github.com/psf/black - rev: 23.1.0 + rev: 23.3.0 hooks: - name: black id: black args: ["--line-length", "79"] - repo: https://github.com/pre-commit/mirrors-prettier - rev: "v3.0.0-alpha.4" + rev: "v3.0.0-alpha.6" hooks: - id: prettier From 04a0cfe2949ff9f53f9671d83e02301a2495f8cd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Apr 2023 19:05:01 +0000 Subject: [PATCH 009/241] Bump wntrblm/nox from 2022.11.21 to 2023.04.22 Bumps [wntrblm/nox](https://github.com/wntrblm/nox) from 2022.11.21 to 2023.04.22. - [Release notes](https://github.com/wntrblm/nox/releases) - [Changelog](https://github.com/wntrblm/nox/blob/main/CHANGELOG.md) - [Commits](https://github.com/wntrblm/nox/compare/2022.11.21...2023.04.22) --- updated-dependencies: - dependency-name: wntrblm/nox dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- .github/workflows/CI.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 456423f..7ef5b9f 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -34,7 +34,7 @@ jobs: steps: - uses: actions/checkout@v3 - name: Set up nox - uses: wntrblm/nox@2022.11.21 + uses: wntrblm/nox@2023.04.22 - id: noxenvs-matrix run: | echo >>$GITHUB_OUTPUT noxenvs=$( @@ -65,7 +65,7 @@ jobs: with: python-version: "3.x" - name: Set up nox - uses: wntrblm/nox@2022.11.21 + uses: wntrblm/nox@2023.04.22 - name: Run nox run: nox -s "${{ matrix.noxenv }}" From 01e9337e58e4c002d8a7b10f04efd9c754e27c5d Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Wed, 5 Jul 2023 16:14:31 +0200 Subject: [PATCH 010/241] Bump pre-commit. --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 77c6ea5..73a5721 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -25,7 +25,7 @@ repos: hooks: - id: flake8 - repo: https://github.com/asottile/pyupgrade - rev: v3.3.1 + rev: v3.8.0 hooks: - id: pyupgrade - repo: https://github.com/psf/black @@ -35,6 +35,6 @@ repos: id: black args: ["--line-length", "79"] - repo: https://github.com/pre-commit/mirrors-prettier - rev: "v3.0.0-alpha.6" + rev: "v3.0.0-alpha.9-for-vscode" hooks: - id: prettier From 3eeb532586817958a7c263be2518cf2f1e7d2170 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Wed, 5 Jul 2023 16:33:33 +0200 Subject: [PATCH 011/241] Bump to PyO3 v0.19 --- Cargo.lock | 24 ++++++++++++------------ Cargo.toml | 4 ++-- pyproject.toml | 2 +- src/lib.rs | 2 +- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bf11c94..6e66472 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -53,9 +53,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", ] @@ -100,9 +100,9 @@ dependencies = [ [[package]] name = "pyo3" -version = "0.18.3" +version = "0.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3b1ac5b3731ba34fdaa9785f8d74d17448cd18f30cf19e0c7e7b1fdb5272109" +checksum = "ffb88ae05f306b4bfcde40ac4a51dc0b05936a9207a4b75b798c7729c4258a59" dependencies = [ "cfg-if", "indoc", @@ -117,9 +117,9 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.18.3" +version = "0.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cb946f5ac61bb61a5014924910d936ebd2b23b705f7a4a3c40b05c720b079a3" +checksum = "554db24f0b3c180a9c0b1268f91287ab3f17c162e15b54caaae5a6b3773396b0" dependencies = [ "once_cell", "target-lexicon", @@ -127,9 +127,9 @@ dependencies = [ [[package]] name = "pyo3-ffi" -version = "0.18.3" +version = "0.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd4d7c5337821916ea2a1d21d1092e8443cf34879e53a0ac653fbb98f44ff65c" +checksum = "922ede8759e8600ad4da3195ae41259654b9c55da4f7eec84a0ccc7d067a70a4" dependencies = [ "libc", "pyo3-build-config", @@ -137,9 +137,9 @@ dependencies = [ [[package]] name = "pyo3-macros" -version = "0.18.3" +version = "0.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9d39c55dab3fc5a4b25bbd1ac10a2da452c4aca13bb450f22818a002e29648d" +checksum = "8a5caec6a1dd355964a841fcbeeb1b89fe4146c87295573f94228911af3cc5a2" dependencies = [ "proc-macro2", "pyo3-macros-backend", @@ -149,9 +149,9 @@ dependencies = [ [[package]] name = "pyo3-macros-backend" -version = "0.18.3" +version = "0.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97daff08a4c48320587b5224cc98d609e3c27b6d437315bd40b605c98eeb5918" +checksum = "e0b78ccbb160db1556cdb6fd96c50334c5d4ec44dc5e0a968d0a1208fa0efa8b" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index fa7ee4f..3b7ccec 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,5 +12,5 @@ rpds = "0.13.0" archery = "0.5.0" [dependencies.pyo3] -version = "0.18.3" -features = ["abi3-py38"] +version = "0.19.1" +features = ["extension-module"] diff --git a/pyproject.toml b/pyproject.toml index 093d402..dfb05ca 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["maturin>=0.14,<0.15"] +requires = ["maturin>=1.0,<2.0"] build-backend = "maturin" [project] diff --git a/src/lib.rs b/src/lib.rs index 1c164b4..4de113c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -169,7 +169,7 @@ impl HashTrieMapPy { #[classmethod] fn convert(_cls: &PyType, value: &PyAny, py: Python) -> PyResult { - if value.is_instance_of::()? { + if value.is_instance_of::() { Ok(value.into()) } else { Ok(HashTrieMapPy::extract(value)?.into_py(py)) From 5de7a1908eb19c0ee1ed8164b947ba70da792318 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Wed, 5 Jul 2023 16:38:47 +0200 Subject: [PATCH 012/241] Add rpds to known_first_party for isort. I don't know why behavior differs between CI and locally (locally nothing changes previously when running pre-commit, whereas in CI things fail...). Maybe the actual name of the directory (which locally I have called rpds.py) is what matters or something. But I don't care to find out, this seems to explicitly make things work. --- pyproject.toml | 1 + tests/test_hash_trie_map.py | 3 ++- tests/test_hash_trie_set.py | 3 ++- tests/test_list.py | 3 ++- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index dfb05ca..71e08f4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,6 +34,7 @@ combine_as_imports = true from_first = true include_trailing_comma = true multi_line_output = 3 +known_first_party = ["rpds"] [tool.maturin] features = ["pyo3/extension-module"] diff --git a/tests/test_hash_trie_map.py b/tests/test_hash_trie_map.py index e10fa4a..790662e 100644 --- a/tests/test_hash_trie_map.py +++ b/tests/test_hash_trie_map.py @@ -28,9 +28,10 @@ """ from collections.abc import Hashable, Mapping -from rpds import HashTrieMap import pytest +from rpds import HashTrieMap + HASH_MSG = "Not sure HashTrieMap implements Hash, it has mutable methods" diff --git a/tests/test_hash_trie_set.py b/tests/test_hash_trie_set.py index 0816765..d6dc970 100644 --- a/tests/test_hash_trie_set.py +++ b/tests/test_hash_trie_set.py @@ -26,9 +26,10 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ -from rpds import HashTrieSet import pytest +from rpds import HashTrieSet + HASH_MSG = "Not sure HashTrieSet implements Hash, it has mutable methods" diff --git a/tests/test_list.py b/tests/test_list.py index 305ed2d..f9b6cce 100644 --- a/tests/test_list.py +++ b/tests/test_list.py @@ -26,9 +26,10 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ -from rpds import List import pytest +from rpds import List + HASH_MSG = "Not sure List implements Hash, it has mutable methods" From 4af2f200f5f905cc531a90b855045b4edc0628a1 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Thu, 6 Jul 2023 13:39:50 +0200 Subject: [PATCH 013/241] Add the missing Project URLs for PyPI --- pyproject.toml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 71e08f4..593891d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,9 +15,10 @@ authors = [ ] classifiers = [ "Development Status :: 3 - Alpha", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Rust", - "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", @@ -29,6 +30,12 @@ classifiers = [ ] dynamic = ["version"] +[project.urls] +Homepage = "https://github.com/crate-py/rpds" +Issues = "https://github.com/crate-py/rpds/issues/" +Funding = "https://github.com/sponsors/Julian" +Source = "https://github.com/crate-py/rpds" + [tool.isort] combine_as_imports = true from_first = true From 4881d42b8b6e0b6d4dd81a28b7bae37135881ca0 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Thu, 6 Jul 2023 13:42:34 +0200 Subject: [PATCH 014/241] Actually bump the version to 0.8.3. Guaranteed I will make this mistake 10 more times until/unless I figure out how to share versions in the Cargo.toml with git. --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 3b7ccec..72b5ffc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rpds-py" -version = "0.7.1" +version = "0.8.3" edition = "2021" [lib] From 9b236a3fc7659ac14e6e9426df8a10490bef48f9 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Thu, 6 Jul 2023 13:54:25 +0200 Subject: [PATCH 015/241] Sigh and the lock too... --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6e66472..c3145a4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -187,7 +187,7 @@ dependencies = [ [[package]] name = "rpds-py" -version = "0.7.1" +version = "0.8.4" dependencies = [ "archery", "pyo3", diff --git a/Cargo.toml b/Cargo.toml index 72b5ffc..380cfb2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rpds-py" -version = "0.8.3" +version = "0.8.4" edition = "2021" [lib] From 862f8c2cf07b0dcea92e10c111a18eae3225ca06 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Thu, 6 Jul 2023 13:54:30 +0200 Subject: [PATCH 016/241] Fix the badge URLs. --- README.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index f87d102..2886864 100644 --- a/README.rst +++ b/README.rst @@ -12,9 +12,9 @@ :alt: Supported Python versions :target: https://pypi.org/project/rpds-py/ -.. |CI| image:: https://github.com/Julian/rpds.py/workflows/CI/badge.svg +.. |CI| image:: https://github.com/crate-py/rpds/workflows/CI/badge.svg :alt: Build status - :target: https://github.com/Julian/rpds.py/actions?query=workflow%3ACI + :target: https://github.com/crate-py/rpds/actions?query=workflow%3ACI Python bindings to the Rust ``rpds`` crate. From 3a28ca7ea73bb66266ba6223236ee83a365e0fb3 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Thu, 6 Jul 2023 15:12:38 +0200 Subject: [PATCH 017/241] Let's see if this gets us MUSL wheels. --- .github/workflows/CI.yml | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 7ef5b9f..ed4ebe1 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -69,7 +69,7 @@ jobs: - name: Run nox run: nox -s "${{ matrix.noxenv }}" - linux: + manylinux: needs: test runs-on: ubuntu-latest strategy: @@ -92,6 +92,29 @@ jobs: name: wheels path: dist + musllinux: + needs: test + runs-on: ubuntu-latest + strategy: + matrix: + target: [x86_64-unknown-linux-musl, i686-unknown-linux-musl] + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: "3.x" + - name: Build wheels + uses: PyO3/maturin-action@v1 + with: + target: ${{ matrix.target }} + args: --release --out dist --interpreter '3.8 3.9 3.10 3.11 pypy3.8 pypy3.9' + manylinux: musllinux_1_2 + - name: Upload wheels + uses: actions/upload-artifact@v3 + with: + name: wheels + path: dist + windows: needs: test runs-on: windows-latest From b3fffbee7f112f7a87706556bf0893e23214ed5c Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Thu, 6 Jul 2023 15:14:34 +0200 Subject: [PATCH 018/241] Fix the needs list as well. --- .github/workflows/CI.yml | 2 +- Cargo.lock | 2 +- Cargo.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index ed4ebe1..21884b5 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -164,7 +164,7 @@ jobs: name: Release runs-on: ubuntu-latest if: "startsWith(github.ref, 'refs/tags/')" - needs: [linux, windows, macos] + needs: [manylinux, musllinux, windows, macos] steps: - uses: actions/download-artifact@v3 with: diff --git a/Cargo.lock b/Cargo.lock index c3145a4..1ed3858 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -187,7 +187,7 @@ dependencies = [ [[package]] name = "rpds-py" -version = "0.8.4" +version = "0.8.6" dependencies = [ "archery", "pyo3", diff --git a/Cargo.toml b/Cargo.toml index 380cfb2..bf9345b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rpds-py" -version = "0.8.4" +version = "0.8.6" edition = "2021" [lib] From 39f9d1c3727c6ff8732f0b3f2b327868eda0e812 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Thu, 6 Jul 2023 15:54:38 +0200 Subject: [PATCH 019/241] One more wheel for aarch64. --- .github/workflows/CI.yml | 5 ++++- Cargo.lock | 2 +- Cargo.toml | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 21884b5..5933b9c 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -97,7 +97,10 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - target: [x86_64-unknown-linux-musl, i686-unknown-linux-musl] + target: + - aarch64-unknown-linux-musl + - i686-unknown-linux-musl + - x86_64-unknown-linux-musl steps: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 diff --git a/Cargo.lock b/Cargo.lock index 1ed3858..644f1cb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -187,7 +187,7 @@ dependencies = [ [[package]] name = "rpds-py" -version = "0.8.6" +version = "0.8.7" dependencies = [ "archery", "pyo3", diff --git a/Cargo.toml b/Cargo.toml index bf9345b..1cf6204 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rpds-py" -version = "0.8.6" +version = "0.8.7" edition = "2021" [lib] From 585dad63d1ed7b010abb00f3f8f9553bc1f3ca1b Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Thu, 6 Jul 2023 16:06:54 +0200 Subject: [PATCH 020/241] Add a note on installation instructions (and the need for rust). Combined with now building wheels for MUSL, this should give the vast majority of users a straightforward installation process. Closes: #6 --- README.rst | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.rst b/README.rst index 2886864..7279317 100644 --- a/README.rst +++ b/README.rst @@ -22,6 +22,23 @@ Python bindings to the Rust ``rpds`` crate. What's here is quite minimal (in transparency, it was written initially to support replacing ``pyrsistent`` in the `referencing library `_). If you see something missing (which is very likely), a PR is definitely welcome to add it. +Installation +------------ + +The distribution on PyPI is named ``rpds.py`` (equivalently ``rpds-py``), and thus can be installed via e.g.: + +.. code:: sh + + $ pip install rpds-py + +Note that if you install ``rpds-py`` from source, you will need a Rust toolchain installed, as it is a build-time dependency. +An example of how to do so in a ``Dockerfile`` can be found `here `_. + +If you believe you are on a common platform which should have wheels built (i.e. and not need to compile from source), feel free to file an issue or pull request modifying the GitHub action used here to build wheels via ``maturin``. + +Usage +----- + Methods in general are named similarly to their ``rpds`` counterparts (rather than ``pyrsistent``\ 's conventions, though probably a full drop-in ``pyrsistent``\ -compatible wrapper module is a good addition at some point). .. code:: python From a4fc5c25e8578550aab9120c28e91e62d936cb93 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Thu, 6 Jul 2023 16:54:39 +0200 Subject: [PATCH 021/241] Also build wheels for macOS 3.9 and others. Refs: #10 --- .github/workflows/CI.yml | 2 +- Cargo.lock | 2 +- Cargo.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 5933b9c..5eb321e 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -156,7 +156,7 @@ jobs: uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} - args: --release --out dist --find-interpreter + args: --release --out dist --interpreter '3.8 3.9 3.10 3.11 pypy3.8 pypy3.9' - name: Upload wheels uses: actions/upload-artifact@v3 with: diff --git a/Cargo.lock b/Cargo.lock index 644f1cb..eef16df 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -187,7 +187,7 @@ dependencies = [ [[package]] name = "rpds-py" -version = "0.8.7" +version = "0.8.8" dependencies = [ "archery", "pyo3", diff --git a/Cargo.toml b/Cargo.toml index 1cf6204..14d7063 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rpds-py" -version = "0.8.7" +version = "0.8.8" edition = "2021" [lib] From 6a54caf313d8d1dec9d59042d1b6b88b46f349fc Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Sat, 8 Jul 2023 10:49:02 +0200 Subject: [PATCH 022/241] Try adding wheels for PyPy3.10 and CPython 3.12 --- .github/workflows/CI.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 5eb321e..142a12f 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -84,7 +84,7 @@ jobs: uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} - args: --release --out dist --interpreter '3.8 3.9 3.10 3.11 pypy3.8 pypy3.9' + args: --release --out dist --interpreter '3.8 3.9 3.10 3.11 3.12 pypy3.8 pypy3.9 pypy3.10' manylinux: auto - name: Upload wheels uses: actions/upload-artifact@v3 @@ -110,7 +110,7 @@ jobs: uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} - args: --release --out dist --interpreter '3.8 3.9 3.10 3.11 pypy3.8 pypy3.9' + args: --release --out dist --interpreter '3.8 3.9 3.10 3.11 3.12 pypy3.8 pypy3.9 pypy3.10' manylinux: musllinux_1_2 - name: Upload wheels uses: actions/upload-artifact@v3 @@ -156,7 +156,7 @@ jobs: uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} - args: --release --out dist --interpreter '3.8 3.9 3.10 3.11 pypy3.8 pypy3.9' + args: --release --out dist --interpreter '3.8 3.9 3.10 3.11 3.12 pypy3.8 pypy3.9 pypy3.10' - name: Upload wheels uses: actions/upload-artifact@v3 with: From 59c6202d28c8f445d22f50f714cf66729ddd4bc6 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Sat, 8 Jul 2023 11:05:15 +0200 Subject: [PATCH 023/241] Again forget to bump the version properly... --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index eef16df..6beda94 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -187,7 +187,7 @@ dependencies = [ [[package]] name = "rpds-py" -version = "0.8.8" +version = "0.8.10" dependencies = [ "archery", "pyo3", diff --git a/Cargo.toml b/Cargo.toml index 14d7063..8449c47 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rpds-py" -version = "0.8.8" +version = "0.8.10" edition = "2021" [lib] From bf6c4ac3c4bfb9659ae53a08a0fbf0361f44194e Mon Sep 17 00:00:00 2001 From: Leslie Zhai Date: Mon, 17 Jul 2023 17:50:53 +0800 Subject: [PATCH 024/241] Update target-lexicon to support loongarch64 architecture --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6beda94..392f80b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -225,9 +225,9 @@ dependencies = [ [[package]] name = "target-lexicon" -version = "0.12.6" +version = "0.12.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ae9980cab1db3fceee2f6c6f643d5d8de2997c58ee8d25fb0cc8a9e9e7348e5" +checksum = "fd1ba337640d60c3e96bc6f0638a939b9c9a7f2c316a1598c279828b3d1dc8c5" [[package]] name = "unicode-ident" From 7322c3cf1a6bde5f21978e8646835f5927b639e2 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Mon, 17 Jul 2023 12:05:08 +0200 Subject: [PATCH 025/241] Update deps and bump the version. --- Cargo.lock | 85 ++++++++++++++++++++++++------------------------------ Cargo.toml | 2 +- 2 files changed, 39 insertions(+), 48 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 392f80b..7368b82 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -37,15 +37,15 @@ checksum = "bfa799dd5ed20a7e349f3b4639aa80d74549c81716d9ec4f994c9b5815598306" [[package]] name = "libc" -version = "0.2.139" +version = "0.2.147" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" +checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" [[package]] name = "lock_api" -version = "0.4.9" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" +checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" dependencies = [ "autocfg", "scopeguard", @@ -62,9 +62,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.17.1" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" [[package]] name = "parking_lot" @@ -78,22 +78,22 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.7" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" +checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" dependencies = [ "cfg-if", "libc", "redox_syscall", "smallvec", - "windows-sys", + "windows-targets", ] [[package]] name = "proc-macro2" -version = "1.0.51" +version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d727cae5b39d21da60fa540906919ad737832fe0b1c165da3a34d6548c849d6" +checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" dependencies = [ "unicode-ident", ] @@ -160,18 +160,18 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.23" +version = "1.0.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" +checksum = "5fe8a65d69dd0808184ebb5f836ab526bb259db23c657efa38711b1072ee47f0" dependencies = [ "proc-macro2", ] [[package]] name = "redox_syscall" -version = "0.2.16" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" dependencies = [ "bitflags", ] @@ -187,7 +187,7 @@ dependencies = [ [[package]] name = "rpds-py" -version = "0.8.10" +version = "0.8.11" dependencies = [ "archery", "pyo3", @@ -202,9 +202,9 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "smallvec" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" +checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" [[package]] name = "static_assertions" @@ -225,15 +225,15 @@ dependencies = [ [[package]] name = "target-lexicon" -version = "0.12.7" +version = "0.12.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd1ba337640d60c3e96bc6f0638a939b9c9a7f2c316a1598c279828b3d1dc8c5" +checksum = "df8e77cb757a61f51b947ec4a7e3646efd825b73561db1c232a8ccb639e611a0" [[package]] name = "unicode-ident" -version = "1.0.6" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" +checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" [[package]] name = "unindent" @@ -241,20 +241,11 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1766d682d402817b5ac4490b3c3002d91dfa0d22812f341609f97b08757359c" -[[package]] -name = "windows-sys" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" -dependencies = [ - "windows-targets", -] - [[package]] name = "windows-targets" -version = "0.42.1" +version = "0.48.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e2522491fbfcd58cc84d47aeb2958948c4b8982e9a2d8a2a35bbaed431390e7" +checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", @@ -267,42 +258,42 @@ dependencies = [ [[package]] name = "windows_aarch64_gnullvm" -version = "0.42.1" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608" +checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" [[package]] name = "windows_aarch64_msvc" -version = "0.42.1" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7" +checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" [[package]] name = "windows_i686_gnu" -version = "0.42.1" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640" +checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" [[package]] name = "windows_i686_msvc" -version = "0.42.1" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605" +checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" [[package]] name = "windows_x86_64_gnu" -version = "0.42.1" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45" +checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" [[package]] name = "windows_x86_64_gnullvm" -version = "0.42.1" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463" +checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" [[package]] name = "windows_x86_64_msvc" -version = "0.42.1" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" +checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" diff --git a/Cargo.toml b/Cargo.toml index 8449c47..6e1b3e9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rpds-py" -version = "0.8.10" +version = "0.8.11" edition = "2021" [lib] From fce74eac7ce275e3140335fed92080cf6c6c1cfb Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Tue, 18 Jul 2023 15:37:49 +0200 Subject: [PATCH 026/241] Link to rpds. --- Cargo.lock | 2 +- Cargo.toml | 2 +- README.rst | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7368b82..abe0a61 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -187,7 +187,7 @@ dependencies = [ [[package]] name = "rpds-py" -version = "0.8.11" +version = "0.8.12" dependencies = [ "archery", "pyo3", diff --git a/Cargo.toml b/Cargo.toml index 6e1b3e9..a47634b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rpds-py" -version = "0.8.11" +version = "0.8.12" edition = "2021" [lib] diff --git a/README.rst b/README.rst index 7279317..13f0d9e 100644 --- a/README.rst +++ b/README.rst @@ -17,7 +17,7 @@ :target: https://github.com/crate-py/rpds/actions?query=workflow%3ACI -Python bindings to the Rust ``rpds`` crate. +Python bindings to the `Rust rpds crate `_ for persistent data structures. What's here is quite minimal (in transparency, it was written initially to support replacing ``pyrsistent`` in the `referencing library `_). If you see something missing (which is very likely), a PR is definitely welcome to add it. From a7d48cdab7ceb55c5b79032d8370cee32d575ac3 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Tue, 18 Jul 2023 15:42:47 +0200 Subject: [PATCH 027/241] Declare support for 3.12. --- Cargo.lock | 2 +- Cargo.toml | 2 +- noxfile.py | 2 +- pyproject.toml | 1 + 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index abe0a61..e35c972 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -187,7 +187,7 @@ dependencies = [ [[package]] name = "rpds-py" -version = "0.8.12" +version = "0.9.0" dependencies = [ "archery", "pyo3", diff --git a/Cargo.toml b/Cargo.toml index a47634b..8d0c404 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rpds-py" -version = "0.8.12" +version = "0.9.0" edition = "2021" [lib] diff --git a/noxfile.py b/noxfile.py index 8470d80..7377efc 100644 --- a/noxfile.py +++ b/noxfile.py @@ -19,7 +19,7 @@ def _session(fn): return _session -@session(python=["3.8", "3.9", "3.10", "3.11", "pypy3"]) +@session(python=["3.8", "3.9", "3.10", "3.11", "3.12", "pypy3"]) def tests(session): session.install(ROOT, "-r", TESTS / "requirements.txt") if session.posargs == ["coverage"]: diff --git a/pyproject.toml b/pyproject.toml index 593891d..12dfa29 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,6 +23,7 @@ classifiers = [ "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", From 9f6dd2e040709b7fb20a9199a214beb37a480884 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Tue, 18 Jul 2023 15:48:49 +0200 Subject: [PATCH 028/241] Try enabling pre-releases in the setup-python action. --- .github/workflows/CI.yml | 1 + Cargo.lock | 2 +- Cargo.toml | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 142a12f..d47af7f 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -64,6 +64,7 @@ jobs: uses: actions/setup-python@v4 with: python-version: "3.x" + allow-prereleases: true - name: Set up nox uses: wntrblm/nox@2023.04.22 - name: Run nox diff --git a/Cargo.lock b/Cargo.lock index e35c972..3dfdb76 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -187,7 +187,7 @@ dependencies = [ [[package]] name = "rpds-py" -version = "0.9.0" +version = "0.9.1" dependencies = [ "archery", "pyo3", diff --git a/Cargo.toml b/Cargo.toml index 8d0c404..bd65507 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rpds-py" -version = "0.9.0" +version = "0.9.1" edition = "2021" [lib] From d7b5670ec9f53f3a9a93e99668450c2b489df772 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Tue, 18 Jul 2023 16:00:32 +0200 Subject: [PATCH 029/241] Take 3, try using setup-python with multiple versions. --- .github/workflows/CI.yml | 8 +++++++- Cargo.lock | 2 +- Cargo.toml | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index d47af7f..6cd7c43 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -63,7 +63,13 @@ jobs: - name: Set up Python uses: actions/setup-python@v4 with: - python-version: "3.x" + python-version: | + 3.8 + 3.9 + 3.10 + 3.11 + 3.12 + pypy3.10 allow-prereleases: true - name: Set up nox uses: wntrblm/nox@2023.04.22 diff --git a/Cargo.lock b/Cargo.lock index 3dfdb76..a7c04cc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -187,7 +187,7 @@ dependencies = [ [[package]] name = "rpds-py" -version = "0.9.1" +version = "0.9.2" dependencies = [ "archery", "pyo3", diff --git a/Cargo.toml b/Cargo.toml index bd65507..5f75ca1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rpds-py" -version = "0.9.1" +version = "0.9.2" edition = "2021" [lib] From 8a400957efb32d27205ab5d72e97ca120a402f92 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Jul 2023 18:32:02 +0000 Subject: [PATCH 030/241] Bump archery from 0.5.0 to 1.0.0 Bumps [archery](https://github.com/orium/archery) from 0.5.0 to 1.0.0. - [Release notes](https://github.com/orium/archery/releases) - [Changelog](https://github.com/orium/archery/blob/master/release-notes.md) - [Commits](https://github.com/orium/archery/compare/v0.5.0...v1.0.0) --- updated-dependencies: - dependency-name: archery dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- Cargo.lock | 13 +++++++++++-- Cargo.toml | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a7c04cc..db811f4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11,6 +11,15 @@ dependencies = [ "static_assertions", ] +[[package]] +name = "archery" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab7d8a6d00b222909638a01ddcc8c533219e9d5bfada1613afae43481f2fc699" +dependencies = [ + "static_assertions", +] + [[package]] name = "autocfg" version = "1.1.0" @@ -182,14 +191,14 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9bd6ce569b15c331b1e5fd8cf6adb0bf240678b5f0cdc4d0f41e11683f6feba9" dependencies = [ - "archery", + "archery 0.5.0", ] [[package]] name = "rpds-py" version = "0.9.2" dependencies = [ - "archery", + "archery 1.0.0", "pyo3", "rpds", ] diff --git a/Cargo.toml b/Cargo.toml index 5f75ca1..d27e070 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ crate-type = ["cdylib"] [dependencies] rpds = "0.13.0" -archery = "0.5.0" +archery = "1.0.0" [dependencies.pyo3] version = "0.19.1" From fb3bef3556fa989d284cecf94f89b75d0771b63d Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Fri, 28 Jul 2023 13:56:24 +0200 Subject: [PATCH 031/241] More correct listing of nox envs for the GitHub actions workflow What was here would break with noxenv docstrings. --- .github/workflows/CI.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 6cd7c43..47f85eb 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -38,10 +38,7 @@ jobs: - id: noxenvs-matrix run: | echo >>$GITHUB_OUTPUT noxenvs=$( - nox --list-sessions | - grep '^* ' | - cut -d ' ' -f 2- | - jq --raw-input --slurp 'split("\n") | map(select(. != ""))' + nox --list-sessions --json | jq '[.[].session]' ) test: From 7eb17c39a8050d69015012ae005d3c0dbfa6820a Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Fri, 4 Aug 2023 08:09:11 +0100 Subject: [PATCH 032/241] Add a security policy. --- .github/SECURITY.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .github/SECURITY.md diff --git a/.github/SECURITY.md b/.github/SECURITY.md new file mode 100644 index 0000000..d7d7407 --- /dev/null +++ b/.github/SECURITY.md @@ -0,0 +1,15 @@ +# Security Policy + +## Supported Versions + +In general, only the latest released `rpds-py` version is supported and will receive updates. + +## Reporting a Vulnerability + +To report a security vulnerability, please send an email to `Julian+Security` at `GrayVines.com` with subject line `SECURITY (rpds-py)`. + +I will do my best to respond within 48 hours to acknowledge the message and discuss further steps. + +If the vulnerability is accepted, an advisory will be sent out via GitHub's security advisory functionality. + +For non-sensitive discussion related to this policy itself, feel free to open an issue on the issue tracker. From 0921a164af39229c3c31bf579cf6dcdbe8287b53 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Aug 2023 18:59:09 +0000 Subject: [PATCH 033/241] Bump pyo3 from 0.19.1 to 0.19.2 Bumps [pyo3](https://github.com/pyo3/pyo3) from 0.19.1 to 0.19.2. - [Release notes](https://github.com/pyo3/pyo3/releases) - [Changelog](https://github.com/PyO3/pyo3/blob/main/CHANGELOG.md) - [Commits](https://github.com/pyo3/pyo3/compare/v0.19.1...v0.19.2) --- updated-dependencies: - dependency-name: pyo3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 20 ++++++++++---------- Cargo.toml | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index db811f4..a02d9ad 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -109,9 +109,9 @@ dependencies = [ [[package]] name = "pyo3" -version = "0.19.1" +version = "0.19.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffb88ae05f306b4bfcde40ac4a51dc0b05936a9207a4b75b798c7729c4258a59" +checksum = "e681a6cfdc4adcc93b4d3cf993749a4552018ee0a9b65fc0ccfad74352c72a38" dependencies = [ "cfg-if", "indoc", @@ -126,9 +126,9 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.19.1" +version = "0.19.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "554db24f0b3c180a9c0b1268f91287ab3f17c162e15b54caaae5a6b3773396b0" +checksum = "076c73d0bc438f7a4ef6fdd0c3bb4732149136abd952b110ac93e4edb13a6ba5" dependencies = [ "once_cell", "target-lexicon", @@ -136,9 +136,9 @@ dependencies = [ [[package]] name = "pyo3-ffi" -version = "0.19.1" +version = "0.19.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "922ede8759e8600ad4da3195ae41259654b9c55da4f7eec84a0ccc7d067a70a4" +checksum = "e53cee42e77ebe256066ba8aa77eff722b3bb91f3419177cf4cd0f304d3284d9" dependencies = [ "libc", "pyo3-build-config", @@ -146,9 +146,9 @@ dependencies = [ [[package]] name = "pyo3-macros" -version = "0.19.1" +version = "0.19.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a5caec6a1dd355964a841fcbeeb1b89fe4146c87295573f94228911af3cc5a2" +checksum = "dfeb4c99597e136528c6dd7d5e3de5434d1ceaf487436a3f03b2d56b6fc9efd1" dependencies = [ "proc-macro2", "pyo3-macros-backend", @@ -158,9 +158,9 @@ dependencies = [ [[package]] name = "pyo3-macros-backend" -version = "0.19.1" +version = "0.19.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0b78ccbb160db1556cdb6fd96c50334c5d4ec44dc5e0a968d0a1208fa0efa8b" +checksum = "947dc12175c254889edc0c02e399476c2f652b4b9ebd123aa655c224de259536" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index d27e070..aec3736 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,5 +12,5 @@ rpds = "0.13.0" archery = "1.0.0" [dependencies.pyo3] -version = "0.19.1" +version = "0.19.2" features = ["extension-module"] From dc4b06af76b1c07f425799df494768b9d7501509 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Aug 2023 18:44:14 +0000 Subject: [PATCH 034/241] Bump rpds from 0.13.0 to 1.0.0 Bumps [rpds](https://github.com/orium/rpds) from 0.13.0 to 1.0.0. - [Release notes](https://github.com/orium/rpds/releases) - [Changelog](https://github.com/orium/rpds/blob/master/release-notes.md) - [Commits](https://github.com/orium/rpds/compare/v0.13.0...v1.0.0) --- updated-dependencies: - dependency-name: rpds dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- Cargo.lock | 17 ++++------------- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a02d9ad..5a3a677 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,15 +2,6 @@ # It is not intended for manual editing. version = 3 -[[package]] -name = "archery" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6cd774058b1b415c4855d8b86436c04bf050c003156fe24bc326fb3fe75c343" -dependencies = [ - "static_assertions", -] - [[package]] name = "archery" version = "1.0.0" @@ -187,18 +178,18 @@ dependencies = [ [[package]] name = "rpds" -version = "0.13.0" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bd6ce569b15c331b1e5fd8cf6adb0bf240678b5f0cdc4d0f41e11683f6feba9" +checksum = "0e475a12283dfa5e31bd0b0a1a10b5486c0965a34eaf8a695d6df4b47810250d" dependencies = [ - "archery 0.5.0", + "archery", ] [[package]] name = "rpds-py" version = "0.9.2" dependencies = [ - "archery 1.0.0", + "archery", "pyo3", "rpds", ] diff --git a/Cargo.toml b/Cargo.toml index aec3736..0da41f0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ name = "rpds" crate-type = ["cdylib"] [dependencies] -rpds = "0.13.0" +rpds = "1.0.0" archery = "1.0.0" [dependencies.pyo3] From 79c00d8852e0b0314bf6a1ef1de30cf6bc29c6ca Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Mon, 28 Aug 2023 15:27:43 +0300 Subject: [PATCH 035/241] Unused. --- .pre-commit-config.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 73a5721..87a8e77 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -20,10 +20,6 @@ repos: rev: 5.12.0 hooks: - id: isort - - repo: https://github.com/pycqa/flake8 - rev: "6.0.0" - hooks: - - id: flake8 - repo: https://github.com/asottile/pyupgrade rev: v3.8.0 hooks: From bbdca2e2e60c053013852463d56ba8e22c1be791 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Mon, 28 Aug 2023 15:27:09 +0300 Subject: [PATCH 036/241] Release 0.10.0. This release contains no real functional changes but corresponds to bumping rpds (the upstream dependency) to v1.0.0 --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5a3a677..a634bd1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -187,7 +187,7 @@ dependencies = [ [[package]] name = "rpds-py" -version = "0.9.2" +version = "0.10.0" dependencies = [ "archery", "pyo3", diff --git a/Cargo.toml b/Cargo.toml index 0da41f0..ce3b3cb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rpds-py" -version = "0.9.2" +version = "0.10.0" edition = "2021" [lib] From fb999a27149d94b21d9d1182193bc4f9fe88f253 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Sat, 2 Sep 2023 13:10:28 +0300 Subject: [PATCH 037/241] Don't use nox.session.create_tmp. It's basically a footgun, in that it: * doesn't create a pseudorandom temporary directory, it just gives you the path 'tmp/' * thereby then doesn't create separate directories if you call it multiple times * mutates the global (shell) environment state by setting TMPDIR to this 'new' directory so other processes can now 'accidentally' end up sticking things in it (In particular I was really confused how/why non-distribution files were being plopped into my python -m build's outdir, but it was because TMPDIR was sticking around) --- noxfile.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/noxfile.py b/noxfile.py index 7377efc..4263064 100644 --- a/noxfile.py +++ b/noxfile.py @@ -1,4 +1,5 @@ from pathlib import Path +from tempfile import TemporaryDirectory import nox @@ -30,9 +31,9 @@ def tests(session): session.run("pytest", *session.posargs, TESTS) -@session(tags=["style"]) -def readme(session): +@session(tags=["build"]) +def build(session): session.install("build", "twine") - tmpdir = session.create_tmp() - session.run("python", "-m", "build", ROOT, "--outdir", tmpdir) - session.run("python", "-m", "twine", "check", tmpdir + "/*") + with TemporaryDirectory() as tmpdir: + session.run("python", "-m", "build", ROOT, "--outdir", tmpdir) + session.run("twine", "check", "--strict", tmpdir + "/*") From de7a0caedcaa3a9c4ad6221bc6ecf0a15baef52a Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Sat, 2 Sep 2023 13:10:48 +0300 Subject: [PATCH 038/241] Update requirements. --- noxfile.py | 13 +++++++++++++ tests/requirements.txt | 16 +++++++--------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/noxfile.py b/noxfile.py index 4263064..30e9eb1 100644 --- a/noxfile.py +++ b/noxfile.py @@ -37,3 +37,16 @@ def build(session): with TemporaryDirectory() as tmpdir: session.run("python", "-m", "build", ROOT, "--outdir", tmpdir) session.run("twine", "check", "--strict", tmpdir + "/*") + + +@session(default=False) +def requirements(session): + session.install("pip-tools") + for each in [TESTS / "requirements.in"]: + session.run( + "pip-compile", + "--resolver", + "backtracking", + "-U", + each.relative_to(ROOT), + ) diff --git a/tests/requirements.txt b/tests/requirements.txt index 9c2e60f..6eaa67e 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -2,21 +2,19 @@ # This file is autogenerated by pip-compile with Python 3.11 # by the following command: # -# pip-compile --resolver=backtracking tests/requirements.in +# pip-compile tests/requirements.in # -attrs==22.2.0 - # via - # hypothesis - # pytest -hypothesis==6.68.2 +attrs==23.1.0 + # via hypothesis +hypothesis==6.83.0 # via -r tests/requirements.in iniconfig==2.0.0 # via pytest -packaging==23.0 +packaging==23.1 # via pytest -pluggy==1.0.0 +pluggy==1.3.0 # via pytest -pytest==7.2.1 +pytest==7.4.0 # via -r tests/requirements.in sortedcontainers==2.4.0 # via hypothesis From 2628b8125fc178c8cf5e7c85ec8496a0a20fa4d8 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Sat, 2 Sep 2023 13:11:12 +0300 Subject: [PATCH 039/241] Enable clippy and fix what it complains about. --- .pre-commit-config.yaml | 1 + src/lib.rs | 29 +++++++++++++---------------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 87a8e77..3442752 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,6 +16,7 @@ repos: rev: "v1.0" hooks: - id: fmt + - id: clippy - repo: https://github.com/PyCQA/isort rev: 5.12.0 hooks: diff --git a/src/lib.rs b/src/lib.rs index 4de113c..bd368e1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -126,7 +126,7 @@ impl HashTrieMapPy { } fn __len__(&self) -> usize { - self.inner.size().into() + self.inner.size() } fn __repr__(&self, py: Python) -> String { @@ -151,7 +151,7 @@ impl HashTrieMapPy { && self .inner .iter() - .map(|(k1, v1)| (v1, other.inner.get(&k1))) + .map(|(k1, v1)| (v1, other.inner.get(k1))) .map(|(v1, v2)| PyAny::eq(v1.extract(py)?, v2)) .all(|r| r.unwrap_or(false))) .into_py(py)), @@ -159,7 +159,7 @@ impl HashTrieMapPy { || self .inner .iter() - .map(|(k1, v1)| (v1, other.inner.get(&k1))) + .map(|(k1, v1)| (v1, other.inner.get(k1))) .map(|(v1, v2)| PyAny::ne(v1.extract(py)?, v2)) .all(|r| r.unwrap_or(true))) .into_py(py)), @@ -181,18 +181,15 @@ impl HashTrieMapPy { } fn keys(&self) -> Vec { - self.inner.keys().map(|key| key.clone()).collect() + self.inner.keys().cloned().collect() } fn values(&self) -> Vec<&PyObject> { - self.inner.values().collect::>().to_owned() + self.inner.values().collect::>() } fn items(&self) -> Vec<(&Key, &PyObject)> { - self.inner - .iter() - .collect::>() - .to_owned() + self.inner.iter().collect::>() } fn discard(&self, key: Key) -> PyResult { @@ -208,7 +205,7 @@ impl HashTrieMapPy { fn insert(&self, key: Key, value: &PyAny) -> HashTrieMapPy { HashTrieMapPy { - inner: self.inner.insert(Key::from(key), value.into()), + inner: self.inner.insert(key, value.into()), } } @@ -290,19 +287,19 @@ impl HashTrieSetPy { } fn __and__(&self, other: &Self) -> Self { - self.intersection(&other) + self.intersection(other) } fn __or__(&self, other: &Self) -> Self { - self.union(&other) + self.union(other) } fn __sub__(&self, other: &Self) -> Self { - self.difference(&other) + self.difference(other) } fn __xor__(&self, other: &Self) -> Self { - self.symmetric_difference(&other) + self.symmetric_difference(other) } fn __iter__(slf: PyRef<'_, Self>) -> PyResult> { @@ -316,7 +313,7 @@ impl HashTrieSetPy { } fn __len__(&self) -> usize { - self.inner.size().into() + self.inner.size() } fn __repr__(&self, py: Python) -> String { @@ -350,7 +347,7 @@ impl HashTrieSetPy { fn insert(&self, value: Key) -> HashTrieSetPy { HashTrieSetPy { - inner: self.inner.insert(Key::from(value)), + inner: self.inner.insert(value), } } From 3eac1e7f9b05fa966526b6d4d56584659f72ad90 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Sat, 2 Sep 2023 13:11:47 +0300 Subject: [PATCH 040/241] Update pre-commit hooks. --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3442752..56d2cc4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,16 +22,16 @@ repos: hooks: - id: isort - repo: https://github.com/asottile/pyupgrade - rev: v3.8.0 + rev: v3.10.1 hooks: - id: pyupgrade - repo: https://github.com/psf/black - rev: 23.3.0 + rev: 23.7.0 hooks: - name: black id: black args: ["--line-length", "79"] - repo: https://github.com/pre-commit/mirrors-prettier - rev: "v3.0.0-alpha.9-for-vscode" + rev: "v3.0.3" hooks: - id: prettier From bca8394d67c1a68ee62ee42de412107ee47722e7 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Mon, 4 Sep 2023 17:56:40 +0300 Subject: [PATCH 041/241] Release v0.10.2 Closes: #22 --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a634bd1..21bcd7c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -187,7 +187,7 @@ dependencies = [ [[package]] name = "rpds-py" -version = "0.10.0" +version = "0.10.2" dependencies = [ "archery", "pyo3", diff --git a/Cargo.toml b/Cargo.toml index ce3b3cb..12a8d3a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rpds-py" -version = "0.10.0" +version = "0.10.2" edition = "2021" [lib] From b7c3231f708070a37f3d0e27c49d7af97b7bc654 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Sep 2023 18:54:09 +0000 Subject: [PATCH 042/241] Bump actions/checkout from 3 to 4 Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/CI.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 47f85eb..7afdcb6 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -21,7 +21,7 @@ jobs: pre-commit: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: actions/setup-python@v4 with: python-version: "3.x" @@ -32,7 +32,7 @@ jobs: outputs: noxenvs: ${{ steps.noxenvs-matrix.outputs.noxenvs }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up nox uses: wntrblm/nox@2023.04.22 - id: noxenvs-matrix @@ -50,7 +50,7 @@ jobs: noxenv: ${{ fromJson(needs.list.outputs.noxenvs) }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install dependencies run: sudo apt-get update && sudo apt-get install -y libenchant-2-dev if: runner.os == 'Linux' && startsWith(matrix.noxenv, 'docs') @@ -80,7 +80,7 @@ jobs: matrix: target: [x86_64, x86, aarch64, armv7, s390x, ppc64le] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: actions/setup-python@v4 with: python-version: "3.x" @@ -106,7 +106,7 @@ jobs: - i686-unknown-linux-musl - x86_64-unknown-linux-musl steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: actions/setup-python@v4 with: python-version: "3.x" @@ -129,7 +129,7 @@ jobs: matrix: target: [x64, x86] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: actions/setup-python@v4 with: python-version: "3.x" @@ -152,7 +152,7 @@ jobs: matrix: target: [x86_64, aarch64] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: actions/setup-python@v4 with: python-version: "3.x" From 15819384a117f1bf1cc9435671489fcc240aeeac Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Sep 2023 18:55:32 +0000 Subject: [PATCH 043/241] Bump rpds from 1.0.0 to 1.0.1 Bumps [rpds](https://github.com/orium/rpds) from 1.0.0 to 1.0.1. - [Release notes](https://github.com/orium/rpds/releases) - [Changelog](https://github.com/orium/rpds/blob/master/release-notes.md) - [Commits](https://github.com/orium/rpds/compare/v1.0.0...v1.0.1) --- updated-dependencies: - dependency-name: rpds dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 21bcd7c..e6695f0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -178,9 +178,9 @@ dependencies = [ [[package]] name = "rpds" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e475a12283dfa5e31bd0b0a1a10b5486c0965a34eaf8a695d6df4b47810250d" +checksum = "99334e9410cf4d16241bb88b27bc282e140327a4c4759be76f8a96e6d0cd0f35" dependencies = [ "archery", ] diff --git a/Cargo.toml b/Cargo.toml index 12a8d3a..6b519ff 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ name = "rpds" crate-type = ["cdylib"] [dependencies] -rpds = "1.0.0" +rpds = "1.0.1" archery = "1.0.0" [dependencies.pyo3] From e94a0676ce6218526b74ee15d0f3d91e0fa50a91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Wed, 13 Sep 2023 15:13:33 +0200 Subject: [PATCH 044/241] Remove an unused test dependency on hypothesis --- tests/requirements.in | 1 - tests/requirements.txt | 4 ---- 2 files changed, 5 deletions(-) diff --git a/tests/requirements.in b/tests/requirements.in index 9a54149..e079f8a 100644 --- a/tests/requirements.in +++ b/tests/requirements.in @@ -1,2 +1 @@ -hypothesis pytest diff --git a/tests/requirements.txt b/tests/requirements.txt index 6eaa67e..b216e7c 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -4,8 +4,6 @@ # # pip-compile tests/requirements.in # -attrs==23.1.0 - # via hypothesis hypothesis==6.83.0 # via -r tests/requirements.in iniconfig==2.0.0 @@ -16,5 +14,3 @@ pluggy==1.3.0 # via pytest pytest==7.4.0 # via -r tests/requirements.in -sortedcontainers==2.4.0 - # via hypothesis From 007f8a9d7a737bdb58698498d8941174189ac027 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Wed, 13 Sep 2023 09:21:10 -0400 Subject: [PATCH 045/241] Update test dependencies. --- tests/requirements.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/requirements.txt b/tests/requirements.txt index b216e7c..8b2acf1 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -4,13 +4,11 @@ # # pip-compile tests/requirements.in # -hypothesis==6.83.0 - # via -r tests/requirements.in iniconfig==2.0.0 # via pytest packaging==23.1 # via pytest pluggy==1.3.0 # via pytest -pytest==7.4.0 +pytest==7.4.2 # via -r tests/requirements.in From 5bda2f1462e490d70ee35e8c6384ce41458a7f3e Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Wed, 13 Sep 2023 09:30:19 -0400 Subject: [PATCH 046/241] Release v0.10.3 --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e6695f0..4dd82a5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -187,7 +187,7 @@ dependencies = [ [[package]] name = "rpds-py" -version = "0.10.2" +version = "0.10.3" dependencies = [ "archery", "pyo3", diff --git a/Cargo.toml b/Cargo.toml index 6b519ff..ae098df 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rpds-py" -version = "0.10.2" +version = "0.10.3" edition = "2021" [lib] From 4a319d090e81bc6d3d1bf763a9370d42d2f38ab1 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Wed, 4 Oct 2023 13:06:29 -0400 Subject: [PATCH 047/241] Try building wheels for more Windows interpreters as well. --- .github/workflows/CI.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 7afdcb6..f26770a 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -88,7 +88,7 @@ jobs: uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} - args: --release --out dist --interpreter '3.8 3.9 3.10 3.11 3.12 pypy3.8 pypy3.9 pypy3.10' + args: --release --out dist --sdist --interpreter '3.8 3.9 3.10 3.11 3.12 pypy3.8 pypy3.9 pypy3.10' manylinux: auto - name: Upload wheels uses: actions/upload-artifact@v3 @@ -138,7 +138,7 @@ jobs: uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} - args: --release --out dist --find-interpreter --sdist + args: --release --out dist --interpreter '3.8 3.9 3.10 3.11 3.12 pypy3.8 pypy3.9 pypy3.10' - name: Upload wheels uses: actions/upload-artifact@v3 with: From 3904555c424262d44660333c8fc99b03cf84fae5 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Wed, 4 Oct 2023 13:08:20 -0400 Subject: [PATCH 048/241] Release v0.10.4 --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4dd82a5..b40ed5f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -187,7 +187,7 @@ dependencies = [ [[package]] name = "rpds-py" -version = "0.10.3" +version = "0.10.4" dependencies = [ "archery", "pyo3", diff --git a/Cargo.toml b/Cargo.toml index ae098df..57155c6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rpds-py" -version = "0.10.3" +version = "0.10.4" edition = "2021" [lib] From e2d7929b36c425b1d2bcc1b4a591ba4fb6556c58 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Wed, 4 Oct 2023 13:33:36 -0400 Subject: [PATCH 049/241] Drop PyPy 3.8 which seems to fail. --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index f26770a..8b0c22d 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -138,7 +138,7 @@ jobs: uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} - args: --release --out dist --interpreter '3.8 3.9 3.10 3.11 3.12 pypy3.8 pypy3.9 pypy3.10' + args: --release --out dist --interpreter '3.8 3.9 3.10 3.11 3.12 pypy3.9 pypy3.10' - name: Upload wheels uses: actions/upload-artifact@v3 with: From 537fae2ce5fc2a0dd6c9a9b013cb005b322532a8 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Wed, 4 Oct 2023 13:47:09 -0400 Subject: [PATCH 050/241] Try again to get PyPy 3.x versions on Windows. --- .github/workflows/CI.yml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 8b0c22d..7094a97 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -132,13 +132,22 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v4 with: - python-version: "3.x" + python-version: | + 3.8 + 3.9 + 3.10 + 3.11 + 3.12 + pypy3.8 + pypy3.9 + pypy3.10 + allow-prereleases: true architecture: ${{ matrix.target }} - name: Build wheels uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} - args: --release --out dist --interpreter '3.8 3.9 3.10 3.11 3.12 pypy3.9 pypy3.10' + args: --release --out dist --interpreter '3.8 3.9 3.10 3.11 3.12 pypy3.8 pypy3.9 pypy3.10' - name: Upload wheels uses: actions/upload-artifact@v3 with: From 73b094342f2ca3bff79af82a8c8715830ea33d87 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Wed, 4 Oct 2023 13:53:46 -0400 Subject: [PATCH 051/241] Take 3 on PyPy+Windows. --- .github/workflows/CI.yml | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 7094a97..f8055bc 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -132,22 +132,13 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v4 with: - python-version: | - 3.8 - 3.9 - 3.10 - 3.11 - 3.12 - pypy3.8 - pypy3.9 - pypy3.10 - allow-prereleases: true + python-version: "3.x" architecture: ${{ matrix.target }} - name: Build wheels uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} - args: --release --out dist --interpreter '3.8 3.9 3.10 3.11 3.12 pypy3.8 pypy3.9 pypy3.10' + args: --release --out dist --interpreter '3.8 3.9 3.10 3.11 3.12 pypy3.10' - name: Upload wheels uses: actions/upload-artifact@v3 with: From 9631b376c72bf24045c2a82ba657da8af7ef6c12 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Wed, 4 Oct 2023 14:08:45 -0400 Subject: [PATCH 052/241] Give up for now. Let's get 3.12 working. --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index f8055bc..675801d 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -138,7 +138,7 @@ jobs: uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} - args: --release --out dist --interpreter '3.8 3.9 3.10 3.11 3.12 pypy3.10' + args: --release --out dist --interpreter '3.8 3.9 3.10 3.11 3.12' - name: Upload wheels uses: actions/upload-artifact@v3 with: From ee297b3764bfc6f41a801e0b9b3fcf3fbaf7b742 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Wed, 4 Oct 2023 14:36:16 -0400 Subject: [PATCH 053/241] Build an sdist in a separate explicit job. Makes it less confusing that only one OS does this. --- .github/workflows/CI.yml | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 675801d..b2825b3 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -73,6 +73,22 @@ jobs: - name: Run nox run: nox -s "${{ matrix.noxenv }}" + sdist: + needs: test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Build an sdist + uses: PyO3/maturin-action@v1 + with: + command: sdist + args: --release --out dist + - name: Upload sdist + uses: actions/upload-artifact@v3 + with: + name: wheels + path: dist + manylinux: needs: test runs-on: ubuntu-latest @@ -88,7 +104,7 @@ jobs: uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} - args: --release --out dist --sdist --interpreter '3.8 3.9 3.10 3.11 3.12 pypy3.8 pypy3.9 pypy3.10' + args: --release --out dist --interpreter '3.8 3.9 3.10 3.11 3.12 pypy3.8 pypy3.9 pypy3.10' manylinux: auto - name: Upload wheels uses: actions/upload-artifact@v3 From 85034d9e40926fa77ff81290e3f49b0a5dc71d52 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Wed, 4 Oct 2023 14:46:23 -0400 Subject: [PATCH 054/241] There is apparently no --release argument for sdist. --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index b2825b3..1c0d433 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -82,7 +82,7 @@ jobs: uses: PyO3/maturin-action@v1 with: command: sdist - args: --release --out dist + args: --out dist - name: Upload sdist uses: actions/upload-artifact@v3 with: From 342ef68a8845455dd86362e93cd6e07d0f3c4405 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Wed, 4 Oct 2023 14:55:34 -0400 Subject: [PATCH 055/241] Flail again for Windows. --- .github/workflows/CI.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 1c0d433..9a1c97d 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -143,13 +143,17 @@ jobs: runs-on: windows-latest strategy: matrix: - target: [x64, x86] + include: + - target: x86_64 + python-architecture: x64 + - target: i686 + python-architecture: x86 steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v4 with: python-version: "3.x" - architecture: ${{ matrix.target }} + architecture: ${{ matrix.python-architecture }} - name: Build wheels uses: PyO3/maturin-action@v1 with: From 24bc6ca84b71593b37958c52176ff4105be5adca Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Wed, 4 Oct 2023 15:07:38 -0400 Subject: [PATCH 056/241] Give up entirely for now. No idea why it doesn't find the library, and no one else seems to be doing this quite yet from what I see. --- .github/workflows/CI.yml | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 9a1c97d..a43dfd0 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -143,22 +143,18 @@ jobs: runs-on: windows-latest strategy: matrix: - include: - - target: x86_64 - python-architecture: x64 - - target: i686 - python-architecture: x86 + target: [x64, x86] steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v4 with: python-version: "3.x" - architecture: ${{ matrix.python-architecture }} + architecture: ${{ matrix.target }} - name: Build wheels uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} - args: --release --out dist --interpreter '3.8 3.9 3.10 3.11 3.12' + args: --release --out dist --interpreter '3.8 3.9 3.10 3.11' - name: Upload wheels uses: actions/upload-artifact@v3 with: From 74ef03ad6056b0fc00435f5b02e05748020c5628 Mon Sep 17 00:00:00 2001 From: Aaron Barany Date: Wed, 4 Oct 2023 15:15:42 -0700 Subject: [PATCH 057/241] Build wheel for Windows on Python 3.12 --- .github/workflows/CI.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index a43dfd0..1af21e9 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -148,13 +148,18 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v4 with: - python-version: "3.x" + python-version: | + 3.8 + 3.9 + 3.10 + 3.11 + 3.12 architecture: ${{ matrix.target }} - name: Build wheels uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} - args: --release --out dist --interpreter '3.8 3.9 3.10 3.11' + args: --release --out dist --interpreter '3.8 3.9 3.10 3.11 3.12' - name: Upload wheels uses: actions/upload-artifact@v3 with: From f575a3249affb9015a91f11f6c831565e28042b7 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Wed, 11 Oct 2023 12:44:41 -0400 Subject: [PATCH 058/241] Try enabling sccache. The default maturin template seems to add it these days, so I suppose that means it likely does do something. --- .github/workflows/CI.yml | 36 ++++++++++++++++++++---------------- Cargo.lock | 2 +- Cargo.toml | 2 +- pyproject.toml | 1 - 4 files changed, 22 insertions(+), 19 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 1af21e9..e3d4919 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -73,22 +73,6 @@ jobs: - name: Run nox run: nox -s "${{ matrix.noxenv }}" - sdist: - needs: test - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Build an sdist - uses: PyO3/maturin-action@v1 - with: - command: sdist - args: --out dist - - name: Upload sdist - uses: actions/upload-artifact@v3 - with: - name: wheels - path: dist - manylinux: needs: test runs-on: ubuntu-latest @@ -105,6 +89,7 @@ jobs: with: target: ${{ matrix.target }} args: --release --out dist --interpreter '3.8 3.9 3.10 3.11 3.12 pypy3.8 pypy3.9 pypy3.10' + sccache: "true" manylinux: auto - name: Upload wheels uses: actions/upload-artifact@v3 @@ -132,6 +117,7 @@ jobs: target: ${{ matrix.target }} args: --release --out dist --interpreter '3.8 3.9 3.10 3.11 3.12 pypy3.8 pypy3.9 pypy3.10' manylinux: musllinux_1_2 + sccache: "true" - name: Upload wheels uses: actions/upload-artifact@v3 with: @@ -160,6 +146,7 @@ jobs: with: target: ${{ matrix.target }} args: --release --out dist --interpreter '3.8 3.9 3.10 3.11 3.12' + sccache: "true" - name: Upload wheels uses: actions/upload-artifact@v3 with: @@ -182,12 +169,29 @@ jobs: with: target: ${{ matrix.target }} args: --release --out dist --interpreter '3.8 3.9 3.10 3.11 3.12 pypy3.8 pypy3.9 pypy3.10' + sccache: "true" - name: Upload wheels uses: actions/upload-artifact@v3 with: name: wheels path: dist + sdist: + needs: test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Build an sdist + uses: PyO3/maturin-action@v1 + with: + command: sdist + args: --out dist + - name: Upload sdist + uses: actions/upload-artifact@v3 + with: + name: wheels + path: dist + release: name: Release runs-on: ubuntu-latest diff --git a/Cargo.lock b/Cargo.lock index b40ed5f..d5e1c9c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -187,7 +187,7 @@ dependencies = [ [[package]] name = "rpds-py" -version = "0.10.4" +version = "0.10.5" dependencies = [ "archery", "pyo3", diff --git a/Cargo.toml b/Cargo.toml index 57155c6..2b27143 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rpds-py" -version = "0.10.4" +version = "0.10.5" edition = "2021" [lib] diff --git a/pyproject.toml b/pyproject.toml index 12dfa29..1760316 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,7 +27,6 @@ classifiers = [ "Programming Language :: Python :: 3", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", - ] dynamic = ["version"] From 086ba46569f47ae13db6faa12584f9bc1a09865c Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Wed, 11 Oct 2023 13:12:22 -0400 Subject: [PATCH 059/241] Publish to PyPI using trusted publishing. --- .github/workflows/CI.yml | 17 +++++++++-------- Cargo.lock | 2 +- Cargo.toml | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index e3d4919..d1deddb 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -14,9 +14,6 @@ on: - cron: "33 5 * * *" workflow_dispatch: -permissions: - contents: write - jobs: pre-commit: runs-on: ubuntu-latest @@ -193,21 +190,25 @@ jobs: path: dist release: - name: Release + needs: [manylinux, musllinux, windows, macos] runs-on: ubuntu-latest if: "startsWith(github.ref, 'refs/tags/')" - needs: [manylinux, musllinux, windows, macos] + environment: + name: PyPI + url: https://pypi.org/p/rpds-py + permissions: + contents: write + id-token: write + steps: - uses: actions/download-artifact@v3 with: name: wheels - name: Publish to PyPI uses: PyO3/maturin-action@v1 - env: - MATURIN_PYPI_TOKEN: ${{ secrets.pypi_password }} with: command: upload - args: --skip-existing * + args: --non-interactive --skip-existing * - name: Create a GitHub Release if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') uses: softprops/action-gh-release@v1 diff --git a/Cargo.lock b/Cargo.lock index d5e1c9c..1893ac2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -187,7 +187,7 @@ dependencies = [ [[package]] name = "rpds-py" -version = "0.10.5" +version = "0.10.6" dependencies = [ "archery", "pyo3", diff --git a/Cargo.toml b/Cargo.toml index 2b27143..9e8636c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rpds-py" -version = "0.10.5" +version = "0.10.6" edition = "2021" [lib] From b57eeb5ec961db5a1de580cbd7b2a082362494ad Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 23 Oct 2023 20:59:50 +0000 Subject: [PATCH 060/241] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/pre-commit-hooks: v4.4.0 → v4.5.0](https://github.com/pre-commit/pre-commit-hooks/compare/v4.4.0...v4.5.0) - [github.com/asottile/pyupgrade: v3.10.1 → v3.15.0](https://github.com/asottile/pyupgrade/compare/v3.10.1...v3.15.0) - [github.com/psf/black: 23.7.0 → 23.10.1](https://github.com/psf/black/compare/23.7.0...23.10.1) --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 56d2cc4..97c2b75 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v4.5.0 hooks: - id: check-ast - id: check-docstring-first @@ -22,11 +22,11 @@ repos: hooks: - id: isort - repo: https://github.com/asottile/pyupgrade - rev: v3.10.1 + rev: v3.15.0 hooks: - id: pyupgrade - repo: https://github.com/psf/black - rev: 23.7.0 + rev: 23.10.1 hooks: - name: black id: black From b7483828b8f4395699369a158e45b9df46452cd5 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Mon, 23 Oct 2023 17:09:08 -0400 Subject: [PATCH 061/241] Update pre-commit hooks. --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 56d2cc4..97c2b75 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v4.5.0 hooks: - id: check-ast - id: check-docstring-first @@ -22,11 +22,11 @@ repos: hooks: - id: isort - repo: https://github.com/asottile/pyupgrade - rev: v3.10.1 + rev: v3.15.0 hooks: - id: pyupgrade - repo: https://github.com/psf/black - rev: 23.7.0 + rev: 23.10.1 hooks: - name: black id: black From 4d68de085603f94a2046b1b237e51543af58bbbb Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Fri, 3 Nov 2023 18:10:03 -0400 Subject: [PATCH 062/241] Update for PyO3 0.20.0. With lots of help from @davidhewitt --- Cargo.lock | 41 ++++++++++++++++++++++++----------------- Cargo.toml | 4 ++-- src/lib.rs | 11 ++++++----- 3 files changed, 32 insertions(+), 24 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1893ac2..0c29373 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -29,11 +29,17 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + [[package]] name = "indoc" -version = "1.0.9" +version = "2.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa799dd5ed20a7e349f3b4639aa80d74549c81716d9ec4f994c9b5815598306" +checksum = "1e186cfbae8084e513daff4240b4797e342f988cecda4fb6c939150f96315fd8" [[package]] name = "libc" @@ -100,9 +106,9 @@ dependencies = [ [[package]] name = "pyo3" -version = "0.19.2" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e681a6cfdc4adcc93b4d3cf993749a4552018ee0a9b65fc0ccfad74352c72a38" +checksum = "04e8453b658fe480c3e70c8ed4e3d3ec33eb74988bd186561b0cc66b85c3bc4b" dependencies = [ "cfg-if", "indoc", @@ -117,9 +123,9 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.19.2" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "076c73d0bc438f7a4ef6fdd0c3bb4732149136abd952b110ac93e4edb13a6ba5" +checksum = "a96fe70b176a89cff78f2fa7b3c930081e163d5379b4dcdf993e3ae29ca662e5" dependencies = [ "once_cell", "target-lexicon", @@ -127,9 +133,9 @@ dependencies = [ [[package]] name = "pyo3-ffi" -version = "0.19.2" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e53cee42e77ebe256066ba8aa77eff722b3bb91f3419177cf4cd0f304d3284d9" +checksum = "214929900fd25e6604661ed9cf349727c8920d47deff196c4e28165a6ef2a96b" dependencies = [ "libc", "pyo3-build-config", @@ -137,9 +143,9 @@ dependencies = [ [[package]] name = "pyo3-macros" -version = "0.19.2" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfeb4c99597e136528c6dd7d5e3de5434d1ceaf487436a3f03b2d56b6fc9efd1" +checksum = "dac53072f717aa1bfa4db832b39de8c875b7c7af4f4a6fe93cdbf9264cf8383b" dependencies = [ "proc-macro2", "pyo3-macros-backend", @@ -149,10 +155,11 @@ dependencies = [ [[package]] name = "pyo3-macros-backend" -version = "0.19.2" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "947dc12175c254889edc0c02e399476c2f652b4b9ebd123aa655c224de259536" +checksum = "7774b5a8282bd4f25f803b1f0d945120be959a36c72e08e7cd031c792fdfd424" dependencies = [ + "heck", "proc-macro2", "quote", "syn", @@ -187,7 +194,7 @@ dependencies = [ [[package]] name = "rpds-py" -version = "0.10.6" +version = "0.11.0" dependencies = [ "archery", "pyo3", @@ -214,9 +221,9 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "syn" -version = "1.0.109" +version = "2.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +checksum = "239814284fd6f1a4ffe4ca893952cdd93c224b6a1571c9a9eadd670295c0c9e2" dependencies = [ "proc-macro2", "quote", @@ -237,9 +244,9 @@ checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" [[package]] name = "unindent" -version = "0.1.11" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1766d682d402817b5ac4490b3c3002d91dfa0d22812f341609f97b08757359c" +checksum = "c7de7d73e1754487cb58364ee906a499937a0dfabd86bcb980fa99ec8c8fa2ce" [[package]] name = "windows-targets" diff --git a/Cargo.toml b/Cargo.toml index 9e8636c..850472f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rpds-py" -version = "0.10.6" +version = "0.11.0" edition = "2021" [lib] @@ -12,5 +12,5 @@ rpds = "1.0.1" archery = "1.0.0" [dependencies.pyo3] -version = "0.19.2" +version = "0.20.0" features = ["extension-module"] diff --git a/src/lib.rs b/src/lib.rs index bd368e1..1bf68d2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -39,7 +39,7 @@ impl IntoPy for Key { } } -impl AsPyPointer for Key { +unsafe impl AsPyPointer for Key { fn as_ptr(&self) -> *mut pyo3::ffi::PyObject { self.inner.as_ptr() } @@ -133,7 +133,7 @@ impl HashTrieMapPy { let contents = self.inner.into_iter().map(|(k, v)| { format!( "{}: {}", - k.into_py(py), + k.clone().into_py(py), v.call_method0(py, "__repr__") .and_then(|r| r.extract(py)) .unwrap_or("".to_owned()) @@ -188,8 +188,8 @@ impl HashTrieMapPy { self.inner.values().collect::>() } - fn items(&self) -> Vec<(&Key, &PyObject)> { - self.inner.iter().collect::>() + fn items(&self) -> Vec<(Key, &PyObject)> { + self.inner.iter().map(|(k, v)| (k.clone(), v)).collect() } fn discard(&self, key: Key) -> PyResult { @@ -318,7 +318,8 @@ impl HashTrieSetPy { fn __repr__(&self, py: Python) -> String { let contents = self.inner.into_iter().map(|k| { - k.into_py(py) + k.clone() + .into_py(py) .call_method0(py, "__repr__") .and_then(|r| r.extract(py)) .unwrap_or("".to_owned()) From bf1a74da6cdb8d97cb41cd37557d3cfbb31dbac6 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Fri, 3 Nov 2023 18:29:31 -0400 Subject: [PATCH 063/241] List.drop_front --- Cargo.lock | 2 +- Cargo.toml | 2 +- rpds.pyi | 1 + src/lib.rs | 18 +++++++++++++----- tests/test_list.py | 16 +++++++++++++++- 5 files changed, 31 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0c29373..159e9d5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -194,7 +194,7 @@ dependencies = [ [[package]] name = "rpds-py" -version = "0.11.0" +version = "0.12.0" dependencies = [ "archery", "pyo3", diff --git a/Cargo.toml b/Cargo.toml index 850472f..919877b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rpds-py" -version = "0.11.0" +version = "0.12.0" edition = "2021" [lib] diff --git a/rpds.pyi b/rpds.pyi index 6a0953f..4c01da3 100644 --- a/rpds.pyi +++ b/rpds.pyi @@ -49,3 +49,4 @@ class List(Iterable[T]): def __iter__(self) -> Iterator[T]: ... def __len__(self) -> int: ... def push_front(self, value: T) -> "List[T]": ... + def drop_front(self) -> "List[T]": ... diff --git a/src/lib.rs b/src/lib.rs index 1bf68d2..7a07381 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -553,17 +553,25 @@ impl ListPy { .ok_or_else(|| PyIndexError::new_err("empty list has no first element")) } + #[getter] + fn rest(&self) -> ListPy { + let mut inner = self.inner.clone(); + inner.drop_first_mut(); + ListPy { inner } + } + fn push_front(&self, other: PyObject) -> ListPy { ListPy { inner: self.inner.push_front(other), } } - #[getter] - fn rest(&self) -> ListPy { - let mut inner = self.inner.clone(); - inner.drop_first_mut(); - ListPy { inner } + fn drop_first(&self) -> PyResult { + if let Some(inner) = self.inner.drop_first() { + Ok(ListPy { inner }) + } else { + Err(PyIndexError::new_err("empty list has no first element")) + } } } diff --git a/tests/test_list.py b/tests/test_list.py index f9b6cce..a0af066 100644 --- a/tests/test_list.py +++ b/tests/test_list.py @@ -108,8 +108,22 @@ def test_sequence(): assert m == List(["a", "s", "d", "f"]) +# Non-pyrsistent-test-suite tests + + +def test_drop_first(): + assert List([1, 2, 3]).drop_first() == List([2, 3]) + + +def test_drop_first_empty(): + """ + rpds itself returns an Option here but we try IndexError instead. + """ + with pytest.raises(IndexError): + List([]).drop_first() + + def test_more_eq(): - # Non-pyrsistent-test-suite test o = object() assert List([o, o]) == List([o, o]) From 132866aa2cf9e17399c43ce34bcb2722dc487f92 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 6 Nov 2023 18:09:25 +0000 Subject: [PATCH 064/241] Bump archery from 1.0.0 to 1.1.0 Bumps [archery](https://github.com/orium/archery) from 1.0.0 to 1.1.0. - [Release notes](https://github.com/orium/archery/releases) - [Changelog](https://github.com/orium/archery/blob/main/release-notes.md) - [Commits](https://github.com/orium/archery/compare/v1.0.0...v1.1.0) --- updated-dependencies: - dependency-name: archery dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 159e9d5..5b5c9fb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "archery" -version = "1.0.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab7d8a6d00b222909638a01ddcc8c533219e9d5bfada1613afae43481f2fc699" +checksum = "487955f60962765486ce000015a3492ca45c34a2ebbf12bc0aa2b5110ca6e7d2" dependencies = [ "static_assertions", ] diff --git a/Cargo.toml b/Cargo.toml index 919877b..883b522 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ crate-type = ["cdylib"] [dependencies] rpds = "1.0.1" -archery = "1.0.0" +archery = "1.1.0" [dependencies.pyo3] version = "0.20.0" From 902cced6752a3e52ca4b9e10b301aa9f3c89052e Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Wed, 8 Nov 2023 10:23:45 -0500 Subject: [PATCH 065/241] Skip Rust on pre-commit.ci which doesn't seem to have Rust installed. I'm not sure I follow why since I see a PR adding it, and I swear I remember it working, but not going to diagnose quite now. --- .pre-commit-config.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 97c2b75..73e6169 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,3 +1,9 @@ +ci: + skip: + # pre-commit.ci doesn't have Rust installed + - cargo-fmt + - cargo-deny + repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.5.0 From 009d761ba64496adbea61e472790964bd6c977a5 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Wed, 8 Nov 2023 10:24:37 -0500 Subject: [PATCH 066/241] That's what I get for copy/paste. --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 73e6169..9acc561 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,8 +1,8 @@ ci: skip: # pre-commit.ci doesn't have Rust installed - - cargo-fmt - - cargo-deny + - fmt + - clippy repos: - repo: https://github.com/pre-commit/pre-commit-hooks From 515a69e4953cce919ce4f89dbd64820ea365c02c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Nov 2023 18:24:01 +0000 Subject: [PATCH 067/241] Bump rpds from 1.0.1 to 1.1.0 Bumps [rpds](https://github.com/orium/rpds) from 1.0.1 to 1.1.0. - [Release notes](https://github.com/orium/rpds/releases) - [Changelog](https://github.com/orium/rpds/blob/main/release-notes.md) - [Commits](https://github.com/orium/rpds/compare/v1.0.1...v1.1.0) --- updated-dependencies: - dependency-name: rpds dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Cargo.lock | 11 +++++++++-- Cargo.toml | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5b5c9fb..89dc0f9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9,6 +9,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "487955f60962765486ce000015a3492ca45c34a2ebbf12bc0aa2b5110ca6e7d2" dependencies = [ "static_assertions", + "triomphe", ] [[package]] @@ -185,9 +186,9 @@ dependencies = [ [[package]] name = "rpds" -version = "1.0.1" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99334e9410cf4d16241bb88b27bc282e140327a4c4759be76f8a96e6d0cd0f35" +checksum = "a0e15515d3ce3313324d842629ea4905c25a13f81953eadb88f85516f59290a4" dependencies = [ "archery", ] @@ -236,6 +237,12 @@ version = "0.12.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df8e77cb757a61f51b947ec4a7e3646efd825b73561db1c232a8ccb639e611a0" +[[package]] +name = "triomphe" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee8098afad3fb0c54a9007aab6804558410503ad676d4633f9c2559a00ac0f" + [[package]] name = "unicode-ident" version = "1.0.11" diff --git a/Cargo.toml b/Cargo.toml index 883b522..4aae89b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ name = "rpds" crate-type = ["cdylib"] [dependencies] -rpds = "1.0.1" +rpds = "1.1.0" archery = "1.1.0" [dependencies.pyo3] From bd26420922765d3c1989bc90f97b7b188d2ff58a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 13 Nov 2023 21:08:38 +0000 Subject: [PATCH 068/241] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/psf/black: 23.10.1 → 23.11.0](https://github.com/psf/black/compare/23.10.1...23.11.0) - [github.com/pre-commit/mirrors-prettier: v3.0.3 → v3.1.0](https://github.com/pre-commit/mirrors-prettier/compare/v3.0.3...v3.1.0) --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9acc561..d998c33 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -32,12 +32,12 @@ repos: hooks: - id: pyupgrade - repo: https://github.com/psf/black - rev: 23.10.1 + rev: 23.11.0 hooks: - name: black id: black args: ["--line-length", "79"] - repo: https://github.com/pre-commit/mirrors-prettier - rev: "v3.0.3" + rev: "v3.1.0" hooks: - id: prettier From e1e9b2421fe7927d69275a240690f209a42565a0 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Wed, 15 Nov 2023 21:54:30 -0800 Subject: [PATCH 069/241] Add pickle support Signed-off-by: Anders Kaseorg --- src/lib.rs | 26 +++++++++++++++++++++++++- tests/test_hash_trie_map.py | 7 +++++++ tests/test_hash_trie_set.py | 8 ++++++++ tests/test_list.py | 6 ++++++ 4 files changed, 46 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 7a07381..127f7f3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5,7 +5,7 @@ use pyo3::exceptions::PyIndexError; use pyo3::pyclass::CompareOp; use pyo3::types::{PyDict, PyIterator, PyTuple, PyType}; use pyo3::{exceptions::PyKeyError, types::PyMapping}; -use pyo3::{prelude::*, AsPyPointer}; +use pyo3::{prelude::*, AsPyPointer, PyTypeInfo}; use rpds::{HashTrieMap, HashTrieMapSync, HashTrieSet, HashTrieSetSync, List, ListSync}; #[derive(Clone, Debug)] @@ -167,6 +167,16 @@ impl HashTrieMapPy { } } + fn __reduce__(slf: PyRef) -> (&PyType, (Vec<(Key, PyObject)>,)) { + ( + HashTrieMapPy::type_object(slf.py()), + (slf.inner + .iter() + .map(|(k, v)| (k.clone(), v.clone())) + .collect(),), + ) + } + #[classmethod] fn convert(_cls: &PyType, value: &PyAny, py: Python) -> PyResult { if value.is_instance_of::() { @@ -346,6 +356,13 @@ impl HashTrieSetPy { } } + fn __reduce__(slf: PyRef) -> (&PyType, (Vec,)) { + ( + HashTrieSetPy::type_object(slf.py()), + (slf.inner.iter().cloned().collect(),), + ) + } + fn insert(&self, value: Key) -> HashTrieSetPy { HashTrieSetPy { inner: self.inner.insert(value), @@ -546,6 +563,13 @@ impl ListPy { } } + fn __reduce__(slf: PyRef) -> (&PyType, (Vec,)) { + ( + ListPy::type_object(slf.py()), + (slf.inner.iter().cloned().collect(),), + ) + } + #[getter] fn first(&self) -> PyResult<&PyObject> { self.inner diff --git a/tests/test_hash_trie_map.py b/tests/test_hash_trie_map.py index 790662e..3a1d248 100644 --- a/tests/test_hash_trie_map.py +++ b/tests/test_hash_trie_map.py @@ -27,6 +27,7 @@ OTHER DEALINGS IN THE SOFTWARE. """ from collections.abc import Hashable, Mapping +import pickle import pytest @@ -322,3 +323,9 @@ def test_more_eq(): assert HashTrieMap({1: 2}) != HashTrieMap({1: 3}) assert HashTrieMap({o: 1}) != HashTrieMap({o: o}) assert HashTrieMap([]) != HashTrieMap([(o, 1)]) + + +def test_pickle(): + assert pickle.loads(pickle.dumps(HashTrieMap([(1, 2), (3, 4)]))) == HashTrieMap( + [(1, 2), (3, 4)] + ) diff --git a/tests/test_hash_trie_set.py b/tests/test_hash_trie_set.py index d6dc970..18b46b9 100644 --- a/tests/test_hash_trie_set.py +++ b/tests/test_hash_trie_set.py @@ -26,6 +26,8 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ +import pickle + import pytest from rpds import HashTrieSet @@ -181,3 +183,9 @@ def test_more_set_comparisons(): assert s <= s assert not (s > s) assert s >= s + + +def test_pickle(): + assert pickle.loads(pickle.dumps(HashTrieSet([1, 2, 3, 4]))) == HashTrieSet( + [1, 2, 3, 4] + ) diff --git a/tests/test_list.py b/tests/test_list.py index a0af066..09ac5cc 100644 --- a/tests/test_list.py +++ b/tests/test_list.py @@ -26,6 +26,8 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ +import pickle + import pytest from rpds import List @@ -139,3 +141,7 @@ def test_more_eq(): assert not (List([o, o]) != List([o, o])) assert not (List([o]) != List([o])) assert not (List() != List([])) + + +def test_pickle(): + assert pickle.loads(pickle.dumps(List([1, 2, 3, 4]))) == List([1, 2, 3, 4]) From 12e4c3cd228414f4c16dcf911ea92b695ae3da30 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 16 Nov 2023 05:55:40 +0000 Subject: [PATCH 070/241] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_hash_trie_map.py | 6 +++--- tests/test_hash_trie_set.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/test_hash_trie_map.py b/tests/test_hash_trie_map.py index 3a1d248..2f3db07 100644 --- a/tests/test_hash_trie_map.py +++ b/tests/test_hash_trie_map.py @@ -326,6 +326,6 @@ def test_more_eq(): def test_pickle(): - assert pickle.loads(pickle.dumps(HashTrieMap([(1, 2), (3, 4)]))) == HashTrieMap( - [(1, 2), (3, 4)] - ) + assert pickle.loads( + pickle.dumps(HashTrieMap([(1, 2), (3, 4)])) + ) == HashTrieMap([(1, 2), (3, 4)]) diff --git a/tests/test_hash_trie_set.py b/tests/test_hash_trie_set.py index 18b46b9..8048251 100644 --- a/tests/test_hash_trie_set.py +++ b/tests/test_hash_trie_set.py @@ -186,6 +186,6 @@ def test_more_set_comparisons(): def test_pickle(): - assert pickle.loads(pickle.dumps(HashTrieSet([1, 2, 3, 4]))) == HashTrieSet( - [1, 2, 3, 4] - ) + assert pickle.loads( + pickle.dumps(HashTrieSet([1, 2, 3, 4])) + ) == HashTrieSet([1, 2, 3, 4]) From 48474d4645f5a1206929ba387130701c06e8bca6 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Wed, 15 Nov 2023 22:01:47 -0800 Subject: [PATCH 071/241] Configure Black in pyproject.toml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This way Black uses the project’s settings when invoked directly by the user or their editor, and not only via pre-commit. Signed-off-by: Anders Kaseorg --- .pre-commit-config.yaml | 4 +--- pyproject.toml | 3 +++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d998c33..f387f35 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -34,9 +34,7 @@ repos: - repo: https://github.com/psf/black rev: 23.11.0 hooks: - - name: black - id: black - args: ["--line-length", "79"] + - id: black - repo: https://github.com/pre-commit/mirrors-prettier rev: "v3.1.0" hooks: diff --git a/pyproject.toml b/pyproject.toml index 1760316..e87ac9f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,6 +36,9 @@ Issues = "https://github.com/crate-py/rpds/issues/" Funding = "https://github.com/sponsors/Julian" Source = "https://github.com/crate-py/rpds" +[tool.black] +line-length = 79 + [tool.isort] combine_as_imports = true from_first = true From b1ed53f831c13f4147044ed3da3dd0a7b03f8fcc Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Thu, 16 Nov 2023 09:16:40 -0500 Subject: [PATCH 072/241] Release v0.13.0 --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 89dc0f9..59a7a8f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -195,7 +195,7 @@ dependencies = [ [[package]] name = "rpds-py" -version = "0.12.0" +version = "0.13.0" dependencies = [ "archery", "pyo3", diff --git a/Cargo.toml b/Cargo.toml index 4aae89b..9f0961f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rpds-py" -version = "0.12.0" +version = "0.13.0" edition = "2021" [lib] From b5547d4e2a365a297a57229a3d93ba10f9b98efa Mon Sep 17 00:00:00 2001 From: Byron Date: Mon, 20 Nov 2023 08:49:19 +1100 Subject: [PATCH 073/241] Fix `drop_first` method name for typing https://github.com/crate-py/rpds/commit/bf1a74da6cdb8d97cb41cd37557d3cfbb31dbac6 added suport for "drop_front" but internally named this method "drop_first". Since the test code uses "drop_first", and to prevent creating a backwards incompatible change, I have chosen to fix the type defintion rather than the internal method name, even though the origin commit used "drop_front" in the commit message. --- rpds.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rpds.pyi b/rpds.pyi index 4c01da3..b9b6555 100644 --- a/rpds.pyi +++ b/rpds.pyi @@ -49,4 +49,4 @@ class List(Iterable[T]): def __iter__(self) -> Iterator[T]: ... def __len__(self) -> int: ... def push_front(self, value: T) -> "List[T]": ... - def drop_front(self) -> "List[T]": ... + def drop_first(self) -> "List[T]": ... From 7082045660b3dea6d7e30084bf8be88ca40f95e9 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Mon, 20 Nov 2023 08:43:28 -0500 Subject: [PATCH 074/241] Release v0.13.1. --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 59a7a8f..9e52c63 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -195,7 +195,7 @@ dependencies = [ [[package]] name = "rpds-py" -version = "0.13.0" +version = "0.13.1" dependencies = [ "archery", "pyo3", diff --git a/Cargo.toml b/Cargo.toml index 9f0961f..6d98e59 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rpds-py" -version = "0.13.0" +version = "0.13.1" edition = "2021" [lib] From 36738f616702a197c8672e6b2b9c3ff2666595ef Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Wed, 22 Nov 2023 10:14:44 -0500 Subject: [PATCH 075/241] Add the explicit Tidelift link. --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index e87ac9f..6dd0c22 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,6 +34,7 @@ dynamic = ["version"] Homepage = "https://github.com/crate-py/rpds" Issues = "https://github.com/crate-py/rpds/issues/" Funding = "https://github.com/sponsors/Julian" +Tidelift = "https://tidelift.com/subscription/pkg/pypi-rpds-py?utm_source=pypi-rpds-py&utm_medium=referral&utm_campaign=pypi-link" Source = "https://github.com/crate-py/rpds" [tool.black] From 8697707083ee3786ba2cfbea204d56113a92ab0f Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Wed, 29 Nov 2023 15:40:06 -0500 Subject: [PATCH 076/241] Fix HashTrieMap __repr__s, which need to repr() the key as well. --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/lib.rs | 5 ++++- tests/test_hash_trie_map.py | 8 ++++++++ 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9e52c63..01eb683 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -195,7 +195,7 @@ dependencies = [ [[package]] name = "rpds-py" -version = "0.13.1" +version = "0.13.2" dependencies = [ "archery", "pyo3", diff --git a/Cargo.toml b/Cargo.toml index 6d98e59..9930d0a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rpds-py" -version = "0.13.1" +version = "0.13.2" edition = "2021" [lib] diff --git a/src/lib.rs b/src/lib.rs index 127f7f3..d5b3a91 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -133,7 +133,10 @@ impl HashTrieMapPy { let contents = self.inner.into_iter().map(|(k, v)| { format!( "{}: {}", - k.clone().into_py(py), + k.inner + .call_method0(py, "__repr__") + .and_then(|r| r.extract(py)) + .unwrap_or("".to_owned()), v.call_method0(py, "__repr__") .and_then(|r| r.extract(py)) .unwrap_or("".to_owned()) diff --git a/tests/test_hash_trie_map.py b/tests/test_hash_trie_map.py index 2f3db07..a247b1b 100644 --- a/tests/test_hash_trie_map.py +++ b/tests/test_hash_trie_map.py @@ -287,6 +287,14 @@ def test_iteration_with_many_elements(): assert actual_values == set(values + [12345, 54321]) +def test_repr(): + rep = repr(HashTrieMap({"foo": "12", "": 37})) + assert rep in { + "HashTrieMap({'foo': '12', '': 37})", + "HashTrieMap({'': 37, 'foo': '12'})", + } + + def test_str(): s = str(HashTrieMap({1: 2, 3: 4})) assert s == "HashTrieMap({1: 2, 3: 4})" or s == "HashTrieMap({3: 4, 1: 2})" From f48c7e9ce9f9b88e504fc31813f1061062ff30e4 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Fri, 8 Dec 2023 14:57:55 -0500 Subject: [PATCH 077/241] Update pre-commit hooks. --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f387f35..57b0f49 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -36,6 +36,6 @@ repos: hooks: - id: black - repo: https://github.com/pre-commit/mirrors-prettier - rev: "v3.1.0" + rev: "v4.0.0-alpha.3-1" hooks: - id: prettier From f5f34d5bfab25c1a7a3ffa61db0269bec04f8a07 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Dec 2023 18:49:01 +0000 Subject: [PATCH 078/241] Bump actions/setup-python from 4 to 5 Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4 to 5. - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](https://github.com/actions/setup-python/compare/v4...v5) --- updated-dependencies: - dependency-name: actions/setup-python dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/CI.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index d1deddb..726c582 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -19,7 +19,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version: "3.x" - uses: pre-commit/action@v3.0.0 @@ -55,7 +55,7 @@ jobs: run: brew install enchant if: runner.os == 'macOS' && startsWith(matrix.noxenv, 'docs') - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: | 3.8 @@ -78,7 +78,7 @@ jobs: target: [x86_64, x86, aarch64, armv7, s390x, ppc64le] steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version: "3.x" - name: Build wheels @@ -105,7 +105,7 @@ jobs: - x86_64-unknown-linux-musl steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version: "3.x" - name: Build wheels @@ -129,7 +129,7 @@ jobs: target: [x64, x86] steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version: | 3.8 @@ -158,7 +158,7 @@ jobs: target: [x86_64, aarch64] steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version: "3.x" - name: Build wheels From 75e19aa231b8c02bd24a6072eb78ea64b40e86d8 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 11 Dec 2023 21:01:45 +0000 Subject: [PATCH 079/241] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/PyCQA/isort: 5.12.0 → 5.13.1](https://github.com/PyCQA/isort/compare/5.12.0...5.13.1) - [github.com/pre-commit/mirrors-prettier: v4.0.0-alpha.3-1 → v4.0.0-alpha.4](https://github.com/pre-commit/mirrors-prettier/compare/v4.0.0-alpha.3-1...v4.0.0-alpha.4) --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 57b0f49..d6bde62 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -24,7 +24,7 @@ repos: - id: fmt - id: clippy - repo: https://github.com/PyCQA/isort - rev: 5.12.0 + rev: 5.13.1 hooks: - id: isort - repo: https://github.com/asottile/pyupgrade @@ -36,6 +36,6 @@ repos: hooks: - id: black - repo: https://github.com/pre-commit/mirrors-prettier - rev: "v4.0.0-alpha.3-1" + rev: "v4.0.0-alpha.4" hooks: - id: prettier From e34cddeb4bebf7285f52a09d438a99e4a98a2a59 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Sat, 16 Dec 2023 16:11:38 -0500 Subject: [PATCH 080/241] Expose rpds.Queue. --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/lib.rs | 122 +++++++++++++++++++++++++++++++++++++++- tests/test_queue.py | 133 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 256 insertions(+), 3 deletions(-) create mode 100644 tests/test_queue.py diff --git a/Cargo.lock b/Cargo.lock index 01eb683..048b868 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -195,7 +195,7 @@ dependencies = [ [[package]] name = "rpds-py" -version = "0.13.2" +version = "0.14.0" dependencies = [ "archery", "pyo3", diff --git a/Cargo.toml b/Cargo.toml index 9930d0a..bc8dcd2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rpds-py" -version = "0.13.2" +version = "0.14.0" edition = "2021" [lib] diff --git a/src/lib.rs b/src/lib.rs index d5b3a91..97955ee 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,7 +6,9 @@ use pyo3::pyclass::CompareOp; use pyo3::types::{PyDict, PyIterator, PyTuple, PyType}; use pyo3::{exceptions::PyKeyError, types::PyMapping}; use pyo3::{prelude::*, AsPyPointer, PyTypeInfo}; -use rpds::{HashTrieMap, HashTrieMapSync, HashTrieSet, HashTrieSetSync, List, ListSync}; +use rpds::{ + HashTrieMap, HashTrieMapSync, HashTrieSet, HashTrieSetSync, List, ListSync, Queue, QueueSync, +}; #[derive(Clone, Debug)] struct Key { @@ -618,6 +620,123 @@ impl ListIterator { } } +#[repr(transparent)] +#[pyclass(name = "Queue", module = "rpds", frozen, sequence)] +struct QueuePy { + inner: QueueSync, +} + +impl From> for QueuePy { + fn from(elements: QueueSync) -> Self { + QueuePy { inner: elements } + } +} + +impl<'source> FromPyObject<'source> for QueuePy { + fn extract(ob: &'source PyAny) -> PyResult { + let mut ret = Queue::new_sync(); + for each in ob.iter()? { + ret.enqueue_mut(each?.extract()?); + } + Ok(QueuePy { inner: ret }) + } +} + +#[pymethods] +impl QueuePy { + #[new] + #[pyo3(signature = (*elements))] + fn init(elements: &PyTuple, py: Python<'_>) -> PyResult { + let mut ret: QueuePy; + if elements.len() == 1 { + ret = elements.get_item(0)?.extract()?; + } else { + ret = QueuePy { + inner: Queue::new_sync(), + }; + if elements.len() > 1 { + for each in elements { + ret.inner.enqueue_mut(each.into_py(py)); + } + } + } + Ok(ret) + } + + fn __eq__(&self, other: &Self, py: Python<'_>) -> bool { + (self.inner.len() == other.inner.len()) + && self + .inner + .iter() + .zip(other.inner.iter()) + .map(|(e1, e2)| PyAny::eq(e1.extract(py)?, e2)) + .all(|r| r.unwrap_or(false)) + } + + fn __ne__(&self, other: &Self, py: Python<'_>) -> bool { + (self.inner.len() != other.inner.len()) + || self + .inner + .iter() + .zip(other.inner.iter()) + .map(|(e1, e2)| PyAny::ne(e1.extract(py)?, e2)) + .any(|r| r.unwrap_or(true)) + } + + fn __iter__(slf: PyRef<'_, Self>) -> PyResult> { + let iter = slf + .inner + .iter() + .map(|k| k.to_owned()) + .collect::>() + .into_iter(); + Py::new(slf.py(), ListIterator { inner: iter }) + } + + fn __len__(&self) -> usize { + self.inner.len() + } + + fn __repr__(&self, py: Python) -> String { + let contents = self.inner.into_iter().map(|k| { + k.clone() + .into_py(py) + .call_method0(py, "__repr__") + .and_then(|r| r.extract(py)) + .unwrap_or("".to_owned()) + }); + format!("Queue([{}])", contents.collect::>().join(", ")) + } + + #[getter] + fn peek(&self) -> PyResult { + if let Some(peeked) = self.inner.peek() { + Ok(peeked.to_owned()) + } else { + Err(PyIndexError::new_err("peeked an empty queue")) + } + } + + #[getter] + fn is_empty(&self) -> bool { + self.inner.is_empty() + } + + fn enqueue(&self, value: &PyAny) -> Self { + QueuePy { + inner: self.inner.enqueue(value.into()), + } + } + + fn dequeue(&self) -> PyResult { + if let Some(inner) = self.inner.dequeue() { + Ok(QueuePy { inner }) + } else { + Err(PyIndexError::new_err("dequeued an empty queue")) + } + } +} + #[pymodule] #[pyo3(name = "rpds")] fn rpds_py(py: Python, m: &PyModule) -> PyResult<()> { @@ -625,5 +744,6 @@ fn rpds_py(py: Python, m: &PyModule) -> PyResult<()> { PyMapping::register::(py)?; m.add_class::()?; m.add_class::()?; + m.add_class::()?; Ok(()) } diff --git a/tests/test_queue.py b/tests/test_queue.py new file mode 100644 index 0000000..0ba8f81 --- /dev/null +++ b/tests/test_queue.py @@ -0,0 +1,133 @@ +""" +Modified from the pyrsistent test suite. + +Pre-modification, these were MIT licensed, and are copyright: + + Copyright (c) 2022 Tobias Gustafsson + + Permission is hereby granted, free of charge, to any person + obtaining a copy of this software and associated documentation + files (the "Software"), to deal in the Software without + restriction, including without limitation the rights to use, + copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following + conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + OTHER DEALINGS IN THE SOFTWARE. +""" +import pytest + +from rpds import Queue + +HASH_MSG = "Not sure Queue implements Hash, it has mutable methods" + + +def test_literalish_works(): + assert Queue(1, 2, 3) == Queue([1, 2, 3]) + + +def test_peek_dequeue(): + pl = Queue([1, 2]) + assert pl.peek == 1 + assert pl.dequeue().peek == 2 + assert pl.dequeue().dequeue().is_empty + with pytest.raises(IndexError): + pl.dequeue().dequeue().dequeue() + + +def test_instantiate_large_list(): + assert Queue(range(1000)).peek == 0 + + +def test_iteration(): + assert list(Queue()) == [] + assert list(Queue([1, 2, 3])) == [1, 2, 3] + + +def test_enqueue(): + assert Queue([1, 2, 3]).enqueue(4) == Queue([1, 2, 3, 4]) + + +def test_enqueue_empty_list(): + assert Queue().enqueue(0) == Queue([0]) + + +def test_truthiness(): + assert Queue([1]) + assert not Queue() + + +def test_len(): + assert len(Queue([1, 2, 3])) == 3 + assert len(Queue()) == 0 + + +def test_peek_illegal_on_empty_list(): + with pytest.raises(IndexError): + Queue().peek + + +def test_inequality(): + assert Queue([1, 2]) != Queue([1, 3]) + assert Queue([1, 2]) != Queue([1, 2, 3]) + assert Queue() != Queue([1, 2, 3]) + + +def test_repr(): + assert str(Queue()) == "Queue([])" + assert str(Queue([1, 2, 3])) in "Queue([1, 2, 3])" + + +@pytest.mark.xfail(reason=HASH_MSG) +def test_hashing(): + assert hash(Queue([1, 2])) == hash(Queue([1, 2])) + assert hash(Queue([1, 2])) != hash(Queue([2, 1])) + + +def test_sequence(): + m = Queue("asdf") + assert m == Queue(["a", "s", "d", "f"]) + + +# Non-pyrsistent-test-suite tests + + +def test_dequeue(): + assert Queue([1, 2, 3]).dequeue() == Queue([2, 3]) + + +def test_dequeue_empty(): + """ + rpds itself returns an Option here but we try IndexError instead. + """ + with pytest.raises(IndexError): + Queue([]).dequeue() + + +def test_more_eq(): + o = object() + + assert Queue([o, o]) == Queue([o, o]) + assert Queue([o]) == Queue([o]) + assert Queue() == Queue([]) + assert not (Queue([1, 2]) == Queue([1, 3])) + assert not (Queue([o]) == Queue([o, o])) + assert not (Queue([]) == Queue([o])) + + assert Queue([1, 2]) != Queue([1, 3]) + assert Queue([o]) != Queue([o, o]) + assert Queue([]) != Queue([o]) + assert not (Queue([o, o]) != Queue([o, o])) + assert not (Queue([o]) != Queue([o])) + assert not (Queue() != Queue([])) From 17591587c55520b6aa6a947d6a4136bcfabb4cdb Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Sat, 16 Dec 2023 16:17:46 -0500 Subject: [PATCH 081/241] Le type annotacions --- Cargo.lock | 2 +- Cargo.toml | 2 +- rpds.pyi | 11 +++++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 048b868..0582a38 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -195,7 +195,7 @@ dependencies = [ [[package]] name = "rpds-py" -version = "0.14.0" +version = "0.14.1" dependencies = [ "archery", "pyo3", diff --git a/Cargo.toml b/Cargo.toml index bc8dcd2..44969c7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rpds-py" -version = "0.14.0" +version = "0.14.1" edition = "2021" [lib] diff --git a/rpds.pyi b/rpds.pyi index b9b6555..9f08b65 100644 --- a/rpds.pyi +++ b/rpds.pyi @@ -50,3 +50,14 @@ class List(Iterable[T]): def __len__(self) -> int: ... def push_front(self, value: T) -> "List[T]": ... def drop_first(self) -> "List[T]": ... + +class Queue(Iterable[T]): + def __init__(self, value: Iterable[T] = (), *more: T): ... + def __iter__(self) -> Iterator[T]: ... + def __len__(self) -> int: ... + def enqueue(self, T) -> "Queue[T]": ... + def dequeue(self, T) -> "Queue[T]": ... + @property + def is_empty(self) -> T: ... + @property + def peek(self) -> T: ... From 67717abb81d9312bfcd705517d5c041576028651 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Sun, 17 Dec 2023 10:27:12 -0500 Subject: [PATCH 082/241] Fix HashTrieMap.get to properly take 2 arguments. --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/lib.rs | 8 ++++++-- tests/test_hash_trie_map.py | 13 +++++++++++-- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0582a38..7d906fe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -195,7 +195,7 @@ dependencies = [ [[package]] name = "rpds-py" -version = "0.14.1" +version = "0.14.2" dependencies = [ "archery", "pyo3", diff --git a/Cargo.toml b/Cargo.toml index 44969c7..aee2783 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rpds-py" -version = "0.14.1" +version = "0.14.2" edition = "2021" [lib] diff --git a/src/lib.rs b/src/lib.rs index 97955ee..65846f1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -191,8 +191,12 @@ impl HashTrieMapPy { } } - fn get(&self, key: Key) -> Option<&PyObject> { - self.inner.get(&key) + fn get(&self, key: Key, default: Option) -> Option { + if let Some(value) = self.inner.get(&key) { + Some(value.to_owned()) + } else { + default + } } fn keys(&self) -> Vec { diff --git a/tests/test_hash_trie_map.py b/tests/test_hash_trie_map.py index a247b1b..a94d0f6 100644 --- a/tests/test_hash_trie_map.py +++ b/tests/test_hash_trie_map.py @@ -66,7 +66,7 @@ def test_initialization_with_one_element(): assert "a" not in empty_map -def test_get_non_existing_raises_key_error(): +def test_index_non_existing_raises_key_error(): m1 = HashTrieMap() with pytest.raises(KeyError) as error: m1["foo"] @@ -320,8 +320,10 @@ def test_fast_convert_hashtriemap(): assert HashTrieMap.convert(m) is m +# Non-pyrsistent-test-suite tests + + def test_more_eq(): - # Non-pyrsistent-test-suite test o = object() assert HashTrieMap([(o, o), (1, o)]) == HashTrieMap([(o, o), (1, o)]) @@ -337,3 +339,10 @@ def test_pickle(): assert pickle.loads( pickle.dumps(HashTrieMap([(1, 2), (3, 4)])) ) == HashTrieMap([(1, 2), (3, 4)]) + + +def test_get(): + m1 = HashTrieMap({"foo": "bar"}) + assert m1.get("foo") == "bar" + assert m1.get("baz") is None + assert m1.get("spam", "eggs") == "eggs" From d0ba48e6910ed6c516391dfd43bf7d4d72fd2bf4 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Sun, 17 Dec 2023 12:03:51 -0500 Subject: [PATCH 083/241] Simple docs. --- .gitignore | 6 +++ .readthedocs.yml | 17 ++++++++ README.rst | 4 ++ docs/api.rst | 8 ++++ docs/conf.py | 87 +++++++++++++++++++++++++++++++++++++ docs/index.rst | 52 ++++++++++++++++++++++ docs/requirements.in | 9 ++++ docs/requirements.txt | 89 ++++++++++++++++++++++++++++++++++++++ docs/spelling-wordlist.txt | 0 9 files changed, 272 insertions(+) create mode 100644 .readthedocs.yml create mode 100644 docs/api.rst create mode 100644 docs/conf.py create mode 100644 docs/index.rst create mode 100644 docs/requirements.in create mode 100644 docs/requirements.txt create mode 100644 docs/spelling-wordlist.txt diff --git a/.gitignore b/.gitignore index c8f0442..62e01a9 100644 --- a/.gitignore +++ b/.gitignore @@ -70,3 +70,9 @@ docs/_build/ # Pyenv .python-version + +# User defined +/dirhtml +_cache + +TODO diff --git a/.readthedocs.yml b/.readthedocs.yml new file mode 100644 index 0000000..e6ab173 --- /dev/null +++ b/.readthedocs.yml @@ -0,0 +1,17 @@ +version: 2 + +build: + os: ubuntu-22.04 + tools: + python: "3.11" + +sphinx: + builder: dirhtml + configuration: docs/conf.py + fail_on_warning: true + +formats: all + +python: + install: + - requirements: docs/requirements.txt diff --git a/README.rst b/README.rst index 13f0d9e..4f3e49b 100644 --- a/README.rst +++ b/README.rst @@ -16,6 +16,10 @@ :alt: Build status :target: https://github.com/crate-py/rpds/actions?query=workflow%3ACI +.. |ReadTheDocs| image:: https://readthedocs.org/projects/referencing/badge/?version=stable&style=flat + :alt: ReadTheDocs status + :target: https://referencing.readthedocs.io/en/stable/ + Python bindings to the `Rust rpds crate `_ for persistent data structures. diff --git a/docs/api.rst b/docs/api.rst new file mode 100644 index 0000000..d978fca --- /dev/null +++ b/docs/api.rst @@ -0,0 +1,8 @@ +API Reference +============= + +.. automodule:: rpds + :members: + :undoc-members: + :imported-members: + :special-members: __iter__, __getitem__, __len__, __rmatmul__ diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 0000000..eb1c0bf --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,87 @@ +import importlib.metadata +import re + +from url import URL + +GITHUB = URL.parse("https://github.com/") +HOMEPAGE = GITHUB / "crate-py/rpds" + +project = "rpds.py" +author = "Julian Berman" +copyright = f"2023, {author}" + +release = importlib.metadata.version("rpds.py") +version = release.partition("-")[0] + +language = "en" +default_role = "any" + +extensions = [ + "sphinx.ext.autodoc", + "sphinx.ext.autosectionlabel", + "sphinx.ext.coverage", + "sphinx.ext.doctest", + "sphinx.ext.extlinks", + "sphinx.ext.intersphinx", + "sphinx.ext.napoleon", + "sphinx.ext.todo", + "sphinx.ext.viewcode", + "sphinx_copybutton", + "sphinx_json_schema_spec", + "sphinxcontrib.spelling", + "sphinxext.opengraph", +] + +pygments_style = "lovelace" +pygments_dark_style = "one-dark" + +html_theme = "furo" + + +def entire_domain(host): + return r"http.?://" + re.escape(host) + r"($|/.*)" + + +linkcheck_ignore = [ + entire_domain("img.shields.io"), + f"{GITHUB}.*#.*", + str(HOMEPAGE / "actions"), + str(HOMEPAGE / "workflows/CI/badge.svg"), +] + +# = Extensions = + +# -- autodoc -- + +autodoc_default_options = { + "members": True, + "member-order": "bysource", +} + +# -- autosectionlabel -- + +autosectionlabel_prefix_document = True + +# -- intersphinx -- + +intersphinx_mapping = { + "python": ("https://docs.python.org/", None), +} + +# -- extlinks -- + +extlinks = { + "gh": (str(HOMEPAGE) + "/%s", None), + "github": (str(GITHUB) + "/%s", None), +} +extlinks_detect_hardcoded_links = True + +# -- sphinx-copybutton -- + +copybutton_prompt_text = r">>> |\.\.\. |\$" +copybutton_prompt_is_regexp = True + +# -- sphinxcontrib-spelling -- + +spelling_word_list_filename = "spelling-wordlist.txt" +spelling_show_suggestions = True diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 0000000..741eb17 --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,52 @@ +Python bindings to the `Rust rpds crate `_ for persistent data structures. + +What's here is quite minimal (in transparency, it was written initially to support replacing ``pyrsistent`` in the `referencing library `_). +If you see something missing (which is very likely), a PR is definitely welcome to add it. + +Installation +------------ + +The distribution on PyPI is named ``rpds.py`` (equivalently ``rpds-py``), and thus can be installed via e.g.: + +.. code:: sh + + $ pip install rpds-py + +Note that if you install ``rpds-py`` from source, you will need a Rust toolchain installed, as it is a build-time dependency. +An example of how to do so in a ``Dockerfile`` can be found `here `_. + +If you believe you are on a common platform which should have wheels built (i.e. and not need to compile from source), feel free to file an issue or pull request modifying the GitHub action used here to build wheels via ``maturin``. + +Usage +----- + +Methods in general are named similarly to their ``rpds`` counterparts (rather than ``pyrsistent``\ 's conventions, though probably a full drop-in ``pyrsistent``\ -compatible wrapper module is a good addition at some point). + +.. code:: python + + >>> from rpds import HashTrieMap, HashTrieSet, List + + >>> m = HashTrieMap({"foo": "bar", "baz": "quux"}) + >>> m.insert("spam", 37) == HashTrieMap({"foo": "bar", "baz": "quux", "spam": 37}) + True + >>> m.remove("foo") == HashTrieMap({"baz": "quux"}) + True + + >>> s = HashTrieSet({"foo", "bar", "baz", "quux"}) + >>> s.insert("spam") == HashTrieSet({"foo", "bar", "baz", "quux", "spam"}) + True + >>> s.remove("foo") == HashTrieSet({"bar", "baz", "quux"}) + True + + >>> L = List([1, 3, 5]) + >>> L.push_front(-1) == List([-1, 1, 3, 5]) + True + >>> L.rest == List([3, 5]) + True + + +.. toctree:: + :glob: + :hidden: + + api diff --git a/docs/requirements.in b/docs/requirements.in new file mode 100644 index 0000000..9fe44c0 --- /dev/null +++ b/docs/requirements.in @@ -0,0 +1,9 @@ +file:.#egg=rpds-py +furo +pygments-github-lexers +sphinx-copybutton +sphinx-json-schema-spec +sphinx>5 +sphinxcontrib-spelling>5 +sphinxext-opengraph +url.py diff --git a/docs/requirements.txt b/docs/requirements.txt new file mode 100644 index 0000000..c91badb --- /dev/null +++ b/docs/requirements.txt @@ -0,0 +1,89 @@ +# +# This file is autogenerated by pip-compile with Python 3.12 +# by the following command: +# +# pip-compile --strip-extras docs/requirements.in +# +alabaster==0.7.13 + # via sphinx +babel==2.14.0 + # via sphinx +beautifulsoup4==4.12.2 + # via furo +certifi==2023.11.17 + # via requests +charset-normalizer==3.3.2 + # via requests +docutils==0.20.1 + # via sphinx +furo==2023.9.10 + # via -r docs/requirements.in +idna==3.6 + # via requests +imagesize==1.4.1 + # via sphinx +jinja2==3.1.2 + # via sphinx +lxml==4.9.3 + # via sphinx-json-schema-spec +markupsafe==2.1.3 + # via jinja2 +packaging==23.2 + # via sphinx +pyenchant==3.2.2 + # via sphinxcontrib-spelling +pygments==2.17.2 + # via + # furo + # pygments-github-lexers + # sphinx +pygments-github-lexers==0.0.5 + # via -r docs/requirements.in +requests==2.31.0 + # via sphinx +file:.#egg=rpds-py + # via -r docs/requirements.in +snowballstemmer==2.2.0 + # via sphinx +soupsieve==2.5 + # via beautifulsoup4 +sphinx==7.2.6 + # via + # -r docs/requirements.in + # furo + # sphinx-basic-ng + # sphinx-copybutton + # sphinx-json-schema-spec + # sphinxcontrib-applehelp + # sphinxcontrib-devhelp + # sphinxcontrib-htmlhelp + # sphinxcontrib-qthelp + # sphinxcontrib-serializinghtml + # sphinxcontrib-spelling + # sphinxext-opengraph +sphinx-basic-ng==1.0.0b2 + # via furo +sphinx-copybutton==0.5.2 + # via -r docs/requirements.in +sphinx-json-schema-spec==2023.8.1 + # via -r docs/requirements.in +sphinxcontrib-applehelp==1.0.7 + # via sphinx +sphinxcontrib-devhelp==1.0.5 + # via sphinx +sphinxcontrib-htmlhelp==2.0.4 + # via sphinx +sphinxcontrib-jsmath==1.0.1 + # via sphinx +sphinxcontrib-qthelp==1.0.6 + # via sphinx +sphinxcontrib-serializinghtml==1.1.9 + # via sphinx +sphinxcontrib-spelling==8.0.0 + # via -r docs/requirements.in +sphinxext-opengraph==0.9.1 + # via -r docs/requirements.in +url-py==0.10.0 + # via -r docs/requirements.in +urllib3==2.1.0 + # via requests diff --git a/docs/spelling-wordlist.txt b/docs/spelling-wordlist.txt new file mode 100644 index 0000000..e69de29 From 98e1c7ca651f32a4a808e4a5a4516800cf60e6f6 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Sun, 17 Dec 2023 12:04:33 -0500 Subject: [PATCH 084/241] Enable the rest of the ruff rulesets. Bring the rest of the scaffolding up to date. --- noxfile.py | 123 +++++++++++++++++++++++++++++++++--- pyproject.toml | 97 +++++++++++++++++++++++++++- rpds.pyi | 73 ++++++++++----------- tests/__init__.py | 0 tests/requirements.txt | 8 +-- tests/test_hash_trie_map.py | 10 +-- tests/test_hash_trie_set.py | 4 +- 7 files changed, 259 insertions(+), 56 deletions(-) create mode 100644 tests/__init__.py diff --git a/noxfile.py b/noxfile.py index 30e9eb1..cd1da6d 100644 --- a/noxfile.py +++ b/noxfile.py @@ -1,52 +1,159 @@ from pathlib import Path from tempfile import TemporaryDirectory +import os import nox ROOT = Path(__file__).parent TESTS = ROOT / "tests" PYPROJECT = ROOT / "pyproject.toml" +DOCS = ROOT / "docs" +REQUIREMENTS = dict( + docs=DOCS / "requirements.txt", + tests=TESTS / "requirements.txt", +) +REQUIREMENTS_IN = [ # this is actually ordered, as files depend on each other + path.parent / f"{path.stem}.in" for path in REQUIREMENTS.values() +] + +SUPPORTED = ["3.8", "3.9", "3.10", "3.11", "3.12", "pypy3.10"] +LATEST = "3.12" nox.options.sessions = [] -def session(default=True, **kwargs): +def session(default=True, python=LATEST, **kwargs): # noqa: D103 def _session(fn): if default: nox.options.sessions.append(kwargs.get("name", fn.__name__)) - return nox.session(**kwargs)(fn) + return nox.session(python=python, **kwargs)(fn) return _session -@session(python=["3.8", "3.9", "3.10", "3.11", "3.12", "pypy3"]) +@session(python=SUPPORTED) def tests(session): - session.install(ROOT, "-r", TESTS / "requirements.txt") - if session.posargs == ["coverage"]: + """ + Run the test suite with a corresponding Python version. + """ + session.install("-r", REQUIREMENTS["tests"]) + + if session.posargs and session.posargs[0] == "coverage": + if len(session.posargs) > 1 and session.posargs[1] == "github": + github = Path(os.environ["GITHUB_STEP_SUMMARY"]) + else: + github = None + session.install("coverage[toml]") - session.run("coverage", "run", "-m", "pytest") - session.run("coverage", "report") + session.run("coverage", "run", "-m", "pytest", TESTS) + if github is None: + session.run("coverage", "report") + else: + with github.open("a") as summary: + summary.write("### Coverage\n\n") + summary.flush() # without a flush, output seems out of order. + session.run( + "coverage", + "report", + "--format=markdown", + stdout=summary, + ) else: session.run("pytest", *session.posargs, TESTS) +@session() +def audit(session): + """ + Audit dependencies for vulnerabilities. + """ + session.install("pip-audit", ROOT) + session.run("python", "-m", "pip_audit") + + @session(tags=["build"]) def build(session): + """ + Build a distribution suitable for PyPI and check its validity. + """ session.install("build", "twine") with TemporaryDirectory() as tmpdir: session.run("python", "-m", "build", ROOT, "--outdir", tmpdir) session.run("twine", "check", "--strict", tmpdir + "/*") +@session(tags=["style"]) +def style(session): + """ + Check Python code style. + """ + session.install("ruff") + session.run("ruff", "check", ROOT) + + +@session(tags=["docs"]) +@nox.parametrize( + "builder", + [ + nox.param(name, id=name) + for name in [ + "dirhtml", + "doctest", + "linkcheck", + "man", + "spelling", + ] + ], +) +def docs(session, builder): + """ + Build the documentation using a specific Sphinx builder. + """ + session.install("-r", REQUIREMENTS["docs"]) + with TemporaryDirectory() as tmpdir_str: + tmpdir = Path(tmpdir_str) + argv = ["-n", "-T", "-W"] + if builder != "spelling": + argv += ["-q"] + posargs = session.posargs or [tmpdir / builder] + session.run( + "python", + "-m", + "sphinx", + "-b", + builder, + DOCS, + *argv, + *posargs, + ) + + +@session(tags=["docs", "style"], name="docs(style)") +def docs_style(session): + """ + Check the documentation style. + """ + session.install( + "doc8", + "pygments", + "pygments-github-lexers", + ) + session.run("python", "-m", "doc8", "--config", PYPROJECT, DOCS) + + @session(default=False) def requirements(session): + """ + Update the project's pinned requirements. Commit the result. + """ session.install("pip-tools") - for each in [TESTS / "requirements.in"]: + for each in REQUIREMENTS_IN: session.run( "pip-compile", "--resolver", "backtracking", + "--strip-extras", "-U", each.relative_to(ROOT), ) diff --git a/pyproject.toml b/pyproject.toml index 6dd0c22..69b34e4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,9 +5,9 @@ build-backend = "maturin" [project] name = "rpds-py" description = "Python bindings to Rust's persistent data structures (rpds)" +requires-python = ">=3.8" readme = "README.rst" license = {text = "MIT"} -requires-python = ">=3.8" keywords = ["data structures", "rust", "persistent"] authors = [ {email = "Julian+rpds@GrayVines.com"}, @@ -31,6 +31,7 @@ classifiers = [ dynamic = ["version"] [project.urls] +Documentation = "https://rpds.readthedocs.io/" Homepage = "https://github.com/crate-py/rpds" Issues = "https://github.com/crate-py/rpds/issues/" Funding = "https://github.com/sponsors/Julian" @@ -40,12 +41,106 @@ Source = "https://github.com/crate-py/rpds" [tool.black] line-length = 79 +[tool.coverage.html] +show_contexts = true +skip_covered = false + +[tool.coverage.run] +branch = true +dynamic_context = "test_function" + +[tool.coverage.report] +exclude_also = [ + "if TYPE_CHECKING:", + "\\s*\\.\\.\\.\\s*", +] +fail_under = 100 +show_missing = true +skip_covered = true + +[tool.doc8] +ignore = [ + "D000", # see PyCQA/doc8#125 + "D001", # one sentence per line, so max length doesn't make sense +] + [tool.isort] combine_as_imports = true +ensure_newline_before_comments = true from_first = true include_trailing_comma = true multi_line_output = 3 known_first_party = ["rpds"] +use_parentheses = true [tool.maturin] features = ["pyo3/extension-module"] + +[tool.pyright] +reportUnnecessaryTypeIgnoreComment = true +strict = ["**/*"] +exclude = [ + "**/tests/__init__.py", + "**/tests/test_*.py", +] + +[tool.ruff] +line-length = 79 +select = ["ALL"] +ignore = [ + "A001", # It's fine to shadow builtins + "A002", + "A003", + "ARG", # This is all wrong whenever an interface is involved + "ANN", # Just let the type checker do this + "B008", # It's totally OK to call functions for default arguments. + "B904", # raise SomeException(...) is fine. + "B905", # No need for explicit strict, this is simply zip's default behavior + "C408", # Calling dict is fine when it saves quoting the keys + "C901", # Not really something to focus on + "D105", # It's fine to not have docstrings for magic methods. + "D107", # __init__ especially doesn't need a docstring + "D200", # This rule makes diffs uglier when expanding docstrings + "D203", # No blank lines before docstrings. + "D212", # Start docstrings on the second line. + "D400", # This rule misses sassy docstrings ending with ! or ? + "D401", # This rule is too flaky. + "D406", # Section headers should end with a colon not a newline + "D407", # Underlines aren't needed + "D412", # Plz spaces after section headers + "EM101", # These don't bother me, it's fine there's some duplication. + "EM102", + "FBT", # It's worth avoiding boolean args but I don't care to enforce it + "FIX", # Yes thanks, if I could it wouldn't be there + "I001", # We can't yet use ruff's isort + "N", # These naming rules are silly + "PLR0912", # These metrics are fine to be aware of but not to enforce + "PLR0913", + "PLR0915", + "PLW2901", # Shadowing for loop variables is occasionally fine. + "PT006", # pytest parametrize takes strings as well + "PYI025", # wat, I'm not confused, thanks. + "RET502", # Returning None implicitly is fine + "RET503", + "RET505", # These push you to use `if` instead of `elif`, but for no reason + "RET506", + "RSE102", # Ha, what, who even knew you could leave the parens off. But no. + "SIM300", # Not sure what heuristic this uses, but it's easily incorrect + "SLF001", # Private usage within this package itself is fine + "TD", # These TODO style rules are also silly + "UP007", # We support 3.8 + 3.9 +] +[tool.ruff.lint.flake8-pytest-style] +mark-parentheses = false + +[tool.ruff.flake8-quotes] +docstring-quotes = "double" + +[tool.ruff.lint.isort] +combine-as-imports = true +from-first = true + +[tool.ruff.per-file-ignores] +"noxfile.py" = ["ANN", "D100", "S101", "T201"] +"docs/*" = ["ANN", "D", "INP001"] +"tests/*" = ["ANN", "B018", "D", "PLR", "RUF012", "S", "SIM", "TRY"] diff --git a/rpds.pyi b/rpds.pyi index 9f08b65..417ed22 100644 --- a/rpds.pyi +++ b/rpds.pyi @@ -1,5 +1,4 @@ from typing import ( - FrozenSet, ItemsView, Iterable, Iterator, @@ -9,55 +8,57 @@ from typing import ( ValuesView, ) -T = TypeVar("T") -KT = TypeVar("KT", covariant=True) -VT = TypeVar("VT", covariant=True) +_T = TypeVar("_T") +_KT_co = TypeVar("_KT_co", covariant=True) +_VT_co = TypeVar("_VT_co", covariant=True) -class HashTrieMap(Mapping[KT, VT]): +class HashTrieMap(Mapping[_KT_co, _VT_co]): def __init__( self, - value: Mapping[KT, VT] | Iterable[tuple[KT, VT]] = {}, - **kwds: Mapping[KT, VT], + value: Mapping[_KT_co, _VT_co] | Iterable[tuple[_KT_co, _VT_co]] = {}, + **kwds: Mapping[_KT_co, _VT_co], ): ... - def __getitem__(self, key: KT) -> VT: ... - def __iter__(self) -> Iterator[KT]: ... + def __getitem__(self, key: _KT_co) -> _VT_co: ... + def __iter__(self) -> Iterator[_KT_co]: ... def __len__(self) -> int: ... - def discard(self, key: KT) -> "HashTrieMap[KT, VT]": ... - def items(self) -> ItemsView[KT, VT]: ... - def keys(self) -> KeysView[KT]: ... - def values(self) -> ValuesView[VT]: ... - def remove(self, key: KT) -> "HashTrieMap[KT, VT]": ... - def insert(self, key: KT, val: VT) -> "HashTrieMap[KT, VT]": ... + def discard(self, key: _KT_co) -> HashTrieMap[_KT_co, _VT_co]: ... + def items(self) -> ItemsView[_KT_co, _VT_co]: ... + def keys(self) -> KeysView[_KT_co]: ... + def values(self) -> ValuesView[_VT_co]: ... + def remove(self, key: _KT_co) -> HashTrieMap[_KT_co, _VT_co]: ... + def insert( + self, key: _KT_co, val: _VT_co + ) -> HashTrieMap[_KT_co, _VT_co]: ... def update(self, *args: Mapping): ... @classmethod def convert( cls, - value: Mapping[KT, VT] | Iterable[tuple[KT, VT]], - ) -> "HashTrieMap[KT, VT]": ... + value: Mapping[_KT_co, _VT_co] | Iterable[tuple[_KT_co, _VT_co]], + ) -> HashTrieMap[_KT_co, _VT_co]: ... -class HashTrieSet(FrozenSet[T]): - def __init__(self, value: Iterable[T] = ()): ... - def __iter__(self) -> Iterator[T]: ... +class HashTrieSet(frozenset[_T]): + def __init__(self, value: Iterable[_T] = ()): ... + def __iter__(self) -> Iterator[_T]: ... def __len__(self) -> int: ... - def discard(self, value: T) -> "HashTrieSet[T]": ... - def remove(self, value: T) -> "HashTrieSet[T]": ... - def insert(self, value: T) -> "HashTrieSet[T]": ... - def update(self, *args: Iterable[T]) -> "HashTrieSet[T]": ... + def discard(self, value: _T) -> HashTrieSet[_T]: ... + def remove(self, value: _T) -> HashTrieSet[_T]: ... + def insert(self, value: _T) -> HashTrieSet[_T]: ... + def update(self, *args: Iterable[_T]) -> HashTrieSet[_T]: ... -class List(Iterable[T]): - def __init__(self, value: Iterable[T] = (), *more: T): ... - def __iter__(self) -> Iterator[T]: ... +class List(Iterable[_T]): + def __init__(self, value: Iterable[_T] = (), *more: _T): ... + def __iter__(self) -> Iterator[_T]: ... def __len__(self) -> int: ... - def push_front(self, value: T) -> "List[T]": ... - def drop_first(self) -> "List[T]": ... + def push_front(self, value: _T) -> List[_T]: ... + def drop_first(self) -> List[_T]: ... -class Queue(Iterable[T]): - def __init__(self, value: Iterable[T] = (), *more: T): ... - def __iter__(self) -> Iterator[T]: ... +class Queue(Iterable[_T]): + def __init__(self, value: Iterable[_T] = (), *more: _T): ... + def __iter__(self) -> Iterator[_T]: ... def __len__(self) -> int: ... - def enqueue(self, T) -> "Queue[T]": ... - def dequeue(self, T) -> "Queue[T]": ... + def enqueue(self, _T) -> Queue[_T]: ... + def dequeue(self, _T) -> Queue[_T]: ... @property - def is_empty(self) -> T: ... + def is_empty(self) -> _T: ... @property - def peek(self) -> T: ... + def peek(self) -> _T: ... diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/requirements.txt b/tests/requirements.txt index 8b2acf1..ea16efd 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -1,14 +1,14 @@ # -# This file is autogenerated by pip-compile with Python 3.11 +# This file is autogenerated by pip-compile with Python 3.12 # by the following command: # -# pip-compile tests/requirements.in +# pip-compile --strip-extras tests/requirements.in # iniconfig==2.0.0 # via pytest -packaging==23.1 +packaging==23.2 # via pytest pluggy==1.3.0 # via pytest -pytest==7.4.2 +pytest==7.4.3 # via -r tests/requirements.in diff --git a/tests/test_hash_trie_map.py b/tests/test_hash_trie_map.py index a94d0f6..9a6b672 100644 --- a/tests/test_hash_trie_map.py +++ b/tests/test_hash_trie_map.py @@ -169,7 +169,7 @@ def test_same_hash_when_content_the_same_but_underlying_vector_size_differs(): x = x.remove(z) assert x == y - # assert hash(x) == hash(y) + # assert hash(x) == hash(y) # noqa: ERA001 class HashabilityControlled: @@ -263,7 +263,7 @@ def __eq__(self, other): def test_iteration_with_many_elements(): - values = list(range(0, 2000)) + values = list(range(2000)) keys = [str(x) for x in values] init_dict = dict(zip(keys, values)) @@ -283,8 +283,8 @@ def test_iteration_with_many_elements(): actual_values.add(v) actual_keys.add(k) - assert actual_keys == set(keys + [hash_dummy1, hash_dummy2]) - assert actual_values == set(values + [12345, 54321]) + assert actual_keys == {*keys, hash_dummy1, hash_dummy2} + assert actual_values == {*values, 12345, 54321} def test_repr(): @@ -337,7 +337,7 @@ def test_more_eq(): def test_pickle(): assert pickle.loads( - pickle.dumps(HashTrieMap([(1, 2), (3, 4)])) + pickle.dumps(HashTrieMap([(1, 2), (3, 4)])), ) == HashTrieMap([(1, 2), (3, 4)]) diff --git a/tests/test_hash_trie_set.py b/tests/test_hash_trie_set.py index 8048251..88180c8 100644 --- a/tests/test_hash_trie_set.py +++ b/tests/test_hash_trie_set.py @@ -142,7 +142,7 @@ def test_repr(): def test_update(): assert HashTrieSet([1, 2, 3]).update([3, 4, 4, 5]) == HashTrieSet( - [1, 2, 3, 4, 5] + [1, 2, 3, 4, 5], ) @@ -187,5 +187,5 @@ def test_more_set_comparisons(): def test_pickle(): assert pickle.loads( - pickle.dumps(HashTrieSet([1, 2, 3, 4])) + pickle.dumps(HashTrieSet([1, 2, 3, 4])), ) == HashTrieSet([1, 2, 3, 4]) From 27d6caf11aac8170e2e9fd56042f05ab27cdb580 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Sun, 17 Dec 2023 12:11:05 -0500 Subject: [PATCH 085/241] Still install the package obviously, and minor spelling and style fix. --- docs/spelling-wordlist.txt | 3 +++ rpds.pyi | 4 +++- tests/requirements.in | 1 + tests/requirements.txt | 2 ++ 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/spelling-wordlist.txt b/docs/spelling-wordlist.txt index e69de29..15c6650 100644 --- a/docs/spelling-wordlist.txt +++ b/docs/spelling-wordlist.txt @@ -0,0 +1,3 @@ +iter +len +toolchain diff --git a/rpds.pyi b/rpds.pyi index 417ed22..b5dcf64 100644 --- a/rpds.pyi +++ b/rpds.pyi @@ -27,7 +27,9 @@ class HashTrieMap(Mapping[_KT_co, _VT_co]): def values(self) -> ValuesView[_VT_co]: ... def remove(self, key: _KT_co) -> HashTrieMap[_KT_co, _VT_co]: ... def insert( - self, key: _KT_co, val: _VT_co + self, + key: _KT_co, + val: _VT_co, ) -> HashTrieMap[_KT_co, _VT_co]: ... def update(self, *args: Mapping): ... @classmethod diff --git a/tests/requirements.in b/tests/requirements.in index e079f8a..1c3a2db 100644 --- a/tests/requirements.in +++ b/tests/requirements.in @@ -1 +1,2 @@ +file:.#egg=rpds-py pytest diff --git a/tests/requirements.txt b/tests/requirements.txt index ea16efd..ba29746 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -12,3 +12,5 @@ pluggy==1.3.0 # via pytest pytest==7.4.3 # via -r tests/requirements.in +file:.#egg=rpds-py + # via -r tests/requirements.in From d0dfdf872c80c858416d4c02c732a9ba74043a6a Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Sun, 17 Dec 2023 12:11:47 -0500 Subject: [PATCH 086/241] Release v0.15.0 for docs! --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7d906fe..cb6a7cb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -195,7 +195,7 @@ dependencies = [ [[package]] name = "rpds-py" -version = "0.14.2" +version = "0.15.0" dependencies = [ "archery", "pyo3", diff --git a/Cargo.toml b/Cargo.toml index aee2783..6a931a7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rpds-py" -version = "0.14.2" +version = "0.15.0" edition = "2021" [lib] From bc5dc1869be37729cfebd23a6df8eb1c953e331e Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Sun, 17 Dec 2023 12:14:28 -0500 Subject: [PATCH 087/241] Install cargo in RTD. --- .readthedocs.yml | 1 + Cargo.lock | 2 +- Cargo.toml | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.readthedocs.yml b/.readthedocs.yml index e6ab173..a6caba1 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -4,6 +4,7 @@ build: os: ubuntu-22.04 tools: python: "3.11" + rust: "1.70" sphinx: builder: dirhtml diff --git a/Cargo.lock b/Cargo.lock index cb6a7cb..df8c3f3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -195,7 +195,7 @@ dependencies = [ [[package]] name = "rpds-py" -version = "0.15.0" +version = "0.15.1" dependencies = [ "archery", "pyo3", diff --git a/Cargo.toml b/Cargo.toml index 6a931a7..40ffa0f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rpds-py" -version = "0.15.0" +version = "0.15.1" edition = "2021" [lib] From 73b17e2ec1939a24e6996aaf65907808a15c217b Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Sun, 17 Dec 2023 13:21:37 -0500 Subject: [PATCH 088/241] Fix the Queue type annotations. --- Cargo.lock | 2 +- Cargo.toml | 2 +- rpds.pyi | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index df8c3f3..9d31d03 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -195,7 +195,7 @@ dependencies = [ [[package]] name = "rpds-py" -version = "0.15.1" +version = "0.15.2" dependencies = [ "archery", "pyo3", diff --git a/Cargo.toml b/Cargo.toml index 40ffa0f..21e790c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rpds-py" -version = "0.15.1" +version = "0.15.2" edition = "2021" [lib] diff --git a/rpds.pyi b/rpds.pyi index b5dcf64..0104d79 100644 --- a/rpds.pyi +++ b/rpds.pyi @@ -58,8 +58,8 @@ class Queue(Iterable[_T]): def __init__(self, value: Iterable[_T] = (), *more: _T): ... def __iter__(self) -> Iterator[_T]: ... def __len__(self) -> int: ... - def enqueue(self, _T) -> Queue[_T]: ... - def dequeue(self, _T) -> Queue[_T]: ... + def enqueue(self, value: _T) -> Queue[_T]: ... + def dequeue(self, value: _T) -> Queue[_T]: ... @property def is_empty(self) -> _T: ... @property From b05c56af481e2ac942f7f142556f617409700659 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 25 Dec 2023 20:51:41 +0000 Subject: [PATCH 089/241] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/PyCQA/isort: 5.13.1 → 5.13.2](https://github.com/PyCQA/isort/compare/5.13.1...5.13.2) - [github.com/psf/black: 23.11.0 → 23.12.1](https://github.com/psf/black/compare/23.11.0...23.12.1) - [github.com/pre-commit/mirrors-prettier: v4.0.0-alpha.4 → v4.0.0-alpha.8](https://github.com/pre-commit/mirrors-prettier/compare/v4.0.0-alpha.4...v4.0.0-alpha.8) --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d6bde62..33116e7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -24,7 +24,7 @@ repos: - id: fmt - id: clippy - repo: https://github.com/PyCQA/isort - rev: 5.13.1 + rev: 5.13.2 hooks: - id: isort - repo: https://github.com/asottile/pyupgrade @@ -32,10 +32,10 @@ repos: hooks: - id: pyupgrade - repo: https://github.com/psf/black - rev: 23.11.0 + rev: 23.12.1 hooks: - id: black - repo: https://github.com/pre-commit/mirrors-prettier - rev: "v4.0.0-alpha.4" + rev: "v4.0.0-alpha.8" hooks: - id: prettier From 4fe2bf8bf3ae207f7564bd018809946e8712b6fc Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Thu, 28 Dec 2023 14:28:00 -0500 Subject: [PATCH 090/241] Add HashTrieMap.fromkeys with dict.fromkeys' signature. --- src/lib.rs | 17 +++++++++++++++++ tests/test_hash_trie_map.py | 24 ++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 65846f1..c8f4a04 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -191,6 +191,23 @@ impl HashTrieMapPy { } } + #[classmethod] + fn fromkeys( + _cls: &PyType, + keys: &PyAny, + val: Option<&PyAny>, + py: Python, + ) -> PyResult { + let mut inner = HashTrieMap::new_sync(); + let none = py.None(); + let value = val.unwrap_or_else(|| none.as_ref(py)); + for each in keys.iter()? { + let key = Key::extract(each?)?.to_owned(); + inner.insert_mut(key, value.into()); + } + Ok(HashTrieMapPy { inner }) + } + fn get(&self, key: Key, default: Option) -> Option { if let Some(value) = self.inner.get(&key) { Some(value.to_owned()) diff --git a/tests/test_hash_trie_map.py b/tests/test_hash_trie_map.py index 9a6b672..9f7d75d 100644 --- a/tests/test_hash_trie_map.py +++ b/tests/test_hash_trie_map.py @@ -346,3 +346,27 @@ def test_get(): assert m1.get("foo") == "bar" assert m1.get("baz") is None assert m1.get("spam", "eggs") == "eggs" + + +def test_fromkeys(): + keys = list(range(10)) + got = HashTrieMap.fromkeys(keys) + expected = HashTrieMap((i, None) for i in keys) + assert got == HashTrieMap(dict.fromkeys(keys)) == expected + + +def test_fromkeys_explicit_value(): + keys = list(range(10)) + expected = HashTrieMap((i, "foo") for i in keys) + got = HashTrieMap.fromkeys(keys, "foo") + expected = HashTrieMap((i, "foo") for i in keys) + assert got == HashTrieMap(dict.fromkeys(keys, "foo")) == expected + + +def test_fromkeys_explicit_value_not_copied(): + keys = list(range(5)) + + got = HashTrieMap.fromkeys(keys, []) + got[3].append(1) + + assert got == HashTrieMap((i, [1]) for i in keys) From caa4511d44d7539dd6abf95b7d28158889224e8d Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Thu, 28 Dec 2023 14:29:01 -0500 Subject: [PATCH 091/241] Release v0.16.1 --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9d31d03..9239de4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -195,7 +195,7 @@ dependencies = [ [[package]] name = "rpds-py" -version = "0.15.2" +version = "0.16.1" dependencies = [ "archery", "pyo3", diff --git a/Cargo.toml b/Cargo.toml index 21e790c..4afc7a5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rpds-py" -version = "0.15.2" +version = "0.16.1" edition = "2021" [lib] From 5a93a4ada6951f3677707e480fe262b3d588edad Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Thu, 28 Dec 2023 15:24:58 -0500 Subject: [PATCH 092/241] Type annotation for fromkeys. --- Cargo.lock | 2 +- Cargo.toml | 2 +- rpds.pyi | 6 ++++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9239de4..9838e9b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -195,7 +195,7 @@ dependencies = [ [[package]] name = "rpds-py" -version = "0.16.1" +version = "0.16.2" dependencies = [ "archery", "pyo3", diff --git a/Cargo.toml b/Cargo.toml index 4afc7a5..dc061ce 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rpds-py" -version = "0.16.1" +version = "0.16.2" edition = "2021" [lib] diff --git a/rpds.pyi b/rpds.pyi index 0104d79..0125868 100644 --- a/rpds.pyi +++ b/rpds.pyi @@ -37,6 +37,12 @@ class HashTrieMap(Mapping[_KT_co, _VT_co]): cls, value: Mapping[_KT_co, _VT_co] | Iterable[tuple[_KT_co, _VT_co]], ) -> HashTrieMap[_KT_co, _VT_co]: ... + @classmethod + def fromkeys( + cls, + keys: Iterable[_KT_co], + value: _VT_co = None, + ) -> HashTrieMap[_KT_co, _VT_co]: ... class HashTrieSet(frozenset[_T]): def __init__(self, value: Iterable[_T] = ()): ... From c9b6d5dde5c7c6aafe728142e231abe8bdfcc850 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Jan 2024 18:12:37 +0000 Subject: [PATCH 093/241] Bump pyo3 from 0.20.0 to 0.20.1 Bumps [pyo3](https://github.com/pyo3/pyo3) from 0.20.0 to 0.20.1. - [Release notes](https://github.com/pyo3/pyo3/releases) - [Changelog](https://github.com/PyO3/pyo3/blob/main/CHANGELOG.md) - [Commits](https://github.com/pyo3/pyo3/compare/v0.20.0...v0.20.1) --- updated-dependencies: - dependency-name: pyo3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 20 ++++++++++---------- Cargo.toml | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9838e9b..4fa9975 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -107,9 +107,9 @@ dependencies = [ [[package]] name = "pyo3" -version = "0.20.0" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04e8453b658fe480c3e70c8ed4e3d3ec33eb74988bd186561b0cc66b85c3bc4b" +checksum = "e82ad98ce1991c9c70c3464ba4187337b9c45fcbbb060d46dca15f0c075e14e2" dependencies = [ "cfg-if", "indoc", @@ -124,9 +124,9 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.20.0" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a96fe70b176a89cff78f2fa7b3c930081e163d5379b4dcdf993e3ae29ca662e5" +checksum = "5503d0b3aee2c7a8dbb389cd87cd9649f675d4c7f60ca33699a3e3859d81a891" dependencies = [ "once_cell", "target-lexicon", @@ -134,9 +134,9 @@ dependencies = [ [[package]] name = "pyo3-ffi" -version = "0.20.0" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "214929900fd25e6604661ed9cf349727c8920d47deff196c4e28165a6ef2a96b" +checksum = "18a79e8d80486a00d11c0dcb27cd2aa17c022cc95c677b461f01797226ba8f41" dependencies = [ "libc", "pyo3-build-config", @@ -144,9 +144,9 @@ dependencies = [ [[package]] name = "pyo3-macros" -version = "0.20.0" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dac53072f717aa1bfa4db832b39de8c875b7c7af4f4a6fe93cdbf9264cf8383b" +checksum = "1f4b0dc7eaa578604fab11c8c7ff8934c71249c61d4def8e272c76ed879f03d4" dependencies = [ "proc-macro2", "pyo3-macros-backend", @@ -156,9 +156,9 @@ dependencies = [ [[package]] name = "pyo3-macros-backend" -version = "0.20.0" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7774b5a8282bd4f25f803b1f0d945120be959a36c72e08e7cd031c792fdfd424" +checksum = "816a4f709e29ddab2e3cdfe94600d554c5556cad0ddfeea95c47b580c3247fa4" dependencies = [ "heck", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index dc061ce..8bc5d3e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,5 +12,5 @@ rpds = "1.1.0" archery = "1.1.0" [dependencies.pyo3] -version = "0.20.0" +version = "0.20.1" features = ["extension-module"] From 4eea436f25ed98e6bfa2e7ed70355eae10c1de06 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 Jan 2024 18:15:51 +0000 Subject: [PATCH 094/241] Bump pyo3 from 0.20.1 to 0.20.2 Bumps [pyo3](https://github.com/pyo3/pyo3) from 0.20.1 to 0.20.2. - [Release notes](https://github.com/pyo3/pyo3/releases) - [Changelog](https://github.com/PyO3/pyo3/blob/main/CHANGELOG.md) - [Commits](https://github.com/pyo3/pyo3/compare/v0.20.1...v0.20.2) --- updated-dependencies: - dependency-name: pyo3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 20 ++++++++++---------- Cargo.toml | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4fa9975..6eef69f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -107,9 +107,9 @@ dependencies = [ [[package]] name = "pyo3" -version = "0.20.1" +version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e82ad98ce1991c9c70c3464ba4187337b9c45fcbbb060d46dca15f0c075e14e2" +checksum = "9a89dc7a5850d0e983be1ec2a463a171d20990487c3cfcd68b5363f1ee3d6fe0" dependencies = [ "cfg-if", "indoc", @@ -124,9 +124,9 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.20.1" +version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5503d0b3aee2c7a8dbb389cd87cd9649f675d4c7f60ca33699a3e3859d81a891" +checksum = "07426f0d8fe5a601f26293f300afd1a7b1ed5e78b2a705870c5f30893c5163be" dependencies = [ "once_cell", "target-lexicon", @@ -134,9 +134,9 @@ dependencies = [ [[package]] name = "pyo3-ffi" -version = "0.20.1" +version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18a79e8d80486a00d11c0dcb27cd2aa17c022cc95c677b461f01797226ba8f41" +checksum = "dbb7dec17e17766b46bca4f1a4215a85006b4c2ecde122076c562dd058da6cf1" dependencies = [ "libc", "pyo3-build-config", @@ -144,9 +144,9 @@ dependencies = [ [[package]] name = "pyo3-macros" -version = "0.20.1" +version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f4b0dc7eaa578604fab11c8c7ff8934c71249c61d4def8e272c76ed879f03d4" +checksum = "05f738b4e40d50b5711957f142878cfa0f28e054aa0ebdfc3fd137a843f74ed3" dependencies = [ "proc-macro2", "pyo3-macros-backend", @@ -156,9 +156,9 @@ dependencies = [ [[package]] name = "pyo3-macros-backend" -version = "0.20.1" +version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "816a4f709e29ddab2e3cdfe94600d554c5556cad0ddfeea95c47b580c3247fa4" +checksum = "0fc910d4851847827daf9d6cdd4a823fbdaab5b8818325c5e97a86da79e8881f" dependencies = [ "heck", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index 8bc5d3e..cba2705 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,5 +12,5 @@ rpds = "1.1.0" archery = "1.1.0" [dependencies.pyo3] -version = "0.20.1" +version = "0.20.2" features = ["extension-module"] From d80800531146e97c950fd889d66f0b6afa441b22 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Wed, 10 Jan 2024 15:18:44 -0500 Subject: [PATCH 095/241] Proper List + Queue iterators. We reimplement them, as I can't figure out whether it's feasible to use the existing native Rust Iter implementations. --- src/lib.rs | 52 +++++++++++++++++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 17 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index c8f4a04..88c2ab6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -574,13 +574,12 @@ impl ListPy { } fn __iter__(slf: PyRef<'_, Self>) -> PyResult> { - let iter = slf - .inner - .iter() - .map(|k| k.to_owned()) - .collect::>() - .into_iter(); - Py::new(slf.py(), ListIterator { inner: iter }) + Py::new( + slf.py(), + ListIterator { + inner: slf.inner.clone(), + }, + ) } fn __reversed__(&self) -> ListPy { @@ -627,7 +626,7 @@ impl ListPy { #[pyclass(module = "rpds")] struct ListIterator { - inner: IntoIter, + inner: ListSync, } #[pymethods] @@ -637,7 +636,27 @@ impl ListIterator { } fn __next__(mut slf: PyRefMut<'_, Self>) -> Option { - slf.inner.next() + let first = slf.inner.first()?.to_owned(); + slf.inner = slf.inner.drop_first()?; + Some(first) + } +} + +#[pyclass(module = "rpds")] +struct QueueIterator { + inner: QueueSync, +} + +#[pymethods] +impl QueueIterator { + fn __iter__(slf: PyRef<'_, Self>) -> PyRef<'_, Self> { + slf + } + + fn __next__(mut slf: PyRefMut<'_, Self>) -> Option { + let first = slf.inner.peek()?.to_owned(); + slf.inner = slf.inner.dequeue()?; + Some(first) } } @@ -704,14 +723,13 @@ impl QueuePy { .any(|r| r.unwrap_or(true)) } - fn __iter__(slf: PyRef<'_, Self>) -> PyResult> { - let iter = slf - .inner - .iter() - .map(|k| k.to_owned()) - .collect::>() - .into_iter(); - Py::new(slf.py(), ListIterator { inner: iter }) + fn __iter__(slf: PyRef<'_, Self>) -> PyResult> { + Py::new( + slf.py(), + QueueIterator { + inner: slf.inner.clone(), + }, + ) } fn __len__(&self) -> usize { From e2f2842eb308f57c696795bb73862a106a74713b Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Wed, 10 Jan 2024 15:25:44 -0500 Subject: [PATCH 096/241] Trim down the manual Py wrapping too. --- src/lib.rs | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 88c2ab6..b3afad7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -573,13 +573,10 @@ impl ListPy { } } - fn __iter__(slf: PyRef<'_, Self>) -> PyResult> { - Py::new( - slf.py(), - ListIterator { - inner: slf.inner.clone(), - }, - ) + fn __iter__(slf: PyRef<'_, Self>) -> ListIterator { + ListIterator { + inner: slf.inner.clone(), + } } fn __reversed__(&self) -> ListPy { @@ -723,13 +720,10 @@ impl QueuePy { .any(|r| r.unwrap_or(true)) } - fn __iter__(slf: PyRef<'_, Self>) -> PyResult> { - Py::new( - slf.py(), - QueueIterator { - inner: slf.inner.clone(), - }, - ) + fn __iter__(slf: PyRef<'_, Self>) -> QueueIterator { + QueueIterator { + inner: slf.inner.clone(), + } } fn __len__(&self) -> usize { From 579e1ca5a277e1758a814ad933bf75ae14d573b4 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Wed, 10 Jan 2024 15:35:44 -0500 Subject: [PATCH 097/241] And now an iterator for HashTrieSet. This I'm even less sure is 'optimal' (well it's definitely not fully but even for my level of optimal) -- but I don't see another way to do 'give me an arbitrary element and then the remaining set' other than creating an Iter. --- src/lib.rs | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index b3afad7..9d9365e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -338,14 +338,10 @@ impl HashTrieSetPy { self.symmetric_difference(other) } - fn __iter__(slf: PyRef<'_, Self>) -> PyResult> { - let iter = slf - .inner - .iter() - .map(|k| k.to_owned()) - .collect::>() - .into_iter(); - Py::new(slf.py(), KeyIterator { inner: iter }) + fn __iter__(slf: PyRef<'_, Self>) -> SetIterator { + SetIterator { + inner: slf.inner.clone(), + } } fn __len__(&self) -> usize { @@ -491,6 +487,24 @@ impl HashTrieSetPy { } } +#[pyclass(module = "rpds")] +struct SetIterator { + inner: HashTrieSetSync, +} + +#[pymethods] +impl SetIterator { + fn __iter__(slf: PyRef<'_, Self>) -> PyRef<'_, Self> { + slf + } + + fn __next__(mut slf: PyRefMut<'_, Self>) -> Option { + let first = slf.inner.iter().next()?.to_owned(); + slf.inner = slf.inner.remove(&first); + Some(first) + } +} + #[repr(transparent)] #[pyclass(name = "List", module = "rpds", frozen, sequence)] struct ListPy { From f3d713c72c49a640628e93118a85317aea6f242d Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Wed, 10 Jan 2024 15:58:33 -0500 Subject: [PATCH 098/241] And same for HashTrieMap. --- src/lib.rs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 9d9365e..51a8a17 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,4 @@ use std::hash::{Hash, Hasher}; -use std::vec::IntoIter; use pyo3::exceptions::PyIndexError; use pyo3::pyclass::CompareOp; @@ -111,13 +110,10 @@ impl HashTrieMapPy { self.inner.contains_key(&key) } - fn __iter__(slf: PyRef<'_, Self>) -> PyResult> { - Py::new( - slf.py(), - KeyIterator { - inner: slf.keys().into_iter(), - }, - ) + fn __iter__(slf: PyRef<'_, Self>) -> KeyIterator { + KeyIterator { + inner: slf.inner.clone(), + } } fn __getitem__(&self, key: Key) -> PyResult { @@ -274,7 +270,7 @@ impl HashTrieMapPy { #[pyclass(module = "rpds")] struct KeyIterator { - inner: IntoIter, + inner: HashTrieMapSync, } #[pymethods] @@ -284,7 +280,9 @@ impl KeyIterator { } fn __next__(mut slf: PyRefMut<'_, Self>) -> Option { - slf.inner.next() + let first = slf.inner.keys().next()?.to_owned(); + slf.inner = slf.inner.remove(&first); + Some(first) } } From eacc5f165a5e7e9b23a0b9ea6b93859a0451cbc3 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Thu, 11 Jan 2024 10:15:56 -0500 Subject: [PATCH 099/241] Start reworking the HashTrieMap methods that should return views. --- src/lib.rs | 119 ++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 109 insertions(+), 10 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 51a8a17..20663d1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -110,8 +110,8 @@ impl HashTrieMapPy { self.inner.contains_key(&key) } - fn __iter__(slf: PyRef<'_, Self>) -> KeyIterator { - KeyIterator { + fn __iter__(slf: PyRef<'_, Self>) -> KeysIterator { + KeysIterator { inner: slf.inner.clone(), } } @@ -212,16 +212,22 @@ impl HashTrieMapPy { } } - fn keys(&self) -> Vec { - self.inner.keys().cloned().collect() + fn keys(&self) -> KeysView { + KeysView { + inner: self.inner.clone(), + } } - fn values(&self) -> Vec<&PyObject> { - self.inner.values().collect::>() + fn values(&self) -> ValuesView { + ValuesView { + inner: self.inner.clone(), + } } - fn items(&self) -> Vec<(Key, &PyObject)> { - self.inner.iter().map(|(k, v)| (k.clone(), v)).collect() + fn items(&self) -> ItemsView { + ItemsView { + inner: self.inner.clone(), + } } fn discard(&self, key: Key) -> PyResult { @@ -269,12 +275,12 @@ impl HashTrieMapPy { } #[pyclass(module = "rpds")] -struct KeyIterator { +struct KeysIterator { inner: HashTrieMapSync, } #[pymethods] -impl KeyIterator { +impl KeysIterator { fn __iter__(slf: PyRef<'_, Self>) -> PyRef<'_, Self> { slf } @@ -286,6 +292,99 @@ impl KeyIterator { } } +#[pyclass(module = "rpds")] +struct ValuesIterator { + inner: HashTrieMapSync, +} + +#[pymethods] +impl ValuesIterator { + fn __iter__(slf: PyRef<'_, Self>) -> PyRef<'_, Self> { + slf + } + + fn __next__(mut slf: PyRefMut<'_, Self>) -> Option { + let kv = slf.inner.iter().next()?; + let value = kv.1.to_owned(); + slf.inner = slf.inner.remove(kv.0); + Some(value) + } +} + +#[pyclass(module = "rpds")] +struct ItemsIterator { + inner: HashTrieMapSync, +} + +#[pymethods] +impl ItemsIterator { + fn __iter__(slf: PyRef<'_, Self>) -> PyRef<'_, Self> { + slf + } + + fn __next__(mut slf: PyRefMut<'_, Self>) -> Option<(Key, PyObject)> { + let kv = slf.inner.iter().next()?; + let key = kv.0.to_owned(); + let value = kv.1.to_owned(); + slf.inner = slf.inner.remove(kv.0); + Some((key, value)) + } +} + +#[pyclass(module = "rpds")] +struct KeysView { + inner: HashTrieMapSync, +} + +#[pymethods] +impl KeysView { + fn __iter__(slf: PyRef<'_, Self>) -> KeysIterator { + KeysIterator { + inner: slf.inner.clone(), + } + } + + fn __len__(slf: PyRef<'_, Self>) -> usize { + slf.inner.size() + } +} + +#[pyclass(module = "rpds")] +struct ValuesView { + inner: HashTrieMapSync, +} + +#[pymethods] +impl ValuesView { + fn __iter__(slf: PyRef<'_, Self>) -> ValuesIterator { + ValuesIterator { + inner: slf.inner.clone(), + } + } + + fn __len__(slf: PyRef<'_, Self>) -> usize { + slf.inner.size() + } +} + +#[pyclass(module = "rpds")] +struct ItemsView { + inner: HashTrieMapSync, +} + +#[pymethods] +impl ItemsView { + fn __iter__(slf: PyRef<'_, Self>) -> ItemsIterator { + ItemsIterator { + inner: slf.inner.clone(), + } + } + + fn __len__(slf: PyRef<'_, Self>) -> usize { + slf.inner.size() + } +} + #[repr(transparent)] #[pyclass(name = "HashTrieSet", module = "rpds", frozen)] struct HashTrieSetPy { From fb02a654eb230a700679ee2d80df4af5d2b9bc0b Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Fri, 12 Jan 2024 12:58:13 -0500 Subject: [PATCH 100/241] Reimplement view types for maps. Add tests for the missing pyrsistent functionality, so now these should behave as dict.keys/values/items do. There's plenty of duplication / inefficiency to improve here, but at least we return the right types now, and hopefully PyO3 will eventually make this a bit easier, it's slightly annoying not being able to mixin the collections.abc types. Also fix the ABC situation. --- src/lib.rs | 367 ++++++++++++++++++++++++++++++++++-- tests/test_hash_trie_map.py | 149 ++++++++++++++- tests/test_hash_trie_set.py | 16 ++ 3 files changed, 510 insertions(+), 22 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 20663d1..6046455 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,7 +2,7 @@ use std::hash::{Hash, Hasher}; use pyo3::exceptions::PyIndexError; use pyo3::pyclass::CompareOp; -use pyo3::types::{PyDict, PyIterator, PyTuple, PyType}; +use pyo3::types::{PyDict, PyIterator, PyNone, PyTuple, PyType}; use pyo3::{exceptions::PyKeyError, types::PyMapping}; use pyo3::{prelude::*, AsPyPointer, PyTypeInfo}; use rpds::{ @@ -338,6 +338,75 @@ struct KeysView { #[pymethods] impl KeysView { + fn __contains__(&self, key: Key) -> bool { + self.inner.contains_key(&key) + } + + fn __eq__(slf: PyRef<'_, Self>, other: &PyAny, py: Python) -> PyResult { + let abc = PyModule::import(py, "collections.abc")?; + if !other.is_instance(abc.getattr("Set")?)? || other.len()? != slf.inner.size() { + return Ok(false); + } + for each in other.iter()? { + if !slf.inner.contains_key(&Key::extract(each?)?) { + return Ok(false); + } + } + Ok(true) + } + + fn __lt__(slf: PyRef<'_, Self>, other: &PyAny, py: Python) -> PyResult { + let abc = PyModule::import(py, "collections.abc")?; + if !other.is_instance(abc.getattr("Set")?)? || other.len()? <= slf.inner.size() { + return Ok(false); + } + for each in slf.inner.keys() { + if !other.contains(each.inner.to_owned())? { + return Ok(false); + } + } + Ok(true) + } + + fn __le__(slf: PyRef<'_, Self>, other: &PyAny, py: Python) -> PyResult { + let abc = PyModule::import(py, "collections.abc")?; + if !other.is_instance(abc.getattr("Set")?)? || other.len()? < slf.inner.size() { + return Ok(false); + } + for each in slf.inner.keys() { + if !other.contains(each.inner.to_owned())? { + return Ok(false); + } + } + Ok(true) + } + + fn __gt__(slf: PyRef<'_, Self>, other: &PyAny, py: Python) -> PyResult { + let abc = PyModule::import(py, "collections.abc")?; + if !other.is_instance(abc.getattr("Set")?)? || other.len()? >= slf.inner.size() { + return Ok(false); + } + for each in other.iter()? { + if !slf.inner.contains_key(&Key::extract(each?)?) { + return Ok(false); + } + } + Ok(true) + } + + fn __ge__(slf: PyRef<'_, Self>, other: &PyAny, py: Python) -> PyResult { + let abc = PyModule::import(py, "collections.abc")?; + if !other.is_instance(abc.getattr("Set")?)? || other.len()? > slf.inner.size() { + return Ok(false); + } + for each in other.iter()? { + if !slf.inner.contains_key(&Key::extract(each?)?) { + return Ok(false); + } + } + Ok(true) + } + fn __iter__(slf: PyRef<'_, Self>) -> KeysIterator { KeysIterator { inner: slf.inner.clone(), @@ -347,6 +416,49 @@ impl KeysView { fn __len__(slf: PyRef<'_, Self>) -> usize { slf.inner.size() } + + fn __and__(slf: PyRef<'_, Self>, other: &PyAny) -> PyResult { + KeysView::intersection(slf, other) + } + + fn __or__(slf: PyRef<'_, Self>, other: &PyAny, py: Python) -> PyResult { + KeysView::union(slf, other, py) + } + + fn __repr__(&self, py: Python) -> String { + let contents = self.inner.into_iter().map(|(k, _)| { + k.clone() + .inner + .into_py(py) + .call_method0(py, "__repr__") + .and_then(|r| r.extract(py)) + .unwrap_or("".to_owned()) + }); + format!("keys_view({{{}}})", contents.collect::>().join(", ")) + } + + fn intersection(slf: PyRef<'_, Self>, other: &PyAny) -> PyResult { + // TODO: iterate over the shorter one if it's got a length + let mut inner = HashTrieSet::new_sync(); + for each in other.iter()? { + let key = Key::extract(each?)?; + if slf.inner.contains_key(&key) { + inner.insert_mut(key); + } + } + Ok(HashTrieSetPy { inner }) + } + + fn union(slf: PyRef<'_, Self>, other: &PyAny, py: Python) -> PyResult { + // There doesn't seem to be a low-effort way to get a HashTrieSet out of a map, + // so we just keep our map and add values we'll ignore. + let mut inner = slf.inner.clone(); + let none = PyNone::get(py); + for each in other.iter()? { + inner.insert_mut(Key::extract(each?)?, none.into()); + } + Ok(KeysView { inner }) + } } #[pyclass(module = "rpds")] @@ -365,6 +477,16 @@ impl ValuesView { fn __len__(slf: PyRef<'_, Self>) -> usize { slf.inner.size() } + + fn __repr__(&self, py: Python) -> String { + let contents = self.inner.into_iter().map(|(_, v)| { + v.into_py(py) + .call_method0(py, "__repr__") + .and_then(|r| r.extract(py)) + .unwrap_or("".to_owned()) + }); + format!("values_view([{}])", contents.collect::>().join(", ")) + } } #[pyclass(module = "rpds")] @@ -374,6 +496,13 @@ struct ItemsView { #[pymethods] impl ItemsView { + fn __contains__(slf: PyRef<'_, Self>, item: (Key, &PyAny)) -> PyResult { + if let Some(value) = slf.inner.get(&item.0) { + return item.1.eq(value); + } + Ok(false) + } + fn __iter__(slf: PyRef<'_, Self>) -> ItemsIterator { ItemsIterator { inner: slf.inner.clone(), @@ -383,6 +512,136 @@ impl ItemsView { fn __len__(slf: PyRef<'_, Self>) -> usize { slf.inner.size() } + + fn __eq__(slf: PyRef<'_, Self>, other: &PyAny, py: Python) -> PyResult { + let abc = PyModule::import(py, "collections.abc")?; + if !other.is_instance(abc.getattr("Set")?)? || other.len()? != slf.inner.size() { + return Ok(false); + } + for (k, v) in slf.inner.iter() { + if !other.contains((k.inner.to_owned(), v))? { + return Ok(false); + } + } + Ok(true) + } + + fn __repr__(&self, py: Python) -> String { + let contents = self.inner.into_iter().map(|(k, v)| { + let tuple = PyTuple::new(py, [k.inner.to_owned(), v.to_owned()]); + format!("{:?}", tuple) + }); + format!("items_view([{}])", contents.collect::>().join(", ")) + } + + fn __lt__(slf: PyRef<'_, Self>, other: &PyAny, py: Python) -> PyResult { + let abc = PyModule::import(py, "collections.abc")?; + if !other.is_instance(abc.getattr("Set")?)? || other.len()? <= slf.inner.size() { + return Ok(false); + } + for (k, v) in slf.inner.iter() { + let pair = PyTuple::new(py, [k.inner.to_owned(), v.to_owned()]); + // FIXME: needs to compare + if !other.contains(pair)? { + return Ok(false); + } + } + Ok(true) + } + + fn __le__(slf: PyRef<'_, Self>, other: &PyAny, py: Python) -> PyResult { + let abc = PyModule::import(py, "collections.abc")?; + if !other.is_instance(abc.getattr("Set")?)? || other.len()? < slf.inner.size() { + return Ok(false); + } + for (k, v) in slf.inner.iter() { + let pair = PyTuple::new(py, [k.inner.to_owned(), v.to_owned()]); + // FIXME: needs to compare + if !other.contains(pair)? { + return Ok(false); + } + } + Ok(true) + } + + fn __gt__(slf: PyRef<'_, Self>, other: &PyAny, py: Python) -> PyResult { + let abc = PyModule::import(py, "collections.abc")?; + if !other.is_instance(abc.getattr("Set")?)? || other.len()? >= slf.inner.size() { + return Ok(false); + } + for each in other.iter()? { + let kv = each?; + let k = kv.get_item(0)?; + match slf.inner.get(&Key::extract(k)?) { + Some(value) => { + let pair = PyTuple::new(py, [k, value.as_ref(py)]); + if !pair.eq(kv)? { + return Ok(false); + } + } + None => return Ok(false), + } + } + Ok(true) + } + + fn __ge__(slf: PyRef<'_, Self>, other: &PyAny, py: Python) -> PyResult { + let abc = PyModule::import(py, "collections.abc")?; + if !other.is_instance(abc.getattr("Set")?)? || other.len()? > slf.inner.size() { + return Ok(false); + } + for each in other.iter()? { + let kv = each?; + let k = kv.get_item(0)?; + match slf.inner.get(&Key::extract(k)?) { + Some(value) => { + let pair = PyTuple::new(py, [k, value.as_ref(py)]); + if !pair.eq(kv)? { + return Ok(false); + } + } + None => return Ok(false), + } + } + Ok(true) + } + + fn __and__(slf: PyRef<'_, Self>, other: &PyAny, py: Python) -> PyResult { + ItemsView::intersection(slf, other, py) + } + + fn __or__(slf: PyRef<'_, Self>, other: &PyAny, py: Python) -> PyResult { + ItemsView::union(slf, other, py) + } + + fn intersection(slf: PyRef<'_, Self>, other: &PyAny, py: Python) -> PyResult { + // TODO: iterate over the shorter one if it's got a length + let mut inner = HashTrieSet::new_sync(); + for each in other.iter()? { + let kv = each?; + let k = kv.get_item(0)?; + if let Some(value) = slf.inner.get(&Key::extract(k)?) { + let pair = PyTuple::new(py, [k, value.as_ref(py)]); + if pair.eq(kv)? { + inner.insert_mut(Key::extract(pair)?); + } + } + } + Ok(HashTrieSetPy { inner }) + } + + fn union(slf: PyRef<'_, Self>, other: &PyAny, py: Python) -> PyResult { + // TODO: this is very inefficient, but again can't seem to get a HashTrieSet out of ourself + let mut inner = HashTrieSet::new_sync(); + for (k, v) in slf.inner.iter() { + let pair = PyTuple::new(py, [k.inner.to_owned(), v.to_owned()]); + inner.insert_mut(Key::extract(pair)?); + } + for each in other.iter()? { + inner.insert_mut(Key::extract(each?)?); + } + Ok(HashTrieSetPy { inner }) + } } #[repr(transparent)] @@ -402,10 +661,6 @@ impl<'source> FromPyObject<'source> for HashTrieSetPy { } } -fn is_subset(one: &HashTrieSetSync, two: &HashTrieSetSync) -> bool { - one.iter().all(|v| two.contains(v)) -} - #[pymethods] impl HashTrieSetPy { #[new] @@ -419,6 +674,10 @@ impl HashTrieSetPy { } } + fn __contains__(&self, key: Key) -> bool { + self.inner.contains(&key) + } + fn __and__(&self, other: &Self) -> Self { self.intersection(other) } @@ -459,20 +718,69 @@ impl HashTrieSetPy { ) } - fn __richcmp__(&self, other: &Self, op: CompareOp, py: Python<'_>) -> PyResult { - match op { - CompareOp::Eq => Ok((self.inner.size() == other.inner.size() - && is_subset(&self.inner, &other.inner)) - .into_py(py)), - CompareOp::Ne => Ok((self.inner.size() != other.inner.size() - || self.inner.iter().any(|k| !other.inner.contains(k))) - .into_py(py)), - CompareOp::Lt => Ok((self.inner.size() < other.inner.size() - && is_subset(&self.inner, &other.inner)) - .into_py(py)), - CompareOp::Le => Ok(is_subset(&self.inner, &other.inner).into_py(py)), - _ => Ok(py.NotImplemented()), + fn __eq__(slf: PyRef<'_, Self>, other: &PyAny, py: Python) -> PyResult { + let abc = PyModule::import(py, "collections.abc")?; + if !other.is_instance(abc.getattr("Set")?)? || other.len()? != slf.inner.size() { + return Ok(false); + } + for each in other.iter()? { + if !slf.inner.contains(&Key::extract(each?)?) { + return Ok(false); + } + } + Ok(true) + } + + fn __lt__(slf: PyRef<'_, Self>, other: &PyAny, py: Python) -> PyResult { + let abc = PyModule::import(py, "collections.abc")?; + if !other.is_instance(abc.getattr("Set")?)? || other.len()? <= slf.inner.size() { + return Ok(false); + } + for each in slf.inner.iter() { + if !other.contains(each.inner.to_owned())? { + return Ok(false); + } + } + Ok(true) + } + + fn __le__(slf: PyRef<'_, Self>, other: &PyAny, py: Python) -> PyResult { + let abc = PyModule::import(py, "collections.abc")?; + if !other.is_instance(abc.getattr("Set")?)? || other.len()? < slf.inner.size() { + return Ok(false); + } + for each in slf.inner.iter() { + if !other.contains(each.inner.to_owned())? { + return Ok(false); + } } + Ok(true) + } + + fn __gt__(slf: PyRef<'_, Self>, other: &PyAny, py: Python) -> PyResult { + let abc = PyModule::import(py, "collections.abc")?; + if !other.is_instance(abc.getattr("Set")?)? || other.len()? >= slf.inner.size() { + return Ok(false); + } + for each in other.iter()? { + if !slf.inner.contains(&Key::extract(each?)?) { + return Ok(false); + } + } + Ok(true) + } + + fn __ge__(slf: PyRef<'_, Self>, other: &PyAny, py: Python) -> PyResult { + let abc = PyModule::import(py, "collections.abc")?; + if !other.is_instance(abc.getattr("Set")?)? || other.len()? > slf.inner.size() { + return Ok(false); + } + for each in other.iter()? { + if !slf.inner.contains(&Key::extract(each?)?) { + return Ok(false); + } + } + Ok(true) } fn __reduce__(slf: PyRef) -> (&PyType, (Vec,)) { @@ -885,9 +1193,30 @@ impl QueuePy { #[pyo3(name = "rpds")] fn rpds_py(py: Python, m: &PyModule) -> PyResult<()> { m.add_class::()?; - PyMapping::register::(py)?; m.add_class::()?; m.add_class::()?; m.add_class::()?; + + PyMapping::register::(py)?; + + let abc = PyModule::import(py, "collections.abc")?; + + abc.getattr("Set")? + .call_method1("register", (HashTrieSetPy::type_object(py),))?; + + abc.getattr("MappingView")? + .call_method1("register", (KeysView::type_object(py),))?; + abc.getattr("MappingView")? + .call_method1("register", (ValuesView::type_object(py),))?; + abc.getattr("MappingView")? + .call_method1("register", (ItemsView::type_object(py),))?; + + abc.getattr("KeysView")? + .call_method1("register", (KeysView::type_object(py),))?; + abc.getattr("ValuesView")? + .call_method1("register", (ValuesView::type_object(py),))?; + abc.getattr("ItemsView")? + .call_method1("register", (ItemsView::type_object(py),))?; + Ok(()) } diff --git a/tests/test_hash_trie_map.py b/tests/test_hash_trie_map.py index 9f7d75d..0e52381 100644 --- a/tests/test_hash_trie_map.py +++ b/tests/test_hash_trie_map.py @@ -26,7 +26,8 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ -from collections.abc import Hashable, Mapping +from collections import abc +from operator import methodcaller import pickle import pytest @@ -38,11 +39,11 @@ @pytest.mark.xfail(reason=HASH_MSG) def test_instance_of_hashable(): - assert isinstance(HashTrieMap(), Hashable) + assert isinstance(HashTrieMap(), abc.Hashable) def test_instance_of_map(): - assert isinstance(HashTrieMap(), Mapping) + assert isinstance(HashTrieMap(), abc.Mapping) def test_literalish_works(): @@ -348,6 +349,148 @@ def test_get(): assert m1.get("spam", "eggs") == "eggs" +@pytest.mark.parametrize( + "view", + [pytest.param(methodcaller(p), id=p) for p in ["keys", "values", "items"]], +) +@pytest.mark.parametrize( + "cls", + [ + abc.Set, + abc.MappingView, + abc.KeysView, + abc.ValuesView, + abc.ItemsView, + ], +) +def test_views_abc(view, cls): + m, d = HashTrieMap(), {} + assert isinstance(view(m), cls) == isinstance(view(d), cls) + + +def test_keys(): + k = HashTrieMap({1: 2, 3: 4}).keys() + + assert 1 in k + + assert k == {1, 3} + assert k != iter({1, 3}) + assert k == HashTrieMap({1: 2, 3: 4}).keys() + assert k != {1, 2, 3} + assert k != {1, 4} + assert not k == {1, 4} + + assert k != object() + + +def test_keys_setlike(): + assert {1: 2, 3: 4}.keys() & HashTrieMap({1: 2}).keys() == {1} + assert {1: 2, 3: 4}.keys() & HashTrieMap({1: 2}).keys() != {1, 2} + assert HashTrieMap({1: 2}).keys() & {1: 2, 3: 4}.keys() == {1} + assert HashTrieMap({1: 2}).keys() & {1: 2, 3: 4}.keys() != {2} + assert not HashTrieMap({1: 2}).keys() & {}.keys() + assert HashTrieMap({1: 2}).keys() & {1} == {1} + assert HashTrieMap({1: 2}).keys() & [1] == {1} + + assert HashTrieMap({1: 2}).keys() | {3} == {1, 3} + assert HashTrieMap({1: 2}).keys() | [3] == {1, 3} + + # these don't really exist on the KeysView protocol but it's nice to have + s = (1, "foo") + assert HashTrieMap({1: 2, "foo": 7}).keys().intersection(s) == set(s) + assert not HashTrieMap({1: 2}).keys().intersection({}) + assert HashTrieMap({1: 2}).keys().union({3}) == {1, 3} + + assert HashTrieMap({1: 2, 3: 4}).keys() < {1, 2, 3} + assert HashTrieMap({1: 2, 3: 4}).keys() <= {1, 2, 3} + assert not HashTrieMap({1: 2}).keys() < {1} + assert HashTrieMap({1: 2}).keys() > set() + assert HashTrieMap({1: 2}).keys() >= set() + + +def test_keys_repr(): + m = HashTrieMap({"foo": 3, 37: "bar"}) + assert repr(m.keys()) in { + "keys_view({'foo', 37})", + "keys_view({37, 'foo'})", + } + + +def test_values(): + v = HashTrieMap({1: 2, 3: 4}).values() + assert 2 in v + assert 3 not in v + assert object() not in v + + assert len(v) == 2 + + assert set(v) == {2, 4} + + +def test_values_repr(): + m = HashTrieMap({"foo": 3, 37: "bar", "baz": 3}) + assert repr(m.values()) in { + "values_view(['bar', 3, 3])", + "values_view([3, 'bar', 3])", + "values_view([3, 3, 'bar'])", + } + + +def test_items(): + k = HashTrieMap({1: 2, 3: 4}).items() + + assert (1, 2) in k + + assert k == {(1, 2), (3, 4)} + assert k != iter({(1, 2), (3, 4)}) + assert k != {(1, 2, 3), (3, 4, 5)} + assert k == {1: 2, 3: 4}.items() + assert k != {(1, 2), (3, 4), (5, 6)} + assert k != {(1, 2)} + assert not k == {1, 4} + + assert k != object() + + +def test_items_setlike(): + assert {1: 2, 3: 4}.items() & HashTrieMap({1: 2}).items() == {(1, 2)} + assert {1: 2, 3: 4}.items() & HashTrieMap({1: 2}).items() != {(1, 2), 3} + + assert HashTrieMap({1: 2}).items() & {1: 2, 3: 4}.items() == {(1, 2)} + assert HashTrieMap({1: 2}).items() & {1: 2, 3: 4}.items() != {(3, 4)} + assert not HashTrieMap({1: 2}).items() & {}.items() + + assert HashTrieMap({1: 2}).items() & [(1, 2)] == {(1, 2)} + assert HashTrieMap({1: 2}).items() & [[1, 2]] == set() + + assert HashTrieMap({1: 2}).items() | {(3, 4)} == {(1, 2), (3, 4)} + assert HashTrieMap({1: 2}).items() | [7] == {(1, 2), 7} + + s = ((1, 2), ("foo", 37)) + assert HashTrieMap({1: 2, "foo": 7}).items().intersection(s) == {(1, 2)} + assert not HashTrieMap({1: 2}).items().intersection({}) + + assert HashTrieMap({1: 2}).items().union({3}) == {(1, 2), 3} + + assert HashTrieMap({1: 2, 3: 4}).items() < {(1, 2), (3, 4), ("foo", "bar")} + assert HashTrieMap({1: 2, 3: 4}).items() <= {(1, 2), (3, 4)} + assert not HashTrieMap({1: 2}).keys() < {1} + assert HashTrieMap({1: 2}).items() > set() + assert HashTrieMap({1: 2}).items() >= set() + + +def test_items_repr(): + m = HashTrieMap({"foo": 3, 37: "bar", "baz": 3}) + assert repr(m.items()) in { + "items_view([('foo', 3), (37, 'bar'), ('baz', 3)])", + "items_view([('foo', 3), ('baz', 3), (37, 'bar')])", + "items_view([(37, 'bar'), ('foo', 3), ('baz', 3)])", + "items_view([(37, 'bar'), ('baz', 3), ('foo', 3)])", + "items_view([('baz', 3), (37, 'bar'), ('foo', 3)])", + "items_view([('baz', 3), ('foo', 3), (37, 'bar')])", + } + + def test_fromkeys(): keys = list(range(10)) got = HashTrieMap.fromkeys(keys) diff --git a/tests/test_hash_trie_set.py b/tests/test_hash_trie_set.py index 88180c8..4e607ff 100644 --- a/tests/test_hash_trie_set.py +++ b/tests/test_hash_trie_set.py @@ -26,6 +26,7 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ +from collections import abc import pickle import pytest @@ -174,6 +175,10 @@ def test_more_eq(): assert not (HashTrieSet([o]) != HashTrieSet([o, o])) assert not (HashTrieSet() != HashTrieSet([])) + assert HashTrieSet([1, 2]) == {1, 2} + assert HashTrieSet([1, 2]) != {1, 2, 3} + assert HashTrieSet([1, 2]) != [1, 2] + def test_more_set_comparisons(): s = HashTrieSet([1, 2, 3]) @@ -189,3 +194,14 @@ def test_pickle(): assert pickle.loads( pickle.dumps(HashTrieSet([1, 2, 3, 4])), ) == HashTrieSet([1, 2, 3, 4]) + + +def test_instance_of_set(): + assert isinstance(HashTrieSet(), abc.Set) + + +def test_lt_le_gt_ge(): + assert HashTrieSet({}) < {1} + assert HashTrieSet({}) <= {1} + assert HashTrieSet({1}) > set() + assert HashTrieSet({1}) >= set() From 74a85edb98977efe407c44d5ed366648538e461f Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Fri, 12 Jan 2024 13:04:12 -0500 Subject: [PATCH 101/241] Remove a non-doc dependency. This was just bad copy-paste. --- docs/conf.py | 1 - docs/requirements.in | 1 - docs/requirements.txt | 9 ++------- tests/requirements.txt | 2 +- 4 files changed, 3 insertions(+), 10 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index eb1c0bf..ef63ad2 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -27,7 +27,6 @@ "sphinx.ext.todo", "sphinx.ext.viewcode", "sphinx_copybutton", - "sphinx_json_schema_spec", "sphinxcontrib.spelling", "sphinxext.opengraph", ] diff --git a/docs/requirements.in b/docs/requirements.in index 9fe44c0..01f3186 100644 --- a/docs/requirements.in +++ b/docs/requirements.in @@ -2,7 +2,6 @@ file:.#egg=rpds-py furo pygments-github-lexers sphinx-copybutton -sphinx-json-schema-spec sphinx>5 sphinxcontrib-spelling>5 sphinxext-opengraph diff --git a/docs/requirements.txt b/docs/requirements.txt index c91badb..0ef05bc 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -4,7 +4,7 @@ # # pip-compile --strip-extras docs/requirements.in # -alabaster==0.7.13 +alabaster==0.7.16 # via sphinx babel==2.14.0 # via sphinx @@ -22,10 +22,8 @@ idna==3.6 # via requests imagesize==1.4.1 # via sphinx -jinja2==3.1.2 +jinja2==3.1.3 # via sphinx -lxml==4.9.3 - # via sphinx-json-schema-spec markupsafe==2.1.3 # via jinja2 packaging==23.2 @@ -53,7 +51,6 @@ sphinx==7.2.6 # furo # sphinx-basic-ng # sphinx-copybutton - # sphinx-json-schema-spec # sphinxcontrib-applehelp # sphinxcontrib-devhelp # sphinxcontrib-htmlhelp @@ -65,8 +62,6 @@ sphinx-basic-ng==1.0.0b2 # via furo sphinx-copybutton==0.5.2 # via -r docs/requirements.in -sphinx-json-schema-spec==2023.8.1 - # via -r docs/requirements.in sphinxcontrib-applehelp==1.0.7 # via sphinx sphinxcontrib-devhelp==1.0.5 diff --git a/tests/requirements.txt b/tests/requirements.txt index ba29746..0483d1b 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -10,7 +10,7 @@ packaging==23.2 # via pytest pluggy==1.3.0 # via pytest -pytest==7.4.3 +pytest==7.4.4 # via -r tests/requirements.in file:.#egg=rpds-py # via -r tests/requirements.in From 9c07d534116bc9823121959f035393ce58fd447e Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Fri, 12 Jan 2024 13:49:41 -0500 Subject: [PATCH 102/241] Yet again, same mistake. --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6eef69f..7437af5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -195,7 +195,7 @@ dependencies = [ [[package]] name = "rpds-py" -version = "0.16.2" +version = "0.17.1" dependencies = [ "archery", "pyo3", diff --git a/Cargo.toml b/Cargo.toml index cba2705..6eeb102 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rpds-py" -version = "0.16.2" +version = "0.17.1" edition = "2021" [lib] From ee1bf7ee85ec5358241a93f15b300084070242ae Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Tue, 16 Jan 2024 13:54:43 -0500 Subject: [PATCH 103/241] Explicitly remind ourselves that dict.values != dict.values in the tests. --- tests/test_hash_trie_map.py | 47 +++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 13 deletions(-) diff --git a/tests/test_hash_trie_map.py b/tests/test_hash_trie_map.py index 0e52381..9f7a822 100644 --- a/tests/test_hash_trie_map.py +++ b/tests/test_hash_trie_map.py @@ -369,13 +369,20 @@ def test_views_abc(view, cls): def test_keys(): - k = HashTrieMap({1: 2, 3: 4}).keys() + d = HashTrieMap({1: 2, 3: 4}) + k = d.keys() assert 1 in k + assert 2 not in k + assert object() not in k + assert len(k) == 2 + + assert k == d.keys() + assert k == HashTrieMap({1: 2, 3: 4}).keys() assert k == {1, 3} + assert k != iter({1, 3}) - assert k == HashTrieMap({1: 2, 3: 4}).keys() assert k != {1, 2, 3} assert k != {1, 4} assert not k == {1, 4} @@ -417,13 +424,20 @@ def test_keys_repr(): def test_values(): - v = HashTrieMap({1: 2, 3: 4}).values() + d = HashTrieMap({1: 2, 3: 4}) + v = d.values() + assert 2 in v assert 3 not in v assert object() not in v assert len(v) == 2 + assert v == v + # https://bugs.python.org/issue12445 which was WONTFIXed + assert v != HashTrieMap({1: 2, 3: 4}).values() + assert v != [2, 4] + assert set(v) == {2, 4} @@ -437,19 +451,26 @@ def test_values_repr(): def test_items(): - k = HashTrieMap({1: 2, 3: 4}).items() + d = HashTrieMap({1: 2, 3: 4}) + i = d.items() - assert (1, 2) in k + assert (1, 2) in i + assert (1, 4) not in i - assert k == {(1, 2), (3, 4)} - assert k != iter({(1, 2), (3, 4)}) - assert k != {(1, 2, 3), (3, 4, 5)} - assert k == {1: 2, 3: 4}.items() - assert k != {(1, 2), (3, 4), (5, 6)} - assert k != {(1, 2)} - assert not k == {1, 4} + assert len(i) == 2 - assert k != object() + assert i == d.items() + assert i == HashTrieMap({1: 2, 3: 4}).items() + assert i == {(1, 2), (3, 4)} + + assert i != iter({(1, 2), (3, 4)}) + assert i != {(1, 2, 3), (3, 4, 5)} + assert i == {1: 2, 3: 4}.items() + assert i != {(1, 2), (3, 4), (5, 6)} + assert i != {(1, 2)} + assert not i == {1, 4} + + assert i != object() def test_items_setlike(): From 783e3ef92ff43a1e9b91486f77e921f13e1d4d21 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Fri, 26 Jan 2024 11:28:39 -0500 Subject: [PATCH 104/241] Implement Queue.__hash__. Refs: #50 --- src/lib.rs | 11 +++++++++++ tests/test_queue.py | 18 ++++++++++++------ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 6046455..ad3cce2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,4 @@ +use std::collections::hash_map::DefaultHasher; use std::hash::{Hash, Hasher}; use pyo3::exceptions::PyIndexError; @@ -1129,6 +1130,16 @@ impl QueuePy { .all(|r| r.unwrap_or(false)) } + fn __hash__(&self, py: Python<'_>) -> PyResult { + let hash = PyModule::import(py, "builtins")?.getattr("hash")?; + let mut hasher = DefaultHasher::new(); + for each in &self.inner { + let n: i64 = hash.call1((each.into_py(py),))?.extract()?; + hasher.write_i64(n); + } + Ok(hasher.finish()) + } + fn __ne__(&self, other: &Self, py: Python<'_>) -> bool { (self.inner.len() != other.inner.len()) || self diff --git a/tests/test_queue.py b/tests/test_queue.py index 0ba8f81..4dfde8f 100644 --- a/tests/test_queue.py +++ b/tests/test_queue.py @@ -89,12 +89,6 @@ def test_repr(): assert str(Queue([1, 2, 3])) in "Queue([1, 2, 3])" -@pytest.mark.xfail(reason=HASH_MSG) -def test_hashing(): - assert hash(Queue([1, 2])) == hash(Queue([1, 2])) - assert hash(Queue([1, 2])) != hash(Queue([2, 1])) - - def test_sequence(): m = Queue("asdf") assert m == Queue(["a", "s", "d", "f"]) @@ -131,3 +125,15 @@ def test_more_eq(): assert not (Queue([o, o]) != Queue([o, o])) assert not (Queue([o]) != Queue([o])) assert not (Queue() != Queue([])) + + +def test_hashing(): + assert hash(Queue([1, 2])) == hash(Queue([1, 2])) + assert hash(Queue([1, 2])) != hash(Queue([2, 1])) + assert len({Queue([1, 2]), Queue([1, 2])}) == 1 + + +def test_unhashable_contents(): + q = Queue([1, {1}]) + with pytest.raises(TypeError): + hash(q) From c581b56856dc2ff32c1bb92de3bc009d1e05068c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 29 Jan 2024 20:48:53 +0000 Subject: [PATCH 105/241] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/psf/black: 23.12.1 → 24.1.1](https://github.com/psf/black/compare/23.12.1...24.1.1) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 33116e7..7a25a74 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -32,7 +32,7 @@ repos: hooks: - id: pyupgrade - repo: https://github.com/psf/black - rev: 23.12.1 + rev: 24.1.1 hooks: - id: black - repo: https://github.com/pre-commit/mirrors-prettier From ce4b8bcb1d6eaf274f65cc5f5a610945b6ceba19 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 29 Jan 2024 20:49:05 +0000 Subject: [PATCH 106/241] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_hash_trie_map.py | 1 + tests/test_hash_trie_set.py | 1 + tests/test_list.py | 1 + tests/test_queue.py | 1 + 4 files changed, 4 insertions(+) diff --git a/tests/test_hash_trie_map.py b/tests/test_hash_trie_map.py index 9f7a822..2f93311 100644 --- a/tests/test_hash_trie_map.py +++ b/tests/test_hash_trie_map.py @@ -26,6 +26,7 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ + from collections import abc from operator import methodcaller import pickle diff --git a/tests/test_hash_trie_set.py b/tests/test_hash_trie_set.py index 4e607ff..791c941 100644 --- a/tests/test_hash_trie_set.py +++ b/tests/test_hash_trie_set.py @@ -26,6 +26,7 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ + from collections import abc import pickle diff --git a/tests/test_list.py b/tests/test_list.py index 09ac5cc..ad0864d 100644 --- a/tests/test_list.py +++ b/tests/test_list.py @@ -26,6 +26,7 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ + import pickle import pytest diff --git a/tests/test_queue.py b/tests/test_queue.py index 4dfde8f..402145e 100644 --- a/tests/test_queue.py +++ b/tests/test_queue.py @@ -26,6 +26,7 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ + import pytest from rpds import Queue From d57b92c71bf5614f4308a9979666af1b5f35acb0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 12 Feb 2024 18:36:31 +0000 Subject: [PATCH 107/241] Bump pre-commit/action from 3.0.0 to 3.0.1 Bumps [pre-commit/action](https://github.com/pre-commit/action) from 3.0.0 to 3.0.1. - [Release notes](https://github.com/pre-commit/action/releases) - [Commits](https://github.com/pre-commit/action/compare/v3.0.0...v3.0.1) --- updated-dependencies: - dependency-name: pre-commit/action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 726c582..e6da892 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -22,7 +22,7 @@ jobs: - uses: actions/setup-python@v5 with: python-version: "3.x" - - uses: pre-commit/action@v3.0.0 + - uses: pre-commit/action@v3.0.1 list: runs-on: ubuntu-latest From e3ee7b94b4cd14d6fc7a3588bf8c73e9c08de879 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 13 Feb 2024 00:15:40 +0000 Subject: [PATCH 108/241] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/psf/black: 24.1.1 → 24.2.0](https://github.com/psf/black/compare/24.1.1...24.2.0) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7a25a74..5af51b0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -32,7 +32,7 @@ repos: hooks: - id: pyupgrade - repo: https://github.com/psf/black - rev: 24.1.1 + rev: 24.2.0 hooks: - id: black - repo: https://github.com/pre-commit/mirrors-prettier From ce3bf37dabe9465835190e929296e10eb223cf19 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Tue, 13 Feb 2024 16:40:54 -0500 Subject: [PATCH 109/241] Type annotation and test for HashTrieMap.update. --- Cargo.lock | 2 +- Cargo.toml | 2 +- rpds.pyi | 7 ++++++- tests/test_hash_trie_map.py | 10 ++++++++++ 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7437af5..7447971 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -195,7 +195,7 @@ dependencies = [ [[package]] name = "rpds-py" -version = "0.17.1" +version = "0.18.0" dependencies = [ "archery", "pyo3", diff --git a/Cargo.toml b/Cargo.toml index 6eeb102..78ac37f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rpds-py" -version = "0.17.1" +version = "0.18.0" edition = "2021" [lib] diff --git a/rpds.pyi b/rpds.pyi index 0125868..5af0e32 100644 --- a/rpds.pyi +++ b/rpds.pyi @@ -11,6 +11,8 @@ from typing import ( _T = TypeVar("_T") _KT_co = TypeVar("_KT_co", covariant=True) _VT_co = TypeVar("_VT_co", covariant=True) +_KU_co = TypeVar("_KU_co", covariant=True) +_VU_co = TypeVar("_VU_co", covariant=True) class HashTrieMap(Mapping[_KT_co, _VT_co]): def __init__( @@ -31,7 +33,10 @@ class HashTrieMap(Mapping[_KT_co, _VT_co]): key: _KT_co, val: _VT_co, ) -> HashTrieMap[_KT_co, _VT_co]: ... - def update(self, *args: Mapping): ... + def update( + self, + *args: Mapping[_KU_co, _VU_co] | Iterable[tuple[_KU_co, _VU_co]], + ) -> HashTrieMap[_KT_co | _KU_co, _VT_co | _VU_co]: ... @classmethod def convert( cls, diff --git a/tests/test_hash_trie_map.py b/tests/test_hash_trie_map.py index 2f93311..e65b601 100644 --- a/tests/test_hash_trie_map.py +++ b/tests/test_hash_trie_map.py @@ -535,3 +535,13 @@ def test_fromkeys_explicit_value_not_copied(): got[3].append(1) assert got == HashTrieMap((i, [1]) for i in keys) + + +def test_update_with_iterable_of_kvs(): + assert HashTrieMap({1: 2}).update(iter([(3, 4), ("5", 6)])) == HashTrieMap( + { + 1: 2, + 3: 4, + "5": 6, + }, + ) From 0daaf22042c667060ddeb1831b67bbfb32accbcb Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 20 Feb 2024 00:32:47 +0000 Subject: [PATCH 110/241] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/asottile/pyupgrade: v3.15.0 → v3.15.1](https://github.com/asottile/pyupgrade/compare/v3.15.0...v3.15.1) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5af51b0..d879ba3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -28,7 +28,7 @@ repos: hooks: - id: isort - repo: https://github.com/asottile/pyupgrade - rev: v3.15.0 + rev: v3.15.1 hooks: - id: pyupgrade - repo: https://github.com/psf/black From 7926846452d60f91abd4bd6ae9e69296afa6f7fa Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Wed, 21 Feb 2024 08:52:18 -0500 Subject: [PATCH 111/241] I'm one person, not two. --- pyproject.toml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 69b34e4..94b2c2c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,8 +10,7 @@ readme = "README.rst" license = {text = "MIT"} keywords = ["data structures", "rust", "persistent"] authors = [ - {email = "Julian+rpds@GrayVines.com"}, - {name = "Julian Berman"}, + { name = "Julian Berman", email = "Julian+rpds@GrayVines.com" }, ] classifiers = [ "Development Status :: 3 - Alpha", From f150f9feb3b3b3d20a3210618ba01303672349a5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 26 Feb 2024 18:08:35 +0000 Subject: [PATCH 112/241] Bump pyo3 from 0.20.2 to 0.20.3 Bumps [pyo3](https://github.com/pyo3/pyo3) from 0.20.2 to 0.20.3. - [Release notes](https://github.com/pyo3/pyo3/releases) - [Changelog](https://github.com/PyO3/pyo3/blob/main/CHANGELOG.md) - [Commits](https://github.com/pyo3/pyo3/compare/v0.20.2...v0.20.3) --- updated-dependencies: - dependency-name: pyo3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 28 ++++++++++++++++++---------- Cargo.toml | 2 +- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7447971..3efc2b5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -96,6 +96,12 @@ dependencies = [ "windows-targets", ] +[[package]] +name = "portable-atomic" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7170ef9988bc169ba16dd36a7fa041e5c4cbeb6a35b76d4c03daded371eae7c0" + [[package]] name = "proc-macro2" version = "1.0.66" @@ -107,15 +113,16 @@ dependencies = [ [[package]] name = "pyo3" -version = "0.20.2" +version = "0.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a89dc7a5850d0e983be1ec2a463a171d20990487c3cfcd68b5363f1ee3d6fe0" +checksum = "53bdbb96d49157e65d45cc287af5f32ffadd5f4761438b527b055fb0d4bb8233" dependencies = [ "cfg-if", "indoc", "libc", "memoffset", "parking_lot", + "portable-atomic", "pyo3-build-config", "pyo3-ffi", "pyo3-macros", @@ -124,9 +131,9 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.20.2" +version = "0.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07426f0d8fe5a601f26293f300afd1a7b1ed5e78b2a705870c5f30893c5163be" +checksum = "deaa5745de3f5231ce10517a1f5dd97d53e5a2fd77aa6b5842292085831d48d7" dependencies = [ "once_cell", "target-lexicon", @@ -134,9 +141,9 @@ dependencies = [ [[package]] name = "pyo3-ffi" -version = "0.20.2" +version = "0.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbb7dec17e17766b46bca4f1a4215a85006b4c2ecde122076c562dd058da6cf1" +checksum = "62b42531d03e08d4ef1f6e85a2ed422eb678b8cd62b762e53891c05faf0d4afa" dependencies = [ "libc", "pyo3-build-config", @@ -144,9 +151,9 @@ dependencies = [ [[package]] name = "pyo3-macros" -version = "0.20.2" +version = "0.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f738b4e40d50b5711957f142878cfa0f28e054aa0ebdfc3fd137a843f74ed3" +checksum = "7305c720fa01b8055ec95e484a6eca7a83c841267f0dd5280f0c8b8551d2c158" dependencies = [ "proc-macro2", "pyo3-macros-backend", @@ -156,12 +163,13 @@ dependencies = [ [[package]] name = "pyo3-macros-backend" -version = "0.20.2" +version = "0.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fc910d4851847827daf9d6cdd4a823fbdaab5b8818325c5e97a86da79e8881f" +checksum = "7c7e9b68bb9c3149c5b0cade5d07f953d6d125eb4337723c4ccdb665f1f96185" dependencies = [ "heck", "proc-macro2", + "pyo3-build-config", "quote", "syn", ] diff --git a/Cargo.toml b/Cargo.toml index 78ac37f..58dc8e4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,5 +12,5 @@ rpds = "1.1.0" archery = "1.1.0" [dependencies.pyo3] -version = "0.20.2" +version = "0.20.3" features = ["extension-module"] From d0dc6d2157e5ec8b6e0a22fb291bab462b2e0f82 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 26 Feb 2024 18:08:39 +0000 Subject: [PATCH 113/241] Bump archery from 1.1.0 to 1.2.0 Bumps [archery](https://github.com/orium/archery) from 1.1.0 to 1.2.0. - [Release notes](https://github.com/orium/archery/releases) - [Changelog](https://github.com/orium/archery/blob/main/release-notes.md) - [Commits](https://github.com/orium/archery/compare/v1.1.0...v1.2.0) --- updated-dependencies: - dependency-name: archery dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7447971..8ff60dc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "archery" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "487955f60962765486ce000015a3492ca45c34a2ebbf12bc0aa2b5110ca6e7d2" +checksum = "8967cd1cc9e9e1954f644e14fbd6042fe9a37da96c52a67e44a2ac18261f8561" dependencies = [ "static_assertions", "triomphe", diff --git a/Cargo.toml b/Cargo.toml index 78ac37f..96a928a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ crate-type = ["cdylib"] [dependencies] rpds = "1.1.0" -archery = "1.1.0" +archery = "1.2.0" [dependencies.pyo3] version = "0.20.2" From f612d9db4dd7cbca04c4ba3cb6596f744dd2afcd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Mar 2024 18:45:47 +0000 Subject: [PATCH 114/241] Bump wntrblm/nox from 2023.04.22 to 2024.03.02 Bumps [wntrblm/nox](https://github.com/wntrblm/nox) from 2023.04.22 to 2024.03.02. - [Release notes](https://github.com/wntrblm/nox/releases) - [Changelog](https://github.com/wntrblm/nox/blob/main/CHANGELOG.md) - [Commits](https://github.com/wntrblm/nox/compare/2023.04.22...2024.03.02) --- updated-dependencies: - dependency-name: wntrblm/nox dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- .github/workflows/CI.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index e6da892..a8329a9 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -31,7 +31,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Set up nox - uses: wntrblm/nox@2023.04.22 + uses: wntrblm/nox@2024.03.02 - id: noxenvs-matrix run: | echo >>$GITHUB_OUTPUT noxenvs=$( @@ -66,7 +66,7 @@ jobs: pypy3.10 allow-prereleases: true - name: Set up nox - uses: wntrblm/nox@2023.04.22 + uses: wntrblm/nox@2024.03.02 - name: Run nox run: nox -s "${{ matrix.noxenv }}" From 18ab4656751a2076926d3e1230c35235cb26f313 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Mar 2024 18:39:16 +0000 Subject: [PATCH 115/241] Bump softprops/action-gh-release from 1 to 2 Bumps [softprops/action-gh-release](https://github.com/softprops/action-gh-release) from 1 to 2. - [Release notes](https://github.com/softprops/action-gh-release/releases) - [Changelog](https://github.com/softprops/action-gh-release/blob/master/CHANGELOG.md) - [Commits](https://github.com/softprops/action-gh-release/compare/v1...v2) --- updated-dependencies: - dependency-name: softprops/action-gh-release dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index a8329a9..a5b9d89 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -211,7 +211,7 @@ jobs: args: --non-interactive --skip-existing * - name: Create a GitHub Release if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') - uses: softprops/action-gh-release@v1 + uses: softprops/action-gh-release@v2 with: files: | * From c638d6f794cda4ca6b5328ffae512acf126e1c63 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 18 Mar 2024 22:21:16 +0000 Subject: [PATCH 116/241] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/psf/black: 24.2.0 → 24.3.0](https://github.com/psf/black/compare/24.2.0...24.3.0) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d879ba3..f890b2d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -32,7 +32,7 @@ repos: hooks: - id: pyupgrade - repo: https://github.com/psf/black - rev: 24.2.0 + rev: 24.3.0 hooks: - id: black - repo: https://github.com/pre-commit/mirrors-prettier From 05836824340563a8c3e4028285d7f195e29c90af Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 25 Mar 2024 22:02:39 +0000 Subject: [PATCH 117/241] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/asottile/pyupgrade: v3.15.1 → v3.15.2](https://github.com/asottile/pyupgrade/compare/v3.15.1...v3.15.2) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f890b2d..57622dc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -28,7 +28,7 @@ repos: hooks: - id: isort - repo: https://github.com/asottile/pyupgrade - rev: v3.15.1 + rev: v3.15.2 hooks: - id: pyupgrade - repo: https://github.com/psf/black From 20a3d8cab66778cf382728b46136c1f671296032 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 Apr 2024 18:34:22 +0000 Subject: [PATCH 118/241] Bump wntrblm/nox from 2024.03.02 to 2024.04.15 Bumps [wntrblm/nox](https://github.com/wntrblm/nox) from 2024.03.02 to 2024.04.15. - [Release notes](https://github.com/wntrblm/nox/releases) - [Changelog](https://github.com/wntrblm/nox/blob/main/CHANGELOG.md) - [Commits](https://github.com/wntrblm/nox/compare/2024.03.02...2024.04.15) --- updated-dependencies: - dependency-name: wntrblm/nox dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- .github/workflows/CI.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index a5b9d89..9037d02 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -31,7 +31,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Set up nox - uses: wntrblm/nox@2024.03.02 + uses: wntrblm/nox@2024.04.15 - id: noxenvs-matrix run: | echo >>$GITHUB_OUTPUT noxenvs=$( @@ -66,7 +66,7 @@ jobs: pypy3.10 allow-prereleases: true - name: Set up nox - uses: wntrblm/nox@2024.03.02 + uses: wntrblm/nox@2024.04.15 - name: Run nox run: nox -s "${{ matrix.noxenv }}" From fb5baf2b3a083218b3526d534def0cb7f2cc2dae Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 15 Apr 2024 22:33:25 +0000 Subject: [PATCH 119/241] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/pre-commit-hooks: v4.5.0 → v4.6.0](https://github.com/pre-commit/pre-commit-hooks/compare/v4.5.0...v4.6.0) - [github.com/psf/black: 24.3.0 → 24.4.0](https://github.com/psf/black/compare/24.3.0...24.4.0) --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 57622dc..66321a3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,7 +6,7 @@ ci: repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 + rev: v4.6.0 hooks: - id: check-ast - id: check-docstring-first @@ -32,7 +32,7 @@ repos: hooks: - id: pyupgrade - repo: https://github.com/psf/black - rev: 24.3.0 + rev: 24.4.0 hooks: - id: black - repo: https://github.com/pre-commit/mirrors-prettier From c3b91089e7e02e3d96fdb7af4b95f282752a6491 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Mon, 22 Apr 2024 17:15:09 +0300 Subject: [PATCH 120/241] Update requirements. --- docs/requirements.txt | 33 ++++++++++++++------------------- tests/requirements.txt | 6 +++--- 2 files changed, 17 insertions(+), 22 deletions(-) diff --git a/docs/requirements.txt b/docs/requirements.txt index 0ef05bc..d9cb93e 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -8,25 +8,25 @@ alabaster==0.7.16 # via sphinx babel==2.14.0 # via sphinx -beautifulsoup4==4.12.2 +beautifulsoup4==4.12.3 # via furo -certifi==2023.11.17 +certifi==2024.2.2 # via requests charset-normalizer==3.3.2 # via requests -docutils==0.20.1 +docutils==0.21.1 # via sphinx -furo==2023.9.10 +furo==2024.1.29 # via -r docs/requirements.in -idna==3.6 +idna==3.7 # via requests imagesize==1.4.1 # via sphinx jinja2==3.1.3 # via sphinx -markupsafe==2.1.3 +markupsafe==2.1.5 # via jinja2 -packaging==23.2 +packaging==24.0 # via sphinx pyenchant==3.2.2 # via sphinxcontrib-spelling @@ -45,34 +45,29 @@ snowballstemmer==2.2.0 # via sphinx soupsieve==2.5 # via beautifulsoup4 -sphinx==7.2.6 +sphinx==7.3.7 # via # -r docs/requirements.in # furo # sphinx-basic-ng # sphinx-copybutton - # sphinxcontrib-applehelp - # sphinxcontrib-devhelp - # sphinxcontrib-htmlhelp - # sphinxcontrib-qthelp - # sphinxcontrib-serializinghtml # sphinxcontrib-spelling # sphinxext-opengraph sphinx-basic-ng==1.0.0b2 # via furo sphinx-copybutton==0.5.2 # via -r docs/requirements.in -sphinxcontrib-applehelp==1.0.7 +sphinxcontrib-applehelp==1.0.8 # via sphinx -sphinxcontrib-devhelp==1.0.5 +sphinxcontrib-devhelp==1.0.6 # via sphinx -sphinxcontrib-htmlhelp==2.0.4 +sphinxcontrib-htmlhelp==2.0.5 # via sphinx sphinxcontrib-jsmath==1.0.1 # via sphinx -sphinxcontrib-qthelp==1.0.6 +sphinxcontrib-qthelp==1.0.7 # via sphinx -sphinxcontrib-serializinghtml==1.1.9 +sphinxcontrib-serializinghtml==1.1.10 # via sphinx sphinxcontrib-spelling==8.0.0 # via -r docs/requirements.in @@ -80,5 +75,5 @@ sphinxext-opengraph==0.9.1 # via -r docs/requirements.in url-py==0.10.0 # via -r docs/requirements.in -urllib3==2.1.0 +urllib3==2.2.1 # via requests diff --git a/tests/requirements.txt b/tests/requirements.txt index 0483d1b..b3d7d87 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -6,11 +6,11 @@ # iniconfig==2.0.0 # via pytest -packaging==23.2 +packaging==24.0 # via pytest -pluggy==1.3.0 +pluggy==1.5.0 # via pytest -pytest==7.4.4 +pytest==8.1.1 # via -r tests/requirements.in file:.#egg=rpds-py # via -r tests/requirements.in From ebcf21c750d91032a34e81f784e24178c9a6d1c1 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 29 Apr 2024 22:37:50 +0000 Subject: [PATCH 121/241] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/psf/black: 24.4.0 → 24.4.2](https://github.com/psf/black/compare/24.4.0...24.4.2) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 66321a3..f2e6622 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -32,7 +32,7 @@ repos: hooks: - id: pyupgrade - repo: https://github.com/psf/black - rev: 24.4.0 + rev: 24.4.2 hooks: - id: black - repo: https://github.com/pre-commit/mirrors-prettier From bb8cfc1074e74872647d05b0f54b6473158a97de Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Mon, 6 May 2024 09:15:09 -0400 Subject: [PATCH 122/241] Tag a release for PyO3 0.20.3 support. Closes: #71 --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e345074..1467e46 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -203,7 +203,7 @@ dependencies = [ [[package]] name = "rpds-py" -version = "0.18.0" +version = "0.18.1" dependencies = [ "archery", "pyo3", diff --git a/Cargo.toml b/Cargo.toml index fb47e0c..13012d0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rpds-py" -version = "0.18.0" +version = "0.18.1" edition = "2021" [lib] From 4de7d411dea1fbe1a2be4eceaaab2105f0f6d18e Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Wed, 8 May 2024 09:37:42 -0400 Subject: [PATCH 123/241] WIP --- Cargo.lock | 20 ++-- Cargo.toml | 2 +- src/lib.rs | 267 +++++++++++++++++++++++++++++------------------------ 3 files changed, 156 insertions(+), 133 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1467e46..5159b40 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -113,9 +113,9 @@ dependencies = [ [[package]] name = "pyo3" -version = "0.20.3" +version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53bdbb96d49157e65d45cc287af5f32ffadd5f4761438b527b055fb0d4bb8233" +checksum = "a5e00b96a521718e08e03b1a622f01c8a8deb50719335de3f60b3b3950f069d8" dependencies = [ "cfg-if", "indoc", @@ -131,9 +131,9 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.20.3" +version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "deaa5745de3f5231ce10517a1f5dd97d53e5a2fd77aa6b5842292085831d48d7" +checksum = "7883df5835fafdad87c0d888b266c8ec0f4c9ca48a5bed6bbb592e8dedee1b50" dependencies = [ "once_cell", "target-lexicon", @@ -141,9 +141,9 @@ dependencies = [ [[package]] name = "pyo3-ffi" -version = "0.20.3" +version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b42531d03e08d4ef1f6e85a2ed422eb678b8cd62b762e53891c05faf0d4afa" +checksum = "01be5843dc60b916ab4dad1dca6d20b9b4e6ddc8e15f50c47fe6d85f1fb97403" dependencies = [ "libc", "pyo3-build-config", @@ -151,9 +151,9 @@ dependencies = [ [[package]] name = "pyo3-macros" -version = "0.20.3" +version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7305c720fa01b8055ec95e484a6eca7a83c841267f0dd5280f0c8b8551d2c158" +checksum = "77b34069fc0682e11b31dbd10321cbf94808394c56fd996796ce45217dfac53c" dependencies = [ "proc-macro2", "pyo3-macros-backend", @@ -163,9 +163,9 @@ dependencies = [ [[package]] name = "pyo3-macros-backend" -version = "0.20.3" +version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c7e9b68bb9c3149c5b0cade5d07f953d6d125eb4337723c4ccdb665f1f96185" +checksum = "08260721f32db5e1a5beae69a55553f56b99bd0e1c3e6e0a5e8851a9d0f5a85c" dependencies = [ "heck", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index 13012d0..6e8be78 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,5 +12,5 @@ rpds = "1.1.0" archery = "1.2.0" [dependencies.pyo3] -version = "0.20.3" +version = "0.21.2" features = ["extension-module"] diff --git a/src/lib.rs b/src/lib.rs index ad3cce2..e49e870 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,7 +3,7 @@ use std::hash::{Hash, Hasher}; use pyo3::exceptions::PyIndexError; use pyo3::pyclass::CompareOp; -use pyo3::types::{PyDict, PyIterator, PyNone, PyTuple, PyType}; +use pyo3::types::{PyDict, PyIterator, PyTuple, PyType}; use pyo3::{exceptions::PyKeyError, types::PyMapping}; use pyo3::{prelude::*, AsPyPointer, PyTypeInfo}; use rpds::{ @@ -48,10 +48,10 @@ unsafe impl AsPyPointer for Key { } impl<'source> FromPyObject<'source> for Key { - fn extract(ob: &'source PyAny) -> PyResult { + fn extract_bound(ob: &Bound<'source, PyAny>) -> PyResult { Ok(Key { hash: ob.hash()?, - inner: ob.into(), + inner: ob.unbind(), }) } } @@ -69,7 +69,7 @@ impl From> for HashTrieMapPy { } impl<'source> FromPyObject<'source> for HashTrieMapPy { - fn extract(ob: &'source PyAny) -> PyResult { + fn extract_bound(ob: &Bound<'source, PyAny>) -> PyResult { let mut ret = HashTrieMap::new_sync(); if let Ok(mapping) = ob.downcast::() { for each in mapping.items()?.iter()? { @@ -90,7 +90,7 @@ impl<'source> FromPyObject<'source> for HashTrieMapPy { impl HashTrieMapPy { #[new] #[pyo3(signature = (value=None, **kwds))] - fn init(value: Option, kwds: Option<&PyDict>) -> PyResult { + fn init(value: Option, kwds: Option<&Bound<'_, PyDict>>) -> PyResult { let mut map: HashTrieMapPy; if let Some(value) = value { map = value; @@ -101,7 +101,7 @@ impl HashTrieMapPy { } if let Some(kwds) = kwds { for (k, v) in kwds { - map.inner.insert_mut(Key::extract(k)?, v.into()); + map.inner.insert_mut(Key::extract_bound(&k)?, v.into()); } } Ok(map) @@ -169,9 +169,9 @@ impl HashTrieMapPy { } } - fn __reduce__(slf: PyRef) -> (&PyType, (Vec<(Key, PyObject)>,)) { + fn __reduce__(slf: PyRef) -> (Bound<'_, PyType>, (Vec<(Key, PyObject)>,)) { ( - HashTrieMapPy::type_object(slf.py()), + HashTrieMapPy::type_object_bound(slf.py()), (slf.inner .iter() .map(|(k, v)| (k.clone(), v.clone())) @@ -180,27 +180,31 @@ impl HashTrieMapPy { } #[classmethod] - fn convert(_cls: &PyType, value: &PyAny, py: Python) -> PyResult { + fn convert( + _cls: &Bound<'_, PyType>, + value: Bound<'_, PyAny>, + py: Python, + ) -> PyResult { if value.is_instance_of::() { - Ok(value.into()) + Ok(value.unbind()) } else { - Ok(HashTrieMapPy::extract(value)?.into_py(py)) + Ok(HashTrieMapPy::extract_bound(&value)?.into_py(py)) } } #[classmethod] fn fromkeys( - _cls: &PyType, - keys: &PyAny, - val: Option<&PyAny>, + _cls: &Bound<'_, PyType>, + keys: &Bound<'_, PyAny>, + val: Option<&Bound<'_, PyAny>>, py: Python, ) -> PyResult { let mut inner = HashTrieMap::new_sync(); - let none = py.None(); - let value = val.unwrap_or_else(|| none.as_ref(py)); + let none = py.None().into_bound(py); + let value = val.unwrap_or_else(|| &none); for each in keys.iter()? { - let key = Key::extract(each?)?.to_owned(); - inner.insert_mut(key, value.into()); + let key = Key::extract_bound(&each?)?.to_owned(); + inner.insert_mut(key, value.unbind()); } Ok(HashTrieMapPy { inner }) } @@ -242,9 +246,9 @@ impl HashTrieMapPy { } } - fn insert(&self, key: Key, value: &PyAny) -> HashTrieMapPy { + fn insert(&self, key: Key, value: Bound<'_, PyAny>) -> HashTrieMapPy { HashTrieMapPy { - inner: self.inner.insert(key, value.into()), + inner: self.inner.insert(key, value.unbind()), } } @@ -258,17 +262,21 @@ impl HashTrieMapPy { } #[pyo3(signature = (*maps, **kwds))] - fn update(&self, maps: &PyTuple, kwds: Option<&PyDict>) -> PyResult { + fn update( + &self, + maps: &Bound<'_, PyTuple>, + kwds: Option<&Bound<'_, PyDict>>, + ) -> PyResult { let mut inner = self.inner.clone(); for value in maps { - let map = HashTrieMapPy::extract(value)?; + let map = HashTrieMapPy::extract_bound(&value)?; for (k, v) in &map.inner { inner.insert_mut(k.to_owned(), v.to_owned()); } } if let Some(kwds) = kwds { for (k, v) in kwds { - inner.insert_mut(Key::extract(k)?, v.extract()?); + inner.insert_mut(Key::extract_bound(&k)?, v.extract()?); } } Ok(HashTrieMapPy { inner }) @@ -343,22 +351,22 @@ impl KeysView { self.inner.contains_key(&key) } - fn __eq__(slf: PyRef<'_, Self>, other: &PyAny, py: Python) -> PyResult { - let abc = PyModule::import(py, "collections.abc")?; - if !other.is_instance(abc.getattr("Set")?)? || other.len()? != slf.inner.size() { + fn __eq__(slf: PyRef<'_, Self>, other: &Bound<'_, PyAny>, py: Python) -> PyResult { + let abc = PyModule::import_bound(py, "collections.abc")?; + if !other.is_instance(&abc.getattr("Set")?)? || other.len()? != slf.inner.size() { return Ok(false); } for each in other.iter()? { - if !slf.inner.contains_key(&Key::extract(each?)?) { + if !slf.inner.contains_key(&Key::extract_bound(&each?)?) { return Ok(false); } } Ok(true) } - fn __lt__(slf: PyRef<'_, Self>, other: &PyAny, py: Python) -> PyResult { - let abc = PyModule::import(py, "collections.abc")?; - if !other.is_instance(abc.getattr("Set")?)? || other.len()? <= slf.inner.size() { + fn __lt__(slf: PyRef<'_, Self>, other: &Bound<'_, PyAny>, py: Python) -> PyResult { + let abc = PyModule::import_bound(py, "collections.abc")?; + if !other.is_instance(&abc.getattr("Set")?)? || other.len()? <= slf.inner.size() { return Ok(false); } for each in slf.inner.keys() { @@ -369,9 +377,9 @@ impl KeysView { Ok(true) } - fn __le__(slf: PyRef<'_, Self>, other: &PyAny, py: Python) -> PyResult { - let abc = PyModule::import(py, "collections.abc")?; - if !other.is_instance(abc.getattr("Set")?)? || other.len()? < slf.inner.size() { + fn __le__(slf: PyRef<'_, Self>, other: &Bound<'_, PyAny>, py: Python) -> PyResult { + let abc = PyModule::import_bound(py, "collections.abc")?; + if !other.is_instance(&abc.getattr("Set")?)? || other.len()? < slf.inner.size() { return Ok(false); } for each in slf.inner.keys() { @@ -382,26 +390,26 @@ impl KeysView { Ok(true) } - fn __gt__(slf: PyRef<'_, Self>, other: &PyAny, py: Python) -> PyResult { - let abc = PyModule::import(py, "collections.abc")?; - if !other.is_instance(abc.getattr("Set")?)? || other.len()? >= slf.inner.size() { + fn __gt__(slf: PyRef<'_, Self>, other: &Bound<'_, PyAny>, py: Python) -> PyResult { + let abc = PyModule::import_bound(py, "collections.abc")?; + if !other.is_instance(&abc.getattr("Set")?)? || other.len()? >= slf.inner.size() { return Ok(false); } for each in other.iter()? { - if !slf.inner.contains_key(&Key::extract(each?)?) { + if !slf.inner.contains_key(&Key::extract_bound(&each?)?) { return Ok(false); } } Ok(true) } - fn __ge__(slf: PyRef<'_, Self>, other: &PyAny, py: Python) -> PyResult { - let abc = PyModule::import(py, "collections.abc")?; - if !other.is_instance(abc.getattr("Set")?)? || other.len()? > slf.inner.size() { + fn __ge__(slf: PyRef<'_, Self>, other: &Bound<'_, PyAny>, py: Python) -> PyResult { + let abc = PyModule::import_bound(py, "collections.abc")?; + if !other.is_instance(&abc.getattr("Set")?)? || other.len()? > slf.inner.size() { return Ok(false); } for each in other.iter()? { - if !slf.inner.contains_key(&Key::extract(each?)?) { + if !slf.inner.contains_key(&Key::extract_bound(&each?)?) { return Ok(false); } } @@ -418,11 +426,11 @@ impl KeysView { slf.inner.size() } - fn __and__(slf: PyRef<'_, Self>, other: &PyAny) -> PyResult { + fn __and__(slf: PyRef<'_, Self>, other: &Bound<'_, PyAny>) -> PyResult { KeysView::intersection(slf, other) } - fn __or__(slf: PyRef<'_, Self>, other: &PyAny, py: Python) -> PyResult { + fn __or__(slf: PyRef<'_, Self>, other: &Bound<'_, PyAny>, py: Python) -> PyResult { KeysView::union(slf, other, py) } @@ -438,11 +446,11 @@ impl KeysView { format!("keys_view({{{}}})", contents.collect::>().join(", ")) } - fn intersection(slf: PyRef<'_, Self>, other: &PyAny) -> PyResult { + fn intersection(slf: PyRef<'_, Self>, other: &Bound<'_, PyAny>) -> PyResult { // TODO: iterate over the shorter one if it's got a length let mut inner = HashTrieSet::new_sync(); for each in other.iter()? { - let key = Key::extract(each?)?; + let key = Key::extract_bound(&each?)?; if slf.inner.contains_key(&key) { inner.insert_mut(key); } @@ -450,13 +458,12 @@ impl KeysView { Ok(HashTrieSetPy { inner }) } - fn union(slf: PyRef<'_, Self>, other: &PyAny, py: Python) -> PyResult { + fn union(slf: PyRef<'_, Self>, other: &Bound<'_, PyAny>, py: Python) -> PyResult { // There doesn't seem to be a low-effort way to get a HashTrieSet out of a map, // so we just keep our map and add values we'll ignore. let mut inner = slf.inner.clone(); - let none = PyNone::get(py); for each in other.iter()? { - inner.insert_mut(Key::extract(each?)?, none.into()); + inner.insert_mut(Key::extract_bound(&each?)?, py.None()); } Ok(KeysView { inner }) } @@ -514,9 +521,9 @@ impl ItemsView { slf.inner.size() } - fn __eq__(slf: PyRef<'_, Self>, other: &PyAny, py: Python) -> PyResult { - let abc = PyModule::import(py, "collections.abc")?; - if !other.is_instance(abc.getattr("Set")?)? || other.len()? != slf.inner.size() { + fn __eq__(slf: PyRef<'_, Self>, other: &Bound<'_, PyAny>, py: Python) -> PyResult { + let abc = PyModule::import_bound(py, "collections.abc")?; + if !other.is_instance(&abc.getattr("Set")?)? || other.len()? != slf.inner.size() { return Ok(false); } for (k, v) in slf.inner.iter() { @@ -529,19 +536,19 @@ impl ItemsView { fn __repr__(&self, py: Python) -> String { let contents = self.inner.into_iter().map(|(k, v)| { - let tuple = PyTuple::new(py, [k.inner.to_owned(), v.to_owned()]); + let tuple = PyTuple::new_bound(py, [k.inner.to_owned(), v.to_owned()]); format!("{:?}", tuple) }); format!("items_view([{}])", contents.collect::>().join(", ")) } - fn __lt__(slf: PyRef<'_, Self>, other: &PyAny, py: Python) -> PyResult { - let abc = PyModule::import(py, "collections.abc")?; - if !other.is_instance(abc.getattr("Set")?)? || other.len()? <= slf.inner.size() { + fn __lt__(slf: PyRef<'_, Self>, other: &Bound<'_, PyAny>, py: Python) -> PyResult { + let abc = PyModule::import_bound(py, "collections.abc")?; + if !other.is_instance(&abc.getattr("Set")?)? || other.len()? <= slf.inner.size() { return Ok(false); } for (k, v) in slf.inner.iter() { - let pair = PyTuple::new(py, [k.inner.to_owned(), v.to_owned()]); + let pair = PyTuple::new_bound(py, [k.inner.to_owned(), v.to_owned()]); // FIXME: needs to compare if !other.contains(pair)? { return Ok(false); @@ -550,13 +557,13 @@ impl ItemsView { Ok(true) } - fn __le__(slf: PyRef<'_, Self>, other: &PyAny, py: Python) -> PyResult { - let abc = PyModule::import(py, "collections.abc")?; - if !other.is_instance(abc.getattr("Set")?)? || other.len()? < slf.inner.size() { + fn __le__(slf: PyRef<'_, Self>, other: &Bound<'_, PyAny>, py: Python) -> PyResult { + let abc = PyModule::import_bound(py, "collections.abc")?; + if !other.is_instance(&abc.getattr("Set")?)? || other.len()? < slf.inner.size() { return Ok(false); } for (k, v) in slf.inner.iter() { - let pair = PyTuple::new(py, [k.inner.to_owned(), v.to_owned()]); + let pair = PyTuple::new_bound(py, [k.inner.to_owned(), v.to_owned()]); // FIXME: needs to compare if !other.contains(pair)? { return Ok(false); @@ -565,17 +572,17 @@ impl ItemsView { Ok(true) } - fn __gt__(slf: PyRef<'_, Self>, other: &PyAny, py: Python) -> PyResult { - let abc = PyModule::import(py, "collections.abc")?; - if !other.is_instance(abc.getattr("Set")?)? || other.len()? >= slf.inner.size() { + fn __gt__(slf: PyRef<'_, Self>, other: &Bound<'_, PyAny>, py: Python) -> PyResult { + let abc = PyModule::import_bound(py, "collections.abc")?; + if !other.is_instance(&abc.getattr("Set")?)? || other.len()? >= slf.inner.size() { return Ok(false); } for each in other.iter()? { let kv = each?; let k = kv.get_item(0)?; - match slf.inner.get(&Key::extract(k)?) { + match slf.inner.get(&Key::extract_bound(&k)?) { Some(value) => { - let pair = PyTuple::new(py, [k, value.as_ref(py)]); + let pair = PyTuple::new_bound(py, [k, value.into_bound(py)]); if !pair.eq(kv)? { return Ok(false); } @@ -586,17 +593,17 @@ impl ItemsView { Ok(true) } - fn __ge__(slf: PyRef<'_, Self>, other: &PyAny, py: Python) -> PyResult { - let abc = PyModule::import(py, "collections.abc")?; - if !other.is_instance(abc.getattr("Set")?)? || other.len()? > slf.inner.size() { + fn __ge__(slf: PyRef<'_, Self>, other: &Bound<'_, PyAny>, py: Python) -> PyResult { + let abc = PyModule::import_bound(py, "collections.abc")?; + if !other.is_instance(&abc.getattr("Set")?)? || other.len()? > slf.inner.size() { return Ok(false); } for each in other.iter()? { let kv = each?; let k = kv.get_item(0)?; - match slf.inner.get(&Key::extract(k)?) { + match slf.inner.get(&Key::extract_bound(&k)?) { Some(value) => { - let pair = PyTuple::new(py, [k, value.as_ref(py)]); + let pair = PyTuple::new_bound(py, [k, value.into_bound(py)]); if !pair.eq(kv)? { return Ok(false); } @@ -607,39 +614,55 @@ impl ItemsView { Ok(true) } - fn __and__(slf: PyRef<'_, Self>, other: &PyAny, py: Python) -> PyResult { + fn __and__( + slf: PyRef<'_, Self>, + other: &Bound<'_, PyAny>, + py: Python, + ) -> PyResult { ItemsView::intersection(slf, other, py) } - fn __or__(slf: PyRef<'_, Self>, other: &PyAny, py: Python) -> PyResult { + fn __or__( + slf: PyRef<'_, Self>, + other: &Bound<'_, PyAny>, + py: Python, + ) -> PyResult { ItemsView::union(slf, other, py) } - fn intersection(slf: PyRef<'_, Self>, other: &PyAny, py: Python) -> PyResult { + fn intersection( + slf: PyRef<'_, Self>, + other: &Bound<'_, PyAny>, + py: Python, + ) -> PyResult { // TODO: iterate over the shorter one if it's got a length let mut inner = HashTrieSet::new_sync(); for each in other.iter()? { let kv = each?; let k = kv.get_item(0)?; - if let Some(value) = slf.inner.get(&Key::extract(k)?) { - let pair = PyTuple::new(py, [k, value.as_ref(py)]); + if let Some(value) = slf.inner.get(&Key::extract_bound(&k)?) { + let pair = PyTuple::new_bound(py, [k, value.into_bound(py)]); if pair.eq(kv)? { - inner.insert_mut(Key::extract(pair)?); + inner.insert_mut(Key::extract_bound(&pair)?); } } } Ok(HashTrieSetPy { inner }) } - fn union(slf: PyRef<'_, Self>, other: &PyAny, py: Python) -> PyResult { + fn union( + slf: PyRef<'_, Self>, + other: &Bound<'_, PyAny>, + py: Python, + ) -> PyResult { // TODO: this is very inefficient, but again can't seem to get a HashTrieSet out of ourself let mut inner = HashTrieSet::new_sync(); for (k, v) in slf.inner.iter() { - let pair = PyTuple::new(py, [k.inner.to_owned(), v.to_owned()]); - inner.insert_mut(Key::extract(pair)?); + let pair = PyTuple::new_bound(py, [k.inner.to_owned(), v.to_owned()]); + inner.insert_mut(Key::extract_bound(&pair)?); } for each in other.iter()? { - inner.insert_mut(Key::extract(each?)?); + inner.insert_mut(Key::extract_bound(&each?)?); } Ok(HashTrieSetPy { inner }) } @@ -652,7 +675,7 @@ struct HashTrieSetPy { } impl<'source> FromPyObject<'source> for HashTrieSetPy { - fn extract(ob: &'source PyAny) -> PyResult { + fn extract_bound(ob: &Bound<'source, PyAny>) -> PyResult { let mut ret = HashTrieSet::new_sync(); for each in ob.iter()? { let k: Key = each?.extract()?; @@ -719,22 +742,22 @@ impl HashTrieSetPy { ) } - fn __eq__(slf: PyRef<'_, Self>, other: &PyAny, py: Python) -> PyResult { - let abc = PyModule::import(py, "collections.abc")?; - if !other.is_instance(abc.getattr("Set")?)? || other.len()? != slf.inner.size() { + fn __eq__(slf: PyRef<'_, Self>, other: Bound<'_, PyAny>, py: Python) -> PyResult { + let abc = PyModule::import_bound(py, "collections.abc")?; + if !other.is_instance(&abc.getattr("Set")?)? || other.len()? != slf.inner.size() { return Ok(false); } for each in other.iter()? { - if !slf.inner.contains(&Key::extract(each?)?) { + if !slf.inner.contains(&Key::extract_bound(&each?)?) { return Ok(false); } } Ok(true) } - fn __lt__(slf: PyRef<'_, Self>, other: &PyAny, py: Python) -> PyResult { - let abc = PyModule::import(py, "collections.abc")?; - if !other.is_instance(abc.getattr("Set")?)? || other.len()? <= slf.inner.size() { + fn __lt__(slf: PyRef<'_, Self>, other: Bound<'_, PyAny>, py: Python) -> PyResult { + let abc = PyModule::import_bound(py, "collections.abc")?; + if !other.is_instance(&abc.getattr("Set")?)? || other.len()? <= slf.inner.size() { return Ok(false); } for each in slf.inner.iter() { @@ -745,9 +768,9 @@ impl HashTrieSetPy { Ok(true) } - fn __le__(slf: PyRef<'_, Self>, other: &PyAny, py: Python) -> PyResult { - let abc = PyModule::import(py, "collections.abc")?; - if !other.is_instance(abc.getattr("Set")?)? || other.len()? < slf.inner.size() { + fn __le__(slf: PyRef<'_, Self>, other: Bound<'_, PyAny>, py: Python) -> PyResult { + let abc = PyModule::import_bound(py, "collections.abc")?; + if !other.is_instance(&abc.getattr("Set")?)? || other.len()? < slf.inner.size() { return Ok(false); } for each in slf.inner.iter() { @@ -758,35 +781,35 @@ impl HashTrieSetPy { Ok(true) } - fn __gt__(slf: PyRef<'_, Self>, other: &PyAny, py: Python) -> PyResult { - let abc = PyModule::import(py, "collections.abc")?; - if !other.is_instance(abc.getattr("Set")?)? || other.len()? >= slf.inner.size() { + fn __gt__(slf: PyRef<'_, Self>, other: Bound<'_, PyAny>, py: Python) -> PyResult { + let abc = PyModule::import_bound(py, "collections.abc")?; + if !other.is_instance(&abc.getattr("Set")?)? || other.len()? >= slf.inner.size() { return Ok(false); } for each in other.iter()? { - if !slf.inner.contains(&Key::extract(each?)?) { + if !slf.inner.contains(&Key::extract_bound(&each?)?) { return Ok(false); } } Ok(true) } - fn __ge__(slf: PyRef<'_, Self>, other: &PyAny, py: Python) -> PyResult { - let abc = PyModule::import(py, "collections.abc")?; - if !other.is_instance(abc.getattr("Set")?)? || other.len()? > slf.inner.size() { + fn __ge__(slf: PyRef<'_, Self>, other: Bound<'_, PyAny>, py: Python) -> PyResult { + let abc = PyModule::import_bound(py, "collections.abc")?; + if !other.is_instance(&abc.getattr("Set")?)? || other.len()? > slf.inner.size() { return Ok(false); } for each in other.iter()? { - if !slf.inner.contains(&Key::extract(each?)?) { + if !slf.inner.contains(&Key::extract_bound(&each?)?) { return Ok(false); } } Ok(true) } - fn __reduce__(slf: PyRef) -> (&PyType, (Vec,)) { + fn __reduce__(slf: PyRef) -> (Bound<'_, PyType>, (Vec,)) { ( - HashTrieSetPy::type_object(slf.py()), + HashTrieSetPy::type_object_bound(slf.py()), (slf.inner.iter().cloned().collect(),), ) } @@ -881,12 +904,12 @@ impl HashTrieSetPy { } #[pyo3(signature = (*iterables))] - fn update(&self, iterables: &PyTuple) -> PyResult { + fn update(&self, iterables: Bound<'_, PyTuple>) -> PyResult { let mut inner = self.inner.clone(); for each in iterables { let iter = each.iter()?; for value in iter { - inner.insert_mut(Key::extract(value?)?.to_owned()); + inner.insert_mut(Key::extract_bound(&value?)?.to_owned()); } } Ok(HashTrieSetPy { inner }) @@ -924,10 +947,10 @@ impl From> for ListPy { } impl<'source> FromPyObject<'source> for ListPy { - fn extract(ob: &'source PyAny) -> PyResult { + fn extract_bound(ob: &Bound<'source, PyAny>) -> PyResult { let mut ret = List::new_sync(); - let reversed = PyModule::import(ob.py(), "builtins")?.getattr("reversed")?; - let rob: &PyIterator = reversed.call1((ob,))?.iter()?; + let reversed = PyModule::import_bound(ob.py(), "builtins")?.getattr("reversed")?; + let rob: Bound<'_, PyIterator> = reversed.call1((ob,))?.iter()?; for each in rob { ret.push_front_mut(each?.extract()?); } @@ -939,7 +962,7 @@ impl<'source> FromPyObject<'source> for ListPy { impl ListPy { #[new] #[pyo3(signature = (*elements))] - fn init(elements: &PyTuple) -> PyResult { + fn init(elements: &Bound<'_, PyTuple>) -> PyResult { let mut ret: ListPy; if elements.len() == 1 { ret = elements.get_item(0)?.extract()?; @@ -1005,9 +1028,9 @@ impl ListPy { } } - fn __reduce__(slf: PyRef) -> (&PyType, (Vec,)) { + fn __reduce__(slf: PyRef) -> (Bound<'_, PyType>, (Vec,)) { ( - ListPy::type_object(slf.py()), + ListPy::type_object_bound(slf.py()), (slf.inner.iter().cloned().collect(),), ) } @@ -1090,7 +1113,7 @@ impl From> for QueuePy { } impl<'source> FromPyObject<'source> for QueuePy { - fn extract(ob: &'source PyAny) -> PyResult { + fn extract_bound(ob: &Bound<'source, PyAny>) -> PyResult { let mut ret = Queue::new_sync(); for each in ob.iter()? { ret.enqueue_mut(each?.extract()?); @@ -1103,7 +1126,7 @@ impl<'source> FromPyObject<'source> for QueuePy { impl QueuePy { #[new] #[pyo3(signature = (*elements))] - fn init(elements: &PyTuple, py: Python<'_>) -> PyResult { + fn init(elements: &Bound<'_, PyTuple>, py: Python<'_>) -> PyResult { let mut ret: QueuePy; if elements.len() == 1 { ret = elements.get_item(0)?.extract()?; @@ -1131,7 +1154,7 @@ impl QueuePy { } fn __hash__(&self, py: Python<'_>) -> PyResult { - let hash = PyModule::import(py, "builtins")?.getattr("hash")?; + let hash = PyModule::import_bound(py, "builtins")?.getattr("hash")?; let mut hasher = DefaultHasher::new(); for each in &self.inner { let n: i64 = hash.call1((each.into_py(py),))?.extract()?; @@ -1185,7 +1208,7 @@ impl QueuePy { self.inner.is_empty() } - fn enqueue(&self, value: &PyAny) -> Self { + fn enqueue(&self, value: Bound<'_, PyAny>) -> Self { QueuePy { inner: self.inner.enqueue(value.into()), } @@ -1202,7 +1225,7 @@ impl QueuePy { #[pymodule] #[pyo3(name = "rpds")] -fn rpds_py(py: Python, m: &PyModule) -> PyResult<()> { +fn rpds_py(py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> { m.add_class::()?; m.add_class::()?; m.add_class::()?; @@ -1210,24 +1233,24 @@ fn rpds_py(py: Python, m: &PyModule) -> PyResult<()> { PyMapping::register::(py)?; - let abc = PyModule::import(py, "collections.abc")?; + let abc = PyModule::import_bound(py, "collections.abc")?; abc.getattr("Set")? - .call_method1("register", (HashTrieSetPy::type_object(py),))?; + .call_method1("register", (HashTrieSetPy::type_object_bound(py),))?; abc.getattr("MappingView")? - .call_method1("register", (KeysView::type_object(py),))?; + .call_method1("register", (KeysView::type_object_bound(py),))?; abc.getattr("MappingView")? - .call_method1("register", (ValuesView::type_object(py),))?; + .call_method1("register", (ValuesView::type_object_bound(py),))?; abc.getattr("MappingView")? - .call_method1("register", (ItemsView::type_object(py),))?; + .call_method1("register", (ItemsView::type_object_bound(py),))?; abc.getattr("KeysView")? - .call_method1("register", (KeysView::type_object(py),))?; + .call_method1("register", (KeysView::type_object_bound(py),))?; abc.getattr("ValuesView")? - .call_method1("register", (ValuesView::type_object(py),))?; + .call_method1("register", (ValuesView::type_object_bound(py),))?; abc.getattr("ItemsView")? - .call_method1("register", (ItemsView::type_object(py),))?; + .call_method1("register", (ItemsView::type_object_bound(py),))?; Ok(()) } From 9b623e81c4fe8c7e9199bbf322cbdc9245cbb7c7 Mon Sep 17 00:00:00 2001 From: wangweijie Date: Wed, 5 Jun 2024 20:51:17 +0800 Subject: [PATCH 124/241] deps: bump libc from 0.2.147 to 0.2.155 Signed-off-by: wangweijie --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1467e46..57d2a8a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -44,9 +44,9 @@ checksum = "1e186cfbae8084e513daff4240b4797e342f988cecda4fb6c939150f96315fd8" [[package]] name = "libc" -version = "0.2.147" +version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "lock_api" From 8bce8219aec5cc01d820010bcce6b6f334596a50 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 10 Jun 2024 22:31:31 +0000 Subject: [PATCH 125/241] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/asottile/pyupgrade: v3.15.2 → v3.16.0](https://github.com/asottile/pyupgrade/compare/v3.15.2...v3.16.0) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f2e6622..c50db8f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -28,7 +28,7 @@ repos: hooks: - id: isort - repo: https://github.com/asottile/pyupgrade - rev: v3.15.2 + rev: v3.16.0 hooks: - id: pyupgrade - repo: https://github.com/psf/black From fd520b766eb505c00144fcf20a770a1ad2e84e5a Mon Sep 17 00:00:00 2001 From: Heyuan Zeng Date: Wed, 3 Jul 2024 16:34:51 +0100 Subject: [PATCH 126/241] Bump pyo3 from 0.20.3 to 0.22.0 --- Cargo.lock | 159 +++++++---------------------------------------------- Cargo.toml | 2 +- 2 files changed, 22 insertions(+), 139 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 57d2a8a..a383eff 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -18,12 +18,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - [[package]] name = "cfg-if" version = "1.0.0" @@ -32,9 +26,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "heck" -version = "0.4.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "indoc" @@ -48,16 +42,6 @@ version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" -[[package]] -name = "lock_api" -version = "0.4.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" -dependencies = [ - "autocfg", - "scopeguard", -] - [[package]] name = "memoffset" version = "0.9.0" @@ -73,29 +57,6 @@ version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" -[[package]] -name = "parking_lot" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" -dependencies = [ - "lock_api", - "parking_lot_core", -] - -[[package]] -name = "parking_lot_core" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "smallvec", - "windows-targets", -] - [[package]] name = "portable-atomic" version = "1.6.0" @@ -104,24 +65,24 @@ checksum = "7170ef9988bc169ba16dd36a7fa041e5c4cbeb6a35b76d4c03daded371eae7c0" [[package]] name = "proc-macro2" -version = "1.0.66" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] [[package]] name = "pyo3" -version = "0.20.3" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53bdbb96d49157e65d45cc287af5f32ffadd5f4761438b527b055fb0d4bb8233" +checksum = "1962a33ed2a201c637fc14a4e0fd4e06e6edfdeee6a5fede0dab55507ad74cf7" dependencies = [ "cfg-if", "indoc", "libc", "memoffset", - "parking_lot", + "once_cell", "portable-atomic", "pyo3-build-config", "pyo3-ffi", @@ -131,9 +92,9 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.20.3" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "deaa5745de3f5231ce10517a1f5dd97d53e5a2fd77aa6b5842292085831d48d7" +checksum = "ab7164b2202753bd33afc7f90a10355a719aa973d1f94502c50d06f3488bc420" dependencies = [ "once_cell", "target-lexicon", @@ -141,9 +102,9 @@ dependencies = [ [[package]] name = "pyo3-ffi" -version = "0.20.3" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b42531d03e08d4ef1f6e85a2ed422eb678b8cd62b762e53891c05faf0d4afa" +checksum = "c6424906ca49013c0829c5c1ed405e20e2da2dc78b82d198564880a704e6a7b7" dependencies = [ "libc", "pyo3-build-config", @@ -151,9 +112,9 @@ dependencies = [ [[package]] name = "pyo3-macros" -version = "0.20.3" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7305c720fa01b8055ec95e484a6eca7a83c841267f0dd5280f0c8b8551d2c158" +checksum = "82b2f19e153122d64afd8ce7aaa72f06a00f52e34e1d1e74b6d71baea396460a" dependencies = [ "proc-macro2", "pyo3-macros-backend", @@ -163,9 +124,9 @@ dependencies = [ [[package]] name = "pyo3-macros-backend" -version = "0.20.3" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c7e9b68bb9c3149c5b0cade5d07f953d6d125eb4337723c4ccdb665f1f96185" +checksum = "dd698c04cac17cf0fe63d47790ab311b8b25542f5cb976b65c374035c50f1eef" dependencies = [ "heck", "proc-macro2", @@ -176,22 +137,13 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.31" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fe8a65d69dd0808184ebb5f836ab526bb259db23c657efa38711b1072ee47f0" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] -[[package]] -name = "redox_syscall" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" -dependencies = [ - "bitflags", -] - [[package]] name = "rpds" version = "1.1.0" @@ -210,18 +162,6 @@ dependencies = [ "rpds", ] -[[package]] -name = "scopeguard" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" - -[[package]] -name = "smallvec" -version = "1.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9" - [[package]] name = "static_assertions" version = "1.1.0" @@ -230,9 +170,9 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "syn" -version = "2.0.32" +version = "2.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "239814284fd6f1a4ffe4ca893952cdd93c224b6a1571c9a9eadd670295c0c9e2" +checksum = "901fa70d88b9d6c98022e23b4136f9f3e54e4662c3bc1bd1d84a42a9a0f0c1e9" dependencies = [ "proc-macro2", "quote", @@ -241,9 +181,9 @@ dependencies = [ [[package]] name = "target-lexicon" -version = "0.12.9" +version = "0.12.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df8e77cb757a61f51b947ec4a7e3646efd825b73561db1c232a8ccb639e611a0" +checksum = "e1fc403891a21bcfb7c37834ba66a547a8f402146eba7265b5a6d88059c9ff2f" [[package]] name = "triomphe" @@ -262,60 +202,3 @@ name = "unindent" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c7de7d73e1754487cb58364ee906a499937a0dfabd86bcb980fa99ec8c8fa2ce" - -[[package]] -name = "windows-targets" -version = "0.48.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" -dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" - -[[package]] -name = "windows_i686_gnu" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" - -[[package]] -name = "windows_i686_msvc" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.48.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" diff --git a/Cargo.toml b/Cargo.toml index 13012d0..72fd5af 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,5 +12,5 @@ rpds = "1.1.0" archery = "1.2.0" [dependencies.pyo3] -version = "0.20.3" +version = "0.22.0" features = ["extension-module"] From 47cd96c57cb18f46e55c1e3c1849e0740a9ad159 Mon Sep 17 00:00:00 2001 From: Heyuan Zeng Date: Thu, 4 Jul 2024 03:41:23 +0100 Subject: [PATCH 127/241] WIP --- noxfile.py | 2 +- src/lib.rs | 124 +++++++++++++++++++++++++++++++---------------------- 2 files changed, 74 insertions(+), 52 deletions(-) diff --git a/noxfile.py b/noxfile.py index cd1da6d..4b81a5e 100644 --- a/noxfile.py +++ b/noxfile.py @@ -17,7 +17,7 @@ path.parent / f"{path.stem}.in" for path in REQUIREMENTS.values() ] -SUPPORTED = ["3.8", "3.9", "3.10", "3.11", "3.12", "pypy3.10"] +SUPPORTED = ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "pypy3.10"] LATEST = "3.12" nox.options.sessions = [] diff --git a/src/lib.rs b/src/lib.rs index e49e870..79bb51f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,7 +4,7 @@ use std::hash::{Hash, Hasher}; use pyo3::exceptions::PyIndexError; use pyo3::pyclass::CompareOp; use pyo3::types::{PyDict, PyIterator, PyTuple, PyType}; -use pyo3::{exceptions::PyKeyError, types::PyMapping}; +use pyo3::{exceptions::PyKeyError, types::PyMapping, types::PyTupleMethods}; use pyo3::{prelude::*, AsPyPointer, PyTypeInfo}; use rpds::{ HashTrieMap, HashTrieMapSync, HashTrieSet, HashTrieSetSync, List, ListSync, Queue, QueueSync, @@ -51,7 +51,7 @@ impl<'source> FromPyObject<'source> for Key { fn extract_bound(ob: &Bound<'source, PyAny>) -> PyResult { Ok(Key { hash: ob.hash()?, - inner: ob.unbind(), + inner: ob.clone().unbind(), }) } } @@ -89,7 +89,7 @@ impl<'source> FromPyObject<'source> for HashTrieMapPy { #[pymethods] impl HashTrieMapPy { #[new] - #[pyo3(signature = (value=None, **kwds))] + #[pyo3(signature = (value = None, * * kwds))] fn init(value: Option, kwds: Option<&Bound<'_, PyDict>>) -> PyResult { let mut map: HashTrieMapPy; if let Some(value) = value { @@ -151,20 +151,24 @@ impl HashTrieMapPy { match op { CompareOp::Eq => Ok((self.inner.size() == other.inner.size() && self - .inner - .iter() - .map(|(k1, v1)| (v1, other.inner.get(k1))) - .map(|(v1, v2)| PyAny::eq(v1.extract(py)?, v2)) - .all(|r| r.unwrap_or(false))) - .into_py(py)), + .inner + .iter() + .map(|(k1, v1)| (v1, other.inner.get(k1))) + .map(|(v1, v2)| { + v1.bind(py).eq(v2) + }) + .all(|r| r.unwrap_or(false))) + .into_py(py)), CompareOp::Ne => Ok((self.inner.size() != other.inner.size() || self - .inner - .iter() - .map(|(k1, v1)| (v1, other.inner.get(k1))) - .map(|(v1, v2)| PyAny::ne(v1.extract(py)?, v2)) - .all(|r| r.unwrap_or(true))) - .into_py(py)), + .inner + .iter() + .map(|(k1, v1)| (v1, other.inner.get(k1))) + .map(|(v1, v2)| { + v1.bind(py).eq(v2) + }) + .all(|r| r.unwrap_or(true))) + .into_py(py)), _ => Ok(py.NotImplemented()), } } @@ -173,9 +177,9 @@ impl HashTrieMapPy { ( HashTrieMapPy::type_object_bound(slf.py()), (slf.inner - .iter() - .map(|(k, v)| (k.clone(), v.clone())) - .collect(),), + .iter() + .map(|(k, v)| (k.clone(), v.clone())) + .collect(),), ) } @@ -204,7 +208,7 @@ impl HashTrieMapPy { let value = val.unwrap_or_else(|| &none); for each in keys.iter()? { let key = Key::extract_bound(&each?)?.to_owned(); - inner.insert_mut(key, value.unbind()); + inner.insert_mut(key, value.clone().unbind()); } Ok(HashTrieMapPy { inner }) } @@ -261,7 +265,7 @@ impl HashTrieMapPy { } } - #[pyo3(signature = (*maps, **kwds))] + #[pyo3(signature = (* maps, * * kwds))] fn update( &self, maps: &Bound<'_, PyTuple>, @@ -502,12 +506,30 @@ struct ItemsView { inner: HashTrieMapSync, } +struct ItemViewQuery(Key, PyObject); + +impl<'source> FromPyObject<'source> for ItemViewQuery { + fn extract_bound(ob: &Bound<'source, PyAny>) -> PyResult { + let tuple_bound: &Bound<'source, PyTuple> = ob.downcast()?; + + let k = tuple_bound.get_item(0)?; + let v = tuple_bound.get_item(1)?; + + Python::with_gil(|py| { + Ok(ItemViewQuery(Key::extract_bound(&k)?, v.into_py(py))) + }) + } +} + #[pymethods] impl ItemsView { - fn __contains__(slf: PyRef<'_, Self>, item: (Key, &PyAny)) -> PyResult { + fn __contains__(slf: PyRef<'_, Self>, item: ItemViewQuery) -> PyResult { if let Some(value) = slf.inner.get(&item.0) { - return item.1.eq(value); + return Python::with_gil(|py| { + item.1.bind(py).eq(value) + }); } + Ok(false) } @@ -527,7 +549,7 @@ impl ItemsView { return Ok(false); } for (k, v) in slf.inner.iter() { - if !other.contains((k.inner.to_owned(), v))? { + if !other.contains((k.inner.to_owned(), v.clone()))? { return Ok(false); } } @@ -582,7 +604,7 @@ impl ItemsView { let k = kv.get_item(0)?; match slf.inner.get(&Key::extract_bound(&k)?) { Some(value) => { - let pair = PyTuple::new_bound(py, [k, value.into_bound(py)]); + let pair = PyTuple::new_bound(py, [k, value.clone().into_bound(py)]); if !pair.eq(kv)? { return Ok(false); } @@ -603,7 +625,7 @@ impl ItemsView { let k = kv.get_item(0)?; match slf.inner.get(&Key::extract_bound(&k)?) { Some(value) => { - let pair = PyTuple::new_bound(py, [k, value.into_bound(py)]); + let pair = PyTuple::new_bound(py, [k, value.clone().into_bound(py)]); if !pair.eq(kv)? { return Ok(false); } @@ -641,7 +663,7 @@ impl ItemsView { let kv = each?; let k = kv.get_item(0)?; if let Some(value) = slf.inner.get(&Key::extract_bound(&k)?) { - let pair = PyTuple::new_bound(py, [k, value.into_bound(py)]); + let pair = PyTuple::new_bound(py, [k, value.clone().into_bound(py)]); if pair.eq(kv)? { inner.insert_mut(Key::extract_bound(&pair)?); } @@ -903,7 +925,7 @@ impl HashTrieSetPy { HashTrieSetPy { inner } } - #[pyo3(signature = (*iterables))] + #[pyo3(signature = (* iterables))] fn update(&self, iterables: Bound<'_, PyTuple>) -> PyResult { let mut inner = self.inner.clone(); for each in iterables { @@ -961,7 +983,7 @@ impl<'source> FromPyObject<'source> for ListPy { #[pymethods] impl ListPy { #[new] - #[pyo3(signature = (*elements))] + #[pyo3(signature = (* elements))] fn init(elements: &Bound<'_, PyTuple>) -> PyResult { let mut ret: ListPy; if elements.len() == 1 { @@ -998,20 +1020,20 @@ impl ListPy { match op { CompareOp::Eq => Ok((self.inner.len() == other.inner.len() && self - .inner - .iter() - .zip(other.inner.iter()) - .map(|(e1, e2)| PyAny::eq(e1.extract(py)?, e2)) - .all(|r| r.unwrap_or(false))) - .into_py(py)), + .inner + .iter() + .zip(other.inner.iter()) + .map(|(e1, e2)| e1.bind(py).eq(e2)) + .all(|r| r.unwrap_or(false))) + .into_py(py)), CompareOp::Ne => Ok((self.inner.len() != other.inner.len() || self - .inner - .iter() - .zip(other.inner.iter()) - .map(|(e1, e2)| PyAny::ne(e1.extract(py)?, e2)) - .any(|r| r.unwrap_or(true))) - .into_py(py)), + .inner + .iter() + .zip(other.inner.iter()) + .map(|(e1, e2)| e1.bind(py).eq(e2)) + .any(|r| r.unwrap_or(true))) + .into_py(py)), _ => Ok(py.NotImplemented()), } } @@ -1125,7 +1147,7 @@ impl<'source> FromPyObject<'source> for QueuePy { #[pymethods] impl QueuePy { #[new] - #[pyo3(signature = (*elements))] + #[pyo3(signature = (* elements))] fn init(elements: &Bound<'_, PyTuple>, py: Python<'_>) -> PyResult { let mut ret: QueuePy; if elements.len() == 1 { @@ -1146,11 +1168,11 @@ impl QueuePy { fn __eq__(&self, other: &Self, py: Python<'_>) -> bool { (self.inner.len() == other.inner.len()) && self - .inner - .iter() - .zip(other.inner.iter()) - .map(|(e1, e2)| PyAny::eq(e1.extract(py)?, e2)) - .all(|r| r.unwrap_or(false)) + .inner + .iter() + .zip(other.inner.iter()) + .map(|(e1, e2)| e1.bind(py).eq(e2)) + .all(|r| r.unwrap_or(false)) } fn __hash__(&self, py: Python<'_>) -> PyResult { @@ -1166,11 +1188,11 @@ impl QueuePy { fn __ne__(&self, other: &Self, py: Python<'_>) -> bool { (self.inner.len() != other.inner.len()) || self - .inner - .iter() - .zip(other.inner.iter()) - .map(|(e1, e2)| PyAny::ne(e1.extract(py)?, e2)) - .any(|r| r.unwrap_or(true)) + .inner + .iter() + .zip(other.inner.iter()) + .map(|(e1, e2)| e1.bind(py).eq(e2)) + .any(|r| r.unwrap_or(true)) } fn __iter__(slf: PyRef<'_, Self>) -> QueueIterator { From 4d4c71cf96c9085e271bb11a65644a55bb7e2946 Mon Sep 17 00:00:00 2001 From: Heyuan Zeng Date: Thu, 4 Jul 2024 02:22:47 +0100 Subject: [PATCH 128/241] WIP --- src/lib.rs | 198 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 127 insertions(+), 71 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 79bb51f..004791f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -10,7 +10,7 @@ use rpds::{ HashTrieMap, HashTrieMapSync, HashTrieSet, HashTrieSetSync, List, ListSync, Queue, QueueSync, }; -#[derive(Clone, Debug)] +#[derive(Debug)] struct Key { hash: isize, inner: PyObject, @@ -35,6 +35,21 @@ impl PartialEq for Key { } } +impl Key { + fn clone_ref(&self, py: Python<'_>) -> Self { + Key { + hash: self.hash, + inner: self.inner.clone_ref(py), + } + } +} + +impl Clone for Key { + fn clone(&self) -> Self { + Python::with_gil(|py| self.clone_ref(py)) + } +} + impl IntoPy for Key { fn into_py(self, py: Python<'_>) -> PyObject { self.inner.into_py(py) @@ -119,7 +134,9 @@ impl HashTrieMapPy { fn __getitem__(&self, key: Key) -> PyResult { match self.inner.get(&key) { - Some(value) => Ok(value.to_owned()), + Some(value) => Python::with_gil(|py| { + Ok(value.clone_ref(py)) + }), None => Err(PyKeyError::new_err(key)), } } @@ -165,7 +182,7 @@ impl HashTrieMapPy { .iter() .map(|(k1, v1)| (v1, other.inner.get(k1))) .map(|(v1, v2)| { - v1.bind(py).eq(v2) + v1.bind(py).ne(v2) }) .all(|r| r.unwrap_or(true))) .into_py(py)), @@ -174,13 +191,15 @@ impl HashTrieMapPy { } fn __reduce__(slf: PyRef) -> (Bound<'_, PyType>, (Vec<(Key, PyObject)>,)) { - ( - HashTrieMapPy::type_object_bound(slf.py()), - (slf.inner - .iter() - .map(|(k, v)| (k.clone(), v.clone())) - .collect(),), - ) + Python::with_gil(|py| { + ( + HashTrieMapPy::type_object_bound(slf.py()), + (slf.inner + .iter() + .map(|(k, v)| (k.clone_ref(py), v.clone_ref(py))) + .collect(),), + ) + }) } #[classmethod] @@ -207,7 +226,7 @@ impl HashTrieMapPy { let none = py.None().into_bound(py); let value = val.unwrap_or_else(|| &none); for each in keys.iter()? { - let key = Key::extract_bound(&each?)?.to_owned(); + let key = Key::extract_bound(&each?)?; inner.insert_mut(key, value.clone().unbind()); } Ok(HashTrieMapPy { inner }) @@ -215,7 +234,9 @@ impl HashTrieMapPy { fn get(&self, key: Key, default: Option) -> Option { if let Some(value) = self.inner.get(&key) { - Some(value.to_owned()) + Python::with_gil(|py| { + Some(value.clone_ref(py)) + }) } else { default } @@ -274,9 +295,11 @@ impl HashTrieMapPy { let mut inner = self.inner.clone(); for value in maps { let map = HashTrieMapPy::extract_bound(&value)?; - for (k, v) in &map.inner { - inner.insert_mut(k.to_owned(), v.to_owned()); - } + Python::with_gil(|py| { + for (k, v) in &map.inner { + inner.insert_mut(k.clone_ref(py), v.clone_ref(py)); + } + }) } if let Some(kwds) = kwds { for (k, v) in kwds { @@ -318,7 +341,7 @@ impl ValuesIterator { fn __next__(mut slf: PyRefMut<'_, Self>) -> Option { let kv = slf.inner.iter().next()?; - let value = kv.1.to_owned(); + let value = Python::with_gil(|py| { kv.1.clone_ref(py) }); slf.inner = slf.inner.remove(kv.0); Some(value) } @@ -338,8 +361,12 @@ impl ItemsIterator { fn __next__(mut slf: PyRefMut<'_, Self>) -> Option<(Key, PyObject)> { let kv = slf.inner.iter().next()?; let key = kv.0.to_owned(); - let value = kv.1.to_owned(); + let value = Python::with_gil(|py| { + kv.1.clone_ref(py) + }); + slf.inner = slf.inner.remove(kv.0); + Some((key, value)) } } @@ -373,12 +400,15 @@ impl KeysView { if !other.is_instance(&abc.getattr("Set")?)? || other.len()? <= slf.inner.size() { return Ok(false); } - for each in slf.inner.keys() { - if !other.contains(each.inner.to_owned())? { - return Ok(false); + + Python::with_gil(|py| { + for each in slf.inner.keys() { + if !other.contains(each.inner.clone_ref(py))? { + return Ok(false); + } } - } - Ok(true) + Ok(true) + }) } fn __le__(slf: PyRef<'_, Self>, other: &Bound<'_, PyAny>, py: Python) -> PyResult { @@ -386,12 +416,15 @@ impl KeysView { if !other.is_instance(&abc.getattr("Set")?)? || other.len()? < slf.inner.size() { return Ok(false); } - for each in slf.inner.keys() { - if !other.contains(each.inner.to_owned())? { - return Ok(false); + + Python::with_gil(|py| { + for each in slf.inner.keys() { + if !other.contains(each.inner.clone_ref(py))? { + return Ok(false); + } } - } - Ok(true) + Ok(true) + }) } fn __gt__(slf: PyRef<'_, Self>, other: &Bound<'_, PyAny>, py: Python) -> PyResult { @@ -548,17 +581,19 @@ impl ItemsView { if !other.is_instance(&abc.getattr("Set")?)? || other.len()? != slf.inner.size() { return Ok(false); } - for (k, v) in slf.inner.iter() { - if !other.contains((k.inner.to_owned(), v.clone()))? { - return Ok(false); + Python::with_gil(|py| { + for (k, v) in slf.inner.iter() { + if !other.contains((k.inner.clone_ref(py), v))? { + return Ok(false); + } } - } - Ok(true) + Ok(true) + }) } fn __repr__(&self, py: Python) -> String { let contents = self.inner.into_iter().map(|(k, v)| { - let tuple = PyTuple::new_bound(py, [k.inner.to_owned(), v.to_owned()]); + let tuple = PyTuple::new_bound(py, [k.inner.clone_ref(py), v.clone_ref(py)]); format!("{:?}", tuple) }); format!("items_view([{}])", contents.collect::>().join(", ")) @@ -570,7 +605,7 @@ impl ItemsView { return Ok(false); } for (k, v) in slf.inner.iter() { - let pair = PyTuple::new_bound(py, [k.inner.to_owned(), v.to_owned()]); + let pair = PyTuple::new_bound(py, [k.inner.clone_ref(py), v.clone_ref(py)]); // FIXME: needs to compare if !other.contains(pair)? { return Ok(false); @@ -585,7 +620,7 @@ impl ItemsView { return Ok(false); } for (k, v) in slf.inner.iter() { - let pair = PyTuple::new_bound(py, [k.inner.to_owned(), v.to_owned()]); + let pair = PyTuple::new_bound(py, [k.inner.clone_ref(py), v.clone_ref(py)]); // FIXME: needs to compare if !other.contains(pair)? { return Ok(false); @@ -604,7 +639,7 @@ impl ItemsView { let k = kv.get_item(0)?; match slf.inner.get(&Key::extract_bound(&k)?) { Some(value) => { - let pair = PyTuple::new_bound(py, [k, value.clone().into_bound(py)]); + let pair = PyTuple::new_bound(py, [k, value.bind(py).clone()]); if !pair.eq(kv)? { return Ok(false); } @@ -625,7 +660,7 @@ impl ItemsView { let k = kv.get_item(0)?; match slf.inner.get(&Key::extract_bound(&k)?) { Some(value) => { - let pair = PyTuple::new_bound(py, [k, value.clone().into_bound(py)]); + let pair = PyTuple::new_bound(py, [k, value.bind(py).clone()]); if !pair.eq(kv)? { return Ok(false); } @@ -663,7 +698,7 @@ impl ItemsView { let kv = each?; let k = kv.get_item(0)?; if let Some(value) = slf.inner.get(&Key::extract_bound(&k)?) { - let pair = PyTuple::new_bound(py, [k, value.clone().into_bound(py)]); + let pair = PyTuple::new_bound(py, [k, value.bind(py).clone()]); if pair.eq(kv)? { inner.insert_mut(Key::extract_bound(&pair)?); } @@ -680,7 +715,7 @@ impl ItemsView { // TODO: this is very inefficient, but again can't seem to get a HashTrieSet out of ourself let mut inner = HashTrieSet::new_sync(); for (k, v) in slf.inner.iter() { - let pair = PyTuple::new_bound(py, [k.inner.to_owned(), v.to_owned()]); + let pair = PyTuple::new_bound(py, [k.inner.clone_ref(py), v.clone_ref(py)]); inner.insert_mut(Key::extract_bound(&pair)?); } for each in other.iter()? { @@ -782,12 +817,14 @@ impl HashTrieSetPy { if !other.is_instance(&abc.getattr("Set")?)? || other.len()? <= slf.inner.size() { return Ok(false); } - for each in slf.inner.iter() { - if !other.contains(each.inner.to_owned())? { - return Ok(false); + Python::with_gil(|py| { + for each in slf.inner.iter() { + if !other.contains(each.inner.clone_ref(py))? { + return Ok(false); + } } - } - Ok(true) + Ok(true) + }) } fn __le__(slf: PyRef<'_, Self>, other: Bound<'_, PyAny>, py: Python) -> PyResult { @@ -795,12 +832,14 @@ impl HashTrieSetPy { if !other.is_instance(&abc.getattr("Set")?)? || other.len()? < slf.inner.size() { return Ok(false); } - for each in slf.inner.iter() { - if !other.contains(each.inner.to_owned())? { - return Ok(false); + Python::with_gil(|py| { + for each in slf.inner.iter() { + if !other.contains(each.inner.clone_ref(py))? { + return Ok(false); + } } - } - Ok(true) + Ok(true) + }) } fn __gt__(slf: PyRef<'_, Self>, other: Bound<'_, PyAny>, py: Python) -> PyResult { @@ -832,7 +871,9 @@ impl HashTrieSetPy { fn __reduce__(slf: PyRef) -> (Bound<'_, PyType>, (Vec,)) { ( HashTrieSetPy::type_object_bound(slf.py()), - (slf.inner.iter().cloned().collect(),), + (Python::with_gil(|py| { + slf.inner.iter().map(|e| e.clone_ref(py)).collect() + }),), ) } @@ -881,11 +922,13 @@ impl HashTrieSetPy { larger = &other.inner; iter = self.inner.iter(); } - for value in iter { - if larger.contains(value) { - inner.insert_mut(value.to_owned()); + Python::with_gil(|py| { + for value in iter { + if larger.contains(value) { + inner.insert_mut(value.clone_ref(py)); + } } - } + }); HashTrieSetPy { inner } } @@ -899,13 +942,15 @@ impl HashTrieSetPy { inner = other.inner.clone(); iter = self.inner.iter(); } - for value in iter { - if inner.contains(value) { - inner.remove_mut(value); - } else { - inner.insert_mut(value.to_owned()); + Python::with_gil(|py| { + for value in iter { + if inner.contains(value) { + inner.remove_mut(value); + } else { + inner.insert_mut(value.clone_ref(py)); + } } - } + }); HashTrieSetPy { inner } } @@ -919,9 +964,11 @@ impl HashTrieSetPy { inner = other.inner.clone(); iter = self.inner.iter(); } - for value in iter { - inner.insert_mut(value.to_owned()); - } + Python::with_gil(|py| { + for value in iter { + inner.insert_mut(value.clone_ref(py)); + } + }); HashTrieSetPy { inner } } @@ -1031,7 +1078,7 @@ impl ListPy { .inner .iter() .zip(other.inner.iter()) - .map(|(e1, e2)| e1.bind(py).eq(e2)) + .map(|(e1, e2)| e1.bind(py).ne(e2)) .any(|r| r.unwrap_or(true))) .into_py(py)), _ => Ok(py.NotImplemented()), @@ -1053,7 +1100,9 @@ impl ListPy { fn __reduce__(slf: PyRef) -> (Bound<'_, PyType>, (Vec,)) { ( ListPy::type_object_bound(slf.py()), - (slf.inner.iter().cloned().collect(),), + (Python::with_gil(|py| { + slf.inner.iter().map(|e| e.clone_ref(py)).collect() + }),), ) } @@ -1098,8 +1147,13 @@ impl ListIterator { } fn __next__(mut slf: PyRefMut<'_, Self>) -> Option { - let first = slf.inner.first()?.to_owned(); + let first_op = slf.inner.first()?; + let first = Python::with_gil(|py| { + first_op.clone_ref(py) + }); + slf.inner = slf.inner.drop_first()?; + Some(first) } } @@ -1116,7 +1170,10 @@ impl QueueIterator { } fn __next__(mut slf: PyRefMut<'_, Self>) -> Option { - let first = slf.inner.peek()?.to_owned(); + let first_op = slf.inner.peek()?; + let first = Python::with_gil(|py| { + first_op.clone_ref(py) + }); slf.inner = slf.inner.dequeue()?; Some(first) } @@ -1191,7 +1248,7 @@ impl QueuePy { .inner .iter() .zip(other.inner.iter()) - .map(|(e1, e2)| e1.bind(py).eq(e2)) + .map(|(e1, e2)| e1.bind(py).ne(e2)) .any(|r| r.unwrap_or(true)) } @@ -1207,8 +1264,7 @@ impl QueuePy { fn __repr__(&self, py: Python) -> String { let contents = self.inner.into_iter().map(|k| { - k.clone() - .into_py(py) + k.into_py(py) .call_method0(py, "__repr__") .and_then(|r| r.extract(py)) .unwrap_or("".to_owned()) @@ -1219,7 +1275,7 @@ impl QueuePy { #[getter] fn peek(&self) -> PyResult { if let Some(peeked) = self.inner.peek() { - Ok(peeked.to_owned()) + Ok(Python::with_gil(|py| peeked.clone_ref(py))) } else { Err(PyIndexError::new_err("peeked an empty queue")) } From 8ecb460fe14727cf3fdb8192aeb552da272c8d37 Mon Sep 17 00:00:00 2001 From: Heyuan Zeng Date: Thu, 4 Jul 2024 05:55:18 +0100 Subject: [PATCH 129/241] Fix formatting --- src/lib.rs | 118 +++++++++++++++++++++++------------------------------ 1 file changed, 50 insertions(+), 68 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 004791f..67f2af7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -104,7 +104,7 @@ impl<'source> FromPyObject<'source> for HashTrieMapPy { #[pymethods] impl HashTrieMapPy { #[new] - #[pyo3(signature = (value = None, * * kwds))] + #[pyo3(signature = (value=None, ** kwds))] fn init(value: Option, kwds: Option<&Bound<'_, PyDict>>) -> PyResult { let mut map: HashTrieMapPy; if let Some(value) = value { @@ -134,9 +134,7 @@ impl HashTrieMapPy { fn __getitem__(&self, key: Key) -> PyResult { match self.inner.get(&key) { - Some(value) => Python::with_gil(|py| { - Ok(value.clone_ref(py)) - }), + Some(value) => Python::with_gil(|py| Ok(value.clone_ref(py))), None => Err(PyKeyError::new_err(key)), } } @@ -168,24 +166,20 @@ impl HashTrieMapPy { match op { CompareOp::Eq => Ok((self.inner.size() == other.inner.size() && self - .inner - .iter() - .map(|(k1, v1)| (v1, other.inner.get(k1))) - .map(|(v1, v2)| { - v1.bind(py).eq(v2) - }) - .all(|r| r.unwrap_or(false))) - .into_py(py)), + .inner + .iter() + .map(|(k1, v1)| (v1, other.inner.get(k1))) + .map(|(v1, v2)| v1.bind(py).eq(v2)) + .all(|r| r.unwrap_or(false))) + .into_py(py)), CompareOp::Ne => Ok((self.inner.size() != other.inner.size() || self - .inner - .iter() - .map(|(k1, v1)| (v1, other.inner.get(k1))) - .map(|(v1, v2)| { - v1.bind(py).ne(v2) - }) - .all(|r| r.unwrap_or(true))) - .into_py(py)), + .inner + .iter() + .map(|(k1, v1)| (v1, other.inner.get(k1))) + .map(|(v1, v2)| v1.bind(py).ne(v2)) + .all(|r| r.unwrap_or(true))) + .into_py(py)), _ => Ok(py.NotImplemented()), } } @@ -195,9 +189,9 @@ impl HashTrieMapPy { ( HashTrieMapPy::type_object_bound(slf.py()), (slf.inner - .iter() - .map(|(k, v)| (k.clone_ref(py), v.clone_ref(py))) - .collect(),), + .iter() + .map(|(k, v)| (k.clone_ref(py), v.clone_ref(py))) + .collect(),), ) }) } @@ -234,9 +228,7 @@ impl HashTrieMapPy { fn get(&self, key: Key, default: Option) -> Option { if let Some(value) = self.inner.get(&key) { - Python::with_gil(|py| { - Some(value.clone_ref(py)) - }) + Python::with_gil(|py| Some(value.clone_ref(py))) } else { default } @@ -286,7 +278,7 @@ impl HashTrieMapPy { } } - #[pyo3(signature = (* maps, * * kwds))] + #[pyo3(signature = (*maps, **kwds))] fn update( &self, maps: &Bound<'_, PyTuple>, @@ -341,7 +333,7 @@ impl ValuesIterator { fn __next__(mut slf: PyRefMut<'_, Self>) -> Option { let kv = slf.inner.iter().next()?; - let value = Python::with_gil(|py| { kv.1.clone_ref(py) }); + let value = Python::with_gil(|py| kv.1.clone_ref(py)); slf.inner = slf.inner.remove(kv.0); Some(value) } @@ -361,9 +353,7 @@ impl ItemsIterator { fn __next__(mut slf: PyRefMut<'_, Self>) -> Option<(Key, PyObject)> { let kv = slf.inner.iter().next()?; let key = kv.0.to_owned(); - let value = Python::with_gil(|py| { - kv.1.clone_ref(py) - }); + let value = Python::with_gil(|py| kv.1.clone_ref(py)); slf.inner = slf.inner.remove(kv.0); @@ -548,9 +538,7 @@ impl<'source> FromPyObject<'source> for ItemViewQuery { let k = tuple_bound.get_item(0)?; let v = tuple_bound.get_item(1)?; - Python::with_gil(|py| { - Ok(ItemViewQuery(Key::extract_bound(&k)?, v.into_py(py))) - }) + Python::with_gil(|py| Ok(ItemViewQuery(Key::extract_bound(&k)?, v.into_py(py)))) } } @@ -558,9 +546,7 @@ impl<'source> FromPyObject<'source> for ItemViewQuery { impl ItemsView { fn __contains__(slf: PyRef<'_, Self>, item: ItemViewQuery) -> PyResult { if let Some(value) = slf.inner.get(&item.0) { - return Python::with_gil(|py| { - item.1.bind(py).eq(value) - }); + return Python::with_gil(|py| item.1.bind(py).eq(value)); } Ok(false) @@ -972,7 +958,7 @@ impl HashTrieSetPy { HashTrieSetPy { inner } } - #[pyo3(signature = (* iterables))] + #[pyo3(signature = (*iterables))] fn update(&self, iterables: Bound<'_, PyTuple>) -> PyResult { let mut inner = self.inner.clone(); for each in iterables { @@ -1030,7 +1016,7 @@ impl<'source> FromPyObject<'source> for ListPy { #[pymethods] impl ListPy { #[new] - #[pyo3(signature = (* elements))] + #[pyo3(signature = (*elements))] fn init(elements: &Bound<'_, PyTuple>) -> PyResult { let mut ret: ListPy; if elements.len() == 1 { @@ -1067,20 +1053,20 @@ impl ListPy { match op { CompareOp::Eq => Ok((self.inner.len() == other.inner.len() && self - .inner - .iter() - .zip(other.inner.iter()) - .map(|(e1, e2)| e1.bind(py).eq(e2)) - .all(|r| r.unwrap_or(false))) - .into_py(py)), + .inner + .iter() + .zip(other.inner.iter()) + .map(|(e1, e2)| e1.bind(py).eq(e2)) + .all(|r| r.unwrap_or(false))) + .into_py(py)), CompareOp::Ne => Ok((self.inner.len() != other.inner.len() || self - .inner - .iter() - .zip(other.inner.iter()) - .map(|(e1, e2)| e1.bind(py).ne(e2)) - .any(|r| r.unwrap_or(true))) - .into_py(py)), + .inner + .iter() + .zip(other.inner.iter()) + .map(|(e1, e2)| e1.bind(py).ne(e2)) + .any(|r| r.unwrap_or(true))) + .into_py(py)), _ => Ok(py.NotImplemented()), } } @@ -1148,9 +1134,7 @@ impl ListIterator { fn __next__(mut slf: PyRefMut<'_, Self>) -> Option { let first_op = slf.inner.first()?; - let first = Python::with_gil(|py| { - first_op.clone_ref(py) - }); + let first = Python::with_gil(|py| first_op.clone_ref(py)); slf.inner = slf.inner.drop_first()?; @@ -1171,9 +1155,7 @@ impl QueueIterator { fn __next__(mut slf: PyRefMut<'_, Self>) -> Option { let first_op = slf.inner.peek()?; - let first = Python::with_gil(|py| { - first_op.clone_ref(py) - }); + let first = Python::with_gil(|py| first_op.clone_ref(py)); slf.inner = slf.inner.dequeue()?; Some(first) } @@ -1204,7 +1186,7 @@ impl<'source> FromPyObject<'source> for QueuePy { #[pymethods] impl QueuePy { #[new] - #[pyo3(signature = (* elements))] + #[pyo3(signature = (*elements))] fn init(elements: &Bound<'_, PyTuple>, py: Python<'_>) -> PyResult { let mut ret: QueuePy; if elements.len() == 1 { @@ -1225,11 +1207,11 @@ impl QueuePy { fn __eq__(&self, other: &Self, py: Python<'_>) -> bool { (self.inner.len() == other.inner.len()) && self - .inner - .iter() - .zip(other.inner.iter()) - .map(|(e1, e2)| e1.bind(py).eq(e2)) - .all(|r| r.unwrap_or(false)) + .inner + .iter() + .zip(other.inner.iter()) + .map(|(e1, e2)| e1.bind(py).eq(e2)) + .all(|r| r.unwrap_or(false)) } fn __hash__(&self, py: Python<'_>) -> PyResult { @@ -1245,11 +1227,11 @@ impl QueuePy { fn __ne__(&self, other: &Self, py: Python<'_>) -> bool { (self.inner.len() != other.inner.len()) || self - .inner - .iter() - .zip(other.inner.iter()) - .map(|(e1, e2)| e1.bind(py).ne(e2)) - .any(|r| r.unwrap_or(true)) + .inner + .iter() + .zip(other.inner.iter()) + .map(|(e1, e2)| e1.bind(py).ne(e2)) + .any(|r| r.unwrap_or(true)) } fn __iter__(slf: PyRef<'_, Self>) -> QueueIterator { From 19842001cb5155740099a67eac22bd08e621e55b Mon Sep 17 00:00:00 2001 From: Heyuan Zeng Date: Fri, 5 Jul 2024 00:34:48 +0100 Subject: [PATCH 130/241] Remove redundant Python::with_gil calls --- src/lib.rs | 106 ++++++++++++++++++++++------------------------------- 1 file changed, 44 insertions(+), 62 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 67f2af7..98463f7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -185,15 +185,13 @@ impl HashTrieMapPy { } fn __reduce__(slf: PyRef) -> (Bound<'_, PyType>, (Vec<(Key, PyObject)>,)) { - Python::with_gil(|py| { - ( - HashTrieMapPy::type_object_bound(slf.py()), - (slf.inner - .iter() - .map(|(k, v)| (k.clone_ref(py), v.clone_ref(py))) - .collect(),), - ) - }) + ( + HashTrieMapPy::type_object_bound(slf.py()), + (slf.inner + .iter() + .map(|(k, v)| (k.clone_ref(slf.py()), v.clone_ref(slf.py()))) + .collect(),), + ) } #[classmethod] @@ -218,7 +216,7 @@ impl HashTrieMapPy { ) -> PyResult { let mut inner = HashTrieMap::new_sync(); let none = py.None().into_bound(py); - let value = val.unwrap_or_else(|| &none); + let value = val.unwrap_or(&none); for each in keys.iter()? { let key = Key::extract_bound(&each?)?; inner.insert_mut(key, value.clone().unbind()); @@ -287,11 +285,9 @@ impl HashTrieMapPy { let mut inner = self.inner.clone(); for value in maps { let map = HashTrieMapPy::extract_bound(&value)?; - Python::with_gil(|py| { - for (k, v) in &map.inner { - inner.insert_mut(k.clone_ref(py), v.clone_ref(py)); - } - }) + for (k, v) in &map.inner { + inner.insert_mut(k.clone_ref(value.py()), v.clone_ref(value.py())); + } } if let Some(kwds) = kwds { for (k, v) in kwds { @@ -333,7 +329,7 @@ impl ValuesIterator { fn __next__(mut slf: PyRefMut<'_, Self>) -> Option { let kv = slf.inner.iter().next()?; - let value = Python::with_gil(|py| kv.1.clone_ref(py)); + let value = kv.1.clone_ref(slf.py()); slf.inner = slf.inner.remove(kv.0); Some(value) } @@ -353,7 +349,7 @@ impl ItemsIterator { fn __next__(mut slf: PyRefMut<'_, Self>) -> Option<(Key, PyObject)> { let kv = slf.inner.iter().next()?; let key = kv.0.to_owned(); - let value = Python::with_gil(|py| kv.1.clone_ref(py)); + let value = kv.1.clone_ref(slf.py()); slf.inner = slf.inner.remove(kv.0); @@ -391,14 +387,12 @@ impl KeysView { return Ok(false); } - Python::with_gil(|py| { - for each in slf.inner.keys() { - if !other.contains(each.inner.clone_ref(py))? { - return Ok(false); - } + for each in slf.inner.keys() { + if !other.contains(each.inner.clone_ref(slf.py()))? { + return Ok(false); } - Ok(true) - }) + } + Ok(true) } fn __le__(slf: PyRef<'_, Self>, other: &Bound<'_, PyAny>, py: Python) -> PyResult { @@ -407,14 +401,12 @@ impl KeysView { return Ok(false); } - Python::with_gil(|py| { - for each in slf.inner.keys() { - if !other.contains(each.inner.clone_ref(py))? { - return Ok(false); - } + for each in slf.inner.keys() { + if !other.contains(each.inner.clone_ref(slf.py()))? { + return Ok(false); } - Ok(true) - }) + } + Ok(true) } fn __gt__(slf: PyRef<'_, Self>, other: &Bound<'_, PyAny>, py: Python) -> PyResult { @@ -538,7 +530,7 @@ impl<'source> FromPyObject<'source> for ItemViewQuery { let k = tuple_bound.get_item(0)?; let v = tuple_bound.get_item(1)?; - Python::with_gil(|py| Ok(ItemViewQuery(Key::extract_bound(&k)?, v.into_py(py)))) + Ok(ItemViewQuery(Key::extract_bound(&k)?, v.into_py(ob.py()))) } } @@ -546,7 +538,7 @@ impl<'source> FromPyObject<'source> for ItemViewQuery { impl ItemsView { fn __contains__(slf: PyRef<'_, Self>, item: ItemViewQuery) -> PyResult { if let Some(value) = slf.inner.get(&item.0) { - return Python::with_gil(|py| item.1.bind(py).eq(value)); + return item.1.bind(slf.py()).eq(value); } Ok(false) @@ -567,14 +559,12 @@ impl ItemsView { if !other.is_instance(&abc.getattr("Set")?)? || other.len()? != slf.inner.size() { return Ok(false); } - Python::with_gil(|py| { - for (k, v) in slf.inner.iter() { - if !other.contains((k.inner.clone_ref(py), v))? { - return Ok(false); - } + for (k, v) in slf.inner.iter() { + if !other.contains((k.inner.clone_ref(slf.py()), v))? { + return Ok(false); } - Ok(true) - }) + } + Ok(true) } fn __repr__(&self, py: Python) -> String { @@ -803,14 +793,12 @@ impl HashTrieSetPy { if !other.is_instance(&abc.getattr("Set")?)? || other.len()? <= slf.inner.size() { return Ok(false); } - Python::with_gil(|py| { - for each in slf.inner.iter() { - if !other.contains(each.inner.clone_ref(py))? { - return Ok(false); - } + for each in slf.inner.iter() { + if !other.contains(each.inner.clone_ref(py))? { + return Ok(false); } - Ok(true) - }) + } + Ok(true) } fn __le__(slf: PyRef<'_, Self>, other: Bound<'_, PyAny>, py: Python) -> PyResult { @@ -818,14 +806,12 @@ impl HashTrieSetPy { if !other.is_instance(&abc.getattr("Set")?)? || other.len()? < slf.inner.size() { return Ok(false); } - Python::with_gil(|py| { - for each in slf.inner.iter() { - if !other.contains(each.inner.clone_ref(py))? { - return Ok(false); - } + for each in slf.inner.iter() { + if !other.contains(each.inner.clone_ref(slf.py()))? { + return Ok(false); } - Ok(true) - }) + } + Ok(true) } fn __gt__(slf: PyRef<'_, Self>, other: Bound<'_, PyAny>, py: Python) -> PyResult { @@ -857,9 +843,7 @@ impl HashTrieSetPy { fn __reduce__(slf: PyRef) -> (Bound<'_, PyType>, (Vec,)) { ( HashTrieSetPy::type_object_bound(slf.py()), - (Python::with_gil(|py| { - slf.inner.iter().map(|e| e.clone_ref(py)).collect() - }),), + (slf.inner.iter().map(|e| e.clone_ref(slf.py())).collect(),), ) } @@ -1086,9 +1070,7 @@ impl ListPy { fn __reduce__(slf: PyRef) -> (Bound<'_, PyType>, (Vec,)) { ( ListPy::type_object_bound(slf.py()), - (Python::with_gil(|py| { - slf.inner.iter().map(|e| e.clone_ref(py)).collect() - }),), + (slf.inner.iter().map(|e| e.clone_ref(slf.py())).collect(),), ) } @@ -1134,7 +1116,7 @@ impl ListIterator { fn __next__(mut slf: PyRefMut<'_, Self>) -> Option { let first_op = slf.inner.first()?; - let first = Python::with_gil(|py| first_op.clone_ref(py)); + let first = first_op.clone_ref(slf.py()); slf.inner = slf.inner.drop_first()?; @@ -1155,7 +1137,7 @@ impl QueueIterator { fn __next__(mut slf: PyRefMut<'_, Self>) -> Option { let first_op = slf.inner.peek()?; - let first = Python::with_gil(|py| first_op.clone_ref(py)); + let first = first_op.clone_ref(slf.py()); slf.inner = slf.inner.dequeue()?; Some(first) } From d462f1d84da927d658c946f66ee7d85a625fac2c Mon Sep 17 00:00:00 2001 From: Heyuan Zeng Date: Fri, 5 Jul 2024 00:37:44 +0100 Subject: [PATCH 131/241] Fix clippy warnings --- src/lib.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 98463f7..b2f729d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -208,6 +208,7 @@ impl HashTrieMapPy { } #[classmethod] + #[pyo3(signature = (keys, val=None))] fn fromkeys( _cls: &Bound<'_, PyType>, keys: &Bound<'_, PyAny>, @@ -224,6 +225,7 @@ impl HashTrieMapPy { Ok(HashTrieMapPy { inner }) } + #[pyo3(signature = (key, default=None))] fn get(&self, key: Key, default: Option) -> Option { if let Some(value) = self.inner.get(&key) { Python::with_gil(|py| Some(value.clone_ref(py))) @@ -721,6 +723,7 @@ impl<'source> FromPyObject<'source> for HashTrieSetPy { #[pymethods] impl HashTrieSetPy { #[new] + #[pyo3(signature = (value=None))] fn init(value: Option) -> Self { if let Some(value) = value { value From 5e986afc1734da575aa96965a28c8208448bb07d Mon Sep 17 00:00:00 2001 From: Heyuan Zeng Date: Fri, 5 Jul 2024 00:38:35 +0100 Subject: [PATCH 132/241] Add Python 3.13 to GitHub actions CI --- .github/workflows/CI.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 9037d02..35eaadd 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -63,6 +63,7 @@ jobs: 3.10 3.11 3.12 + 3.13 pypy3.10 allow-prereleases: true - name: Set up nox From 6c7cdd241f149676ee5057a3c2dae6efdc8efb50 Mon Sep 17 00:00:00 2001 From: Heyuan Zeng Date: Fri, 5 Jul 2024 15:58:11 +0100 Subject: [PATCH 133/241] Remove redundant Python::wiht_gil calls --- src/lib.rs | 80 +++++++++++++++++++++++------------------------------- 1 file changed, 34 insertions(+), 46 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index b2f729d..beef11b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -44,12 +44,6 @@ impl Key { } } -impl Clone for Key { - fn clone(&self) -> Self { - Python::with_gil(|py| self.clone_ref(py)) - } -} - impl IntoPy for Key { fn into_py(self, py: Python<'_>) -> PyObject { self.inner.into_py(py) @@ -132,9 +126,9 @@ impl HashTrieMapPy { } } - fn __getitem__(&self, key: Key) -> PyResult { + fn __getitem__(&self, key: Key, py: Python) -> PyResult { match self.inner.get(&key) { - Some(value) => Python::with_gil(|py| Ok(value.clone_ref(py))), + Some(value) => Ok(value.clone_ref(py)), None => Err(PyKeyError::new_err(key)), } } @@ -226,9 +220,9 @@ impl HashTrieMapPy { } #[pyo3(signature = (key, default=None))] - fn get(&self, key: Key, default: Option) -> Option { + fn get(&self, key: Key, default: Option, py: Python) -> Option { if let Some(value) = self.inner.get(&key) { - Python::with_gil(|py| Some(value.clone_ref(py))) + Some(value.clone_ref(py)) } else { default } @@ -312,7 +306,7 @@ impl KeysIterator { } fn __next__(mut slf: PyRefMut<'_, Self>) -> Option { - let first = slf.inner.keys().next()?.to_owned(); + let first = slf.inner.keys().next()?.clone_ref(slf.py()); slf.inner = slf.inner.remove(&first); Some(first) } @@ -350,7 +344,7 @@ impl ItemsIterator { fn __next__(mut slf: PyRefMut<'_, Self>) -> Option<(Key, PyObject)> { let kv = slf.inner.iter().next()?; - let key = kv.0.to_owned(); + let key = kv.0.clone_ref(slf.py()); let value = kv.1.clone_ref(slf.py()); slf.inner = slf.inner.remove(kv.0); @@ -457,7 +451,7 @@ impl KeysView { fn __repr__(&self, py: Python) -> String { let contents = self.inner.into_iter().map(|(k, _)| { - k.clone() + k.clone_ref(py) .inner .into_py(py) .call_method0(py, "__repr__") @@ -738,20 +732,20 @@ impl HashTrieSetPy { self.inner.contains(&key) } - fn __and__(&self, other: &Self) -> Self { - self.intersection(other) + fn __and__(&self, other: &Self, py: Python) -> Self { + self.intersection(other, py) } - fn __or__(&self, other: &Self) -> Self { - self.union(other) + fn __or__(&self, other: &Self, py: Python) -> Self { + self.union(other, py) } fn __sub__(&self, other: &Self) -> Self { self.difference(other) } - fn __xor__(&self, other: &Self) -> Self { - self.symmetric_difference(other) + fn __xor__(&self, other: &Self, py: Python) -> Self { + self.symmetric_difference(other, py) } fn __iter__(slf: PyRef<'_, Self>) -> SetIterator { @@ -766,7 +760,7 @@ impl HashTrieSetPy { fn __repr__(&self, py: Python) -> String { let contents = self.inner.into_iter().map(|k| { - k.clone() + k.clone_ref(py) .into_py(py) .call_method0(py, "__repr__") .and_then(|r| r.extract(py)) @@ -884,7 +878,7 @@ impl HashTrieSetPy { HashTrieSetPy { inner } } - fn intersection(&self, other: &Self) -> HashTrieSetPy { + fn intersection(&self, other: &Self, py: Python) -> HashTrieSetPy { let mut inner: HashTrieSetSync = HashTrieSet::new_sync(); let larger: &HashTrieSetSync; let iter; @@ -895,17 +889,15 @@ impl HashTrieSetPy { larger = &other.inner; iter = self.inner.iter(); } - Python::with_gil(|py| { - for value in iter { - if larger.contains(value) { - inner.insert_mut(value.clone_ref(py)); - } + for value in iter { + if larger.contains(value) { + inner.insert_mut(value.clone_ref(py)); } - }); + } HashTrieSetPy { inner } } - fn symmetric_difference(&self, other: &Self) -> HashTrieSetPy { + fn symmetric_difference(&self, other: &Self, py: Python) -> HashTrieSetPy { let mut inner: HashTrieSetSync; let iter; if self.inner.size() > other.inner.size() { @@ -915,19 +907,17 @@ impl HashTrieSetPy { inner = other.inner.clone(); iter = self.inner.iter(); } - Python::with_gil(|py| { - for value in iter { - if inner.contains(value) { - inner.remove_mut(value); - } else { - inner.insert_mut(value.clone_ref(py)); - } + for value in iter { + if inner.contains(value) { + inner.remove_mut(value); + } else { + inner.insert_mut(value.clone_ref(py)); } - }); + } HashTrieSetPy { inner } } - fn union(&self, other: &Self) -> HashTrieSetPy { + fn union(&self, other: &Self, py: Python) -> HashTrieSetPy { let mut inner: HashTrieSetSync; let iter; if self.inner.size() > other.inner.size() { @@ -937,11 +927,9 @@ impl HashTrieSetPy { inner = other.inner.clone(); iter = self.inner.iter(); } - Python::with_gil(|py| { - for value in iter { - inner.insert_mut(value.clone_ref(py)); - } - }); + for value in iter { + inner.insert_mut(value.clone_ref(py)); + } HashTrieSetPy { inner } } @@ -951,7 +939,7 @@ impl HashTrieSetPy { for each in iterables { let iter = each.iter()?; for value in iter { - inner.insert_mut(Key::extract_bound(&value?)?.to_owned()); + inner.insert_mut(Key::extract_bound(&value?)?); } } Ok(HashTrieSetPy { inner }) @@ -970,7 +958,7 @@ impl SetIterator { } fn __next__(mut slf: PyRefMut<'_, Self>) -> Option { - let first = slf.inner.iter().next()?.to_owned(); + let first = slf.inner.iter().next()?.clone_ref(slf.py()); slf.inner = slf.inner.remove(&first); Some(first) } @@ -1240,9 +1228,9 @@ impl QueuePy { } #[getter] - fn peek(&self) -> PyResult { + fn peek(&self, py: Python) -> PyResult { if let Some(peeked) = self.inner.peek() { - Ok(Python::with_gil(|py| peeked.clone_ref(py))) + Ok(peeked.clone_ref(py)) } else { Err(PyIndexError::new_err("peeked an empty queue")) } From 0c600b8dd0e959dde6f0c18e32447ec447ffc1fa Mon Sep 17 00:00:00 2001 From: Heyuan Zeng Date: Sun, 7 Jul 2024 00:32:54 +0100 Subject: [PATCH 134/241] Use #[derive(FromPyObject)] instead of manual impl --- src/lib.rs | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index beef11b..8dae4aa 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -517,19 +517,9 @@ struct ItemsView { inner: HashTrieMapSync, } +#[derive(FromPyObject)] struct ItemViewQuery(Key, PyObject); -impl<'source> FromPyObject<'source> for ItemViewQuery { - fn extract_bound(ob: &Bound<'source, PyAny>) -> PyResult { - let tuple_bound: &Bound<'source, PyTuple> = ob.downcast()?; - - let k = tuple_bound.get_item(0)?; - let v = tuple_bound.get_item(1)?; - - Ok(ItemViewQuery(Key::extract_bound(&k)?, v.into_py(ob.py()))) - } -} - #[pymethods] impl ItemsView { fn __contains__(slf: PyRef<'_, Self>, item: ItemViewQuery) -> PyResult { From 605215e7d41c4eb504d9b40bf101b828baf1a531 Mon Sep 17 00:00:00 2001 From: Heyuan Zeng Date: Sun, 7 Jul 2024 23:08:00 +0100 Subject: [PATCH 135/241] Update PyO3 from 0.22.0 to 0.22.1 --- Cargo.lock | 48 ++++++++++++++++++++++++------------------------ Cargo.toml | 2 +- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a383eff..03a3cb9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -14,9 +14,9 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.1.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "cfg-if" @@ -32,9 +32,9 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "indoc" -version = "2.0.4" +version = "2.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e186cfbae8084e513daff4240b4797e342f988cecda4fb6c939150f96315fd8" +checksum = "b248f5224d1d606005e02c97f5aa4e88eeb230488bcc03bc9ca4d7991399f2b5" [[package]] name = "libc" @@ -44,18 +44,18 @@ checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "memoffset" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" +checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a" dependencies = [ "autocfg", ] [[package]] name = "once_cell" -version = "1.18.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "portable-atomic" @@ -74,9 +74,9 @@ dependencies = [ [[package]] name = "pyo3" -version = "0.22.0" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1962a33ed2a201c637fc14a4e0fd4e06e6edfdeee6a5fede0dab55507ad74cf7" +checksum = "4e99090d12f6182924499253aaa1e73bf15c69cea8d2774c3c781e35badc3548" dependencies = [ "cfg-if", "indoc", @@ -92,9 +92,9 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.22.0" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab7164b2202753bd33afc7f90a10355a719aa973d1f94502c50d06f3488bc420" +checksum = "7879eb018ac754bba32cb0eec7526391c02c14a093121857ed09fbf1d1057d41" dependencies = [ "once_cell", "target-lexicon", @@ -102,9 +102,9 @@ dependencies = [ [[package]] name = "pyo3-ffi" -version = "0.22.0" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6424906ca49013c0829c5c1ed405e20e2da2dc78b82d198564880a704e6a7b7" +checksum = "ce2baa5559a411fc1cf519295f24c34b53d5d725818bc96b5abf94762da09041" dependencies = [ "libc", "pyo3-build-config", @@ -112,9 +112,9 @@ dependencies = [ [[package]] name = "pyo3-macros" -version = "0.22.0" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82b2f19e153122d64afd8ce7aaa72f06a00f52e34e1d1e74b6d71baea396460a" +checksum = "049621c20a23f2def20f4fe67978d1da8d8a883d64b9c21362f3b776e254edc7" dependencies = [ "proc-macro2", "pyo3-macros-backend", @@ -124,9 +124,9 @@ dependencies = [ [[package]] name = "pyo3-macros-backend" -version = "0.22.0" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd698c04cac17cf0fe63d47790ab311b8b25542f5cb976b65c374035c50f1eef" +checksum = "0e969ee2e025435f1819d31a275ba4bb9cbbdf3ac535227fdbd85b9322ffe144" dependencies = [ "heck", "proc-macro2", @@ -170,9 +170,9 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "syn" -version = "2.0.68" +version = "2.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "901fa70d88b9d6c98022e23b4136f9f3e54e4662c3bc1bd1d84a42a9a0f0c1e9" +checksum = "201fcda3845c23e8212cd466bfebf0bd20694490fc0356ae8e428e0824a915a6" dependencies = [ "proc-macro2", "quote", @@ -187,15 +187,15 @@ checksum = "e1fc403891a21bcfb7c37834ba66a547a8f402146eba7265b5a6d88059c9ff2f" [[package]] name = "triomphe" -version = "0.1.9" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0eee8098afad3fb0c54a9007aab6804558410503ad676d4633f9c2559a00ac0f" +checksum = "e6631e42e10b40c0690bf92f404ebcfe6e1fdb480391d15f17cc8e96eeed5369" [[package]] name = "unicode-ident" -version = "1.0.11" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unindent" diff --git a/Cargo.toml b/Cargo.toml index 72fd5af..a68c6d0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,5 +12,5 @@ rpds = "1.1.0" archery = "1.2.0" [dependencies.pyo3] -version = "0.22.0" +version = "0.22.1" features = ["extension-module"] From 06e0cd3d1cd65b7031e3cb049130013cc54df2dc Mon Sep 17 00:00:00 2001 From: Heyuan Zeng Date: Mon, 8 Jul 2024 01:35:42 +0100 Subject: [PATCH 136/241] Implement __hash__ for HashTrieSetPy --- src/lib.rs | 23 +++++++++++++++++++++++ tests/test_hash_trie_set.py | 19 +++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 8dae4aa..0e268b1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -775,6 +775,29 @@ impl HashTrieSetPy { Ok(true) } + fn __hash__(&self, py: Python) -> PyResult { + let hash = PyModule::import_bound(py, "builtins")?.getattr("hash")?; + + let mut hasher = DefaultHasher::new(); + + let mut hash_vec = self + .inner + .iter() + .map(|k| { + let hash_val: i64 = hash.call1((k.inner.clone_ref(py),))?.extract()?; + Ok(hash_val) + }) + .collect::>>()?; + + hash_vec.sort_unstable(); // Order of elements should not affect hash values (numbers) + + for hash_val in hash_vec { + hasher.write_i64(hash_val); + } + + Ok(hasher.finish()) + } + fn __lt__(slf: PyRef<'_, Self>, other: Bound<'_, PyAny>, py: Python) -> PyResult { let abc = PyModule::import_bound(py, "collections.abc")?; if !other.is_instance(&abc.getattr("Set")?)? || other.len()? <= slf.inner.size() { diff --git a/tests/test_hash_trie_set.py b/tests/test_hash_trie_set.py index 791c941..fbb078d 100644 --- a/tests/test_hash_trie_set.py +++ b/tests/test_hash_trie_set.py @@ -181,6 +181,25 @@ def test_more_eq(): assert HashTrieSet([1, 2]) != [1, 2] +def test_hash(): + o = object() + + assert hash(HashTrieSet([o])) == hash(HashTrieSet([o])) + assert hash(HashTrieSet([o, o])) == hash(HashTrieSet([o, o])) + assert hash(HashTrieSet([])) == hash(HashTrieSet([])) + assert hash(HashTrieSet([1, 2])) == hash(HashTrieSet([1, 2])) + assert hash(HashTrieSet([1, 2])) == hash(HashTrieSet([2, 1])) + assert not (HashTrieSet([1, 2]) == HashTrieSet([1, 3])) + assert not (HashTrieSet([]) == HashTrieSet([o])) + + assert hash(HashTrieSet([1, 2])) != hash(HashTrieSet([1, 3])) + assert hash(HashTrieSet([1, o])) != hash(HashTrieSet([1, 2])) + assert hash(HashTrieSet([1, 2])) != hash(HashTrieSet([2, 1, 3])) + assert not (HashTrieSet([o]) != HashTrieSet([o, o])) + assert not (HashTrieSet([o, o]) != HashTrieSet([o, o])) + assert not (HashTrieSet() != HashTrieSet([])) + + def test_more_set_comparisons(): s = HashTrieSet([1, 2, 3]) From 28e5b0ed1eef6241ad145cd7d98c96b635a6ca7d Mon Sep 17 00:00:00 2001 From: Heyuan Zeng Date: Mon, 8 Jul 2024 01:40:24 +0100 Subject: [PATCH 137/241] Add __hash__ to ListPy --- src/lib.rs | 10 ++++++++++ tests/test_list.py | 18 ++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 0e268b1..11a45de 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1059,6 +1059,16 @@ impl ListPy { } } + fn __hash__(&self, py: Python) -> PyResult { + let hash = PyModule::import_bound(py, "builtins")?.getattr("hash")?; + let mut hasher = DefaultHasher::new(); + for each in &self.inner { + let n: i64 = hash.call1((each.clone_ref(py),))?.extract()?; + hasher.write_i64(n); + } + Ok(hasher.finish()) + } + fn __iter__(slf: PyRef<'_, Self>) -> ListIterator { ListIterator { inner: slf.inner.clone(), diff --git a/tests/test_list.py b/tests/test_list.py index ad0864d..ed1ca16 100644 --- a/tests/test_list.py +++ b/tests/test_list.py @@ -144,5 +144,23 @@ def test_more_eq(): assert not (List() != List([])) +def test_hash(): + o = object() + + assert hash(List([o, o])) == hash(List([o, o])) + assert hash(List([o])) == hash(List([o])) + assert hash(List()) == hash(List([])) + assert not (hash(List([1, 2])) == hash(List([1, 3]))) + assert not (hash(List([o])) == hash(List([o, o]))) + assert not (hash(List([])) == hash(List([o]))) + + assert hash(List([1, 2])) != hash(List([1, 3])) + assert hash(List([o])) != hash(List([o, o])) + assert hash(List([])) != hash(List([o])) + assert not (hash(List([o, o])) != hash(List([o, o]))) + assert not (hash(List([o])) != hash(List([o]))) + assert not (hash(List([])) != hash(List([]))) + + def test_pickle(): assert pickle.loads(pickle.dumps(List([1, 2, 3, 4]))) == List([1, 2, 3, 4]) From efc9825c05fb354c6ac07da23cefd54c3f11df5a Mon Sep 17 00:00:00 2001 From: Heyuan Zeng Date: Mon, 8 Jul 2024 01:50:27 +0100 Subject: [PATCH 138/241] Implement __hash__ for HashTrieMap --- src/lib.rs | 24 ++++++++++++++++++++++++ tests/test_hash_trie_map.py | 18 ++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 11a45de..5782776 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -178,6 +178,30 @@ impl HashTrieMapPy { } } + fn __hash__(&self, py: Python) -> PyResult { + let hash = PyModule::import_bound(py, "builtins")?.getattr("hash")?; + + let mut hasher = DefaultHasher::new(); + + let mut hash_vec = self + .inner + .iter() + .map(|(key, val)| { + let key_hash: i64 = hash.call1((key.inner.clone_ref(py),))?.extract()?; + let val_hash: i64 = hash.call1((val.clone_ref(py),))?.extract()?; + Ok((key_hash, val_hash)) + }) + .collect::>>()?; + + hash_vec.sort_unstable(); // Order of elements should not affect hash values (numbers) + + for (key_hash, val_hash) in hash_vec { + hasher.write_i128(((key_hash as i128) << 64) | (val_hash as i128)); + } + + Ok(hasher.finish()) + } + fn __reduce__(slf: PyRef) -> (Bound<'_, PyType>, (Vec<(Key, PyObject)>,)) { ( HashTrieMapPy::type_object_bound(slf.py()), diff --git a/tests/test_hash_trie_map.py b/tests/test_hash_trie_map.py index e65b601..cbbe214 100644 --- a/tests/test_hash_trie_map.py +++ b/tests/test_hash_trie_map.py @@ -337,6 +337,24 @@ def test_more_eq(): assert HashTrieMap([]) != HashTrieMap([(o, 1)]) +def test_hash(): + o = object() + + assert hash(HashTrieMap([(o, o), (1, o)])) == hash( + HashTrieMap([(o, o), (1, o)]) + ) + assert hash(HashTrieMap([(o, o), (1, o)])) == hash( + HashTrieMap([(1, o), (o, o)]) + ) + assert hash(HashTrieMap([(o, "foo")])) == hash(HashTrieMap([(o, "foo")])) + assert hash(HashTrieMap()) == hash(HashTrieMap([])) + + assert hash(HashTrieMap({1: 2})) != hash(HashTrieMap({1: 3})) + assert hash(HashTrieMap({o: 1})) != hash(HashTrieMap({o: o})) + assert hash(HashTrieMap([])) != hash(HashTrieMap([(o, 1)])) + assert hash(HashTrieMap({1: 2, 3: 4})) != hash(HashTrieMap({1: 3, 2: 4})) + + def test_pickle(): assert pickle.loads( pickle.dumps(HashTrieMap([(1, 2), (3, 4)])), From 13d546977c721c32a1c3e3ae3bb26effe30e0c3d Mon Sep 17 00:00:00 2001 From: Heyuan Zeng Date: Mon, 8 Jul 2024 01:52:58 +0100 Subject: [PATCH 139/241] Revise inline comments --- src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 5782776..fefea62 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -193,7 +193,7 @@ impl HashTrieMapPy { }) .collect::>>()?; - hash_vec.sort_unstable(); // Order of elements should not affect hash values (numbers) + hash_vec.sort_unstable(); // Order of identical elements should not affect hash values (numbers) for (key_hash, val_hash) in hash_vec { hasher.write_i128(((key_hash as i128) << 64) | (val_hash as i128)); @@ -813,7 +813,7 @@ impl HashTrieSetPy { }) .collect::>>()?; - hash_vec.sort_unstable(); // Order of elements should not affect hash values (numbers) + hash_vec.sort_unstable(); // Order of identical elements should not affect hash values (numbers) for hash_val in hash_vec { hasher.write_i64(hash_val); From 974af19b2a39b45b17f9439fbab1fd943492b287 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Mon, 8 Jul 2024 09:10:10 -0400 Subject: [PATCH 140/241] Update requirements. --- docs/requirements.txt | 20 ++++++++++---------- tests/requirements.txt | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/requirements.txt b/docs/requirements.txt index d9cb93e..75ce514 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -6,38 +6,38 @@ # alabaster==0.7.16 # via sphinx -babel==2.14.0 +babel==2.15.0 # via sphinx beautifulsoup4==4.12.3 # via furo -certifi==2024.2.2 +certifi==2024.7.4 # via requests charset-normalizer==3.3.2 # via requests -docutils==0.21.1 +docutils==0.21.2 # via sphinx -furo==2024.1.29 +furo==2024.5.6 # via -r docs/requirements.in idna==3.7 # via requests imagesize==1.4.1 # via sphinx -jinja2==3.1.3 +jinja2==3.1.4 # via sphinx markupsafe==2.1.5 # via jinja2 -packaging==24.0 +packaging==24.1 # via sphinx pyenchant==3.2.2 # via sphinxcontrib-spelling -pygments==2.17.2 +pygments==2.18.0 # via # furo # pygments-github-lexers # sphinx pygments-github-lexers==0.0.5 # via -r docs/requirements.in -requests==2.31.0 +requests==2.32.3 # via sphinx file:.#egg=rpds-py # via -r docs/requirements.in @@ -73,7 +73,7 @@ sphinxcontrib-spelling==8.0.0 # via -r docs/requirements.in sphinxext-opengraph==0.9.1 # via -r docs/requirements.in -url-py==0.10.0 +url-py==0.11.3 # via -r docs/requirements.in -urllib3==2.2.1 +urllib3==2.2.2 # via requests diff --git a/tests/requirements.txt b/tests/requirements.txt index b3d7d87..a1693cf 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -6,11 +6,11 @@ # iniconfig==2.0.0 # via pytest -packaging==24.0 +packaging==24.1 # via pytest pluggy==1.5.0 # via pytest -pytest==8.1.1 +pytest==8.2.2 # via -r tests/requirements.in file:.#egg=rpds-py # via -r tests/requirements.in From 4e347fc0341f34c1022202e295633fa01bfa6748 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Mon, 8 Jul 2024 09:54:02 -0400 Subject: [PATCH 141/241] Bump to 0.19.0 --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 03a3cb9..850fdb6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -155,7 +155,7 @@ dependencies = [ [[package]] name = "rpds-py" -version = "0.18.1" +version = "0.19.0" dependencies = [ "archery", "pyo3", diff --git a/Cargo.toml b/Cargo.toml index a68c6d0..49c4671 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rpds-py" -version = "0.18.1" +version = "0.19.0" edition = "2021" [lib] From 0b6ea677974fdf2856d975e9386e16bec441424f Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Mon, 8 Jul 2024 10:23:12 -0400 Subject: [PATCH 142/241] Add the 3.13 classifier. --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 94b2c2c..1510df2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,6 +23,7 @@ classifiers = [ "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", "Programming Language :: Python :: 3", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", From 447d4c5acbf0916af227ec8d0fb8da32db88a38c Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Mon, 8 Jul 2024 18:26:14 -0400 Subject: [PATCH 143/241] uv in the noxfile and CI. --- .github/workflows/CI.yml | 3 +++ noxfile.py | 31 +++++++++++++++++-------------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 35eaadd..221355d 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -66,8 +66,11 @@ jobs: 3.13 pypy3.10 allow-prereleases: true + - name: Set up uv + uses: hynek/setup-cached-uv@v1 - name: Set up nox uses: wntrblm/nox@2024.04.15 + - name: Run nox run: nox -s "${{ matrix.noxenv }}" diff --git a/noxfile.py b/noxfile.py index 4b81a5e..ba4719f 100644 --- a/noxfile.py +++ b/noxfile.py @@ -5,21 +5,22 @@ import nox ROOT = Path(__file__).parent -TESTS = ROOT / "tests" PYPROJECT = ROOT / "pyproject.toml" DOCS = ROOT / "docs" +TESTS = ROOT / "tests" REQUIREMENTS = dict( docs=DOCS / "requirements.txt", tests=TESTS / "requirements.txt", ) REQUIREMENTS_IN = [ # this is actually ordered, as files depend on each other - path.parent / f"{path.stem}.in" for path in REQUIREMENTS.values() + (path.parent / f"{path.stem}.in", path) for path in REQUIREMENTS.values() ] -SUPPORTED = ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "pypy3.10"] +SUPPORTED = ["3.8", "3.9", "3.10", "pypy3.10", "3.11", "3.12", "3.13"] LATEST = "3.12" +nox.options.default_venv_backend = "uv|virtualenv" nox.options.sessions = [] @@ -145,15 +146,17 @@ def docs_style(session): @session(default=False) def requirements(session): """ - Update the project's pinned requirements. Commit the result. + Update the project's pinned requirements. + + You should commit the result afterwards. """ - session.install("pip-tools") - for each in REQUIREMENTS_IN: - session.run( - "pip-compile", - "--resolver", - "backtracking", - "--strip-extras", - "-U", - each.relative_to(ROOT), - ) + if session.venv_backend == "uv": + cmd = ["uv", "pip", "compile"] + else: + session.install("pip-tools") + cmd = ["pip-compile", "--resolver", "backtracking", "--strip-extras"] + + for each, out in REQUIREMENTS_IN: + # otherwise output files end up with silly absolute path comments... + relative = each.relative_to(ROOT) + session.run(*cmd, "--upgrade", "--output-file", out, relative) From 949964e8c5879ced1ed03e2c7eb9fcdb8c24b16f Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Mon, 8 Jul 2024 18:26:33 -0400 Subject: [PATCH 144/241] Let pre-commit.ci handle pre-commit. --- .github/workflows/CI.yml | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 221355d..5c1a0ba 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -15,15 +15,6 @@ on: workflow_dispatch: jobs: - pre-commit: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: "3.x" - - uses: pre-commit/action@v3.0.1 - list: runs-on: ubuntu-latest outputs: @@ -41,6 +32,7 @@ jobs: test: needs: list runs-on: ubuntu-latest + strategy: fail-fast: false matrix: From 26c472fe38b82622273ccbc8ef11928580c470fe Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Mon, 8 Jul 2024 18:31:41 -0400 Subject: [PATCH 145/241] Newer ruff + minor linter tweaks. --- .pre-commit-config.yaml | 8 -------- noxfile.py | 11 ++++++++++- pyproject.toml | 21 ++++++++------------- 3 files changed, 18 insertions(+), 22 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c50db8f..97473fa 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -23,14 +23,6 @@ repos: hooks: - id: fmt - id: clippy - - repo: https://github.com/PyCQA/isort - rev: 5.13.2 - hooks: - - id: isort - - repo: https://github.com/asottile/pyupgrade - rev: v3.16.0 - hooks: - - id: pyupgrade - repo: https://github.com/psf/black rev: 24.4.2 hooks: diff --git a/noxfile.py b/noxfile.py index ba4719f..11e1f98 100644 --- a/noxfile.py +++ b/noxfile.py @@ -90,7 +90,16 @@ def style(session): Check Python code style. """ session.install("ruff") - session.run("ruff", "check", ROOT) + session.run("ruff", "check", TESTS, __file__) + + +@session() +def typing(session): + """ + Check the codebase using pyright by type checking the test suite. + """ + session.install("pyright", ROOT, "-r", REQUIREMENTS["tests"]) + session.run("pyright", TESTS) @session(tags=["docs"]) diff --git a/pyproject.toml b/pyproject.toml index 1510df2..87d01a7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["maturin>=1.0,<2.0"] +requires = ["maturin>=1.2,<2.0"] build-backend = "maturin" [project] @@ -64,15 +64,6 @@ ignore = [ "D001", # one sentence per line, so max length doesn't make sense ] -[tool.isort] -combine_as_imports = true -ensure_newline_before_comments = true -from_first = true -include_trailing_comma = true -multi_line_output = 3 -known_first_party = ["rpds"] -use_parentheses = true - [tool.maturin] features = ["pyo3/extension-module"] @@ -86,6 +77,8 @@ exclude = [ [tool.ruff] line-length = 79 + +[tool.ruff.lint] select = ["ALL"] ignore = [ "A001", # It's fine to shadow builtins @@ -93,6 +86,7 @@ ignore = [ "A003", "ARG", # This is all wrong whenever an interface is involved "ANN", # Just let the type checker do this + "B006", # Mutable arguments require care but are OK if you don't abuse them "B008", # It's totally OK to call functions for default arguments. "B904", # raise SomeException(...) is fine. "B905", # No need for explicit strict, this is simply zip's default behavior @@ -112,7 +106,6 @@ ignore = [ "EM102", "FBT", # It's worth avoiding boolean args but I don't care to enforce it "FIX", # Yes thanks, if I could it wouldn't be there - "I001", # We can't yet use ruff's isort "N", # These naming rules are silly "PLR0912", # These metrics are fine to be aware of but not to enforce "PLR0913", @@ -130,17 +123,19 @@ ignore = [ "TD", # These TODO style rules are also silly "UP007", # We support 3.8 + 3.9 ] + [tool.ruff.lint.flake8-pytest-style] mark-parentheses = false -[tool.ruff.flake8-quotes] +[tool.ruff.lint.flake8-quotes] docstring-quotes = "double" [tool.ruff.lint.isort] combine-as-imports = true from-first = true +known-first-party = ["rpds"] -[tool.ruff.per-file-ignores] +[tool.ruff.lint.per-file-ignores] "noxfile.py" = ["ANN", "D100", "S101", "T201"] "docs/*" = ["ANN", "D", "INP001"] "tests/*" = ["ANN", "B018", "D", "PLR", "RUF012", "S", "SIM", "TRY"] From c8d7b8a9be4e30194dab228d56a5f9cb64f78fde Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Mon, 8 Jul 2024 18:32:26 -0400 Subject: [PATCH 146/241] Move to the v4 artifact actions. --- .github/workflows/CI.yml | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 5c1a0ba..3e4aa0c 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -85,9 +85,9 @@ jobs: sccache: "true" manylinux: auto - name: Upload wheels - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: wheels + name: dist-${{ github.job }}-${{ matrix.target }} path: dist musllinux: @@ -112,9 +112,9 @@ jobs: manylinux: musllinux_1_2 sccache: "true" - name: Upload wheels - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: wheels + name: dist-${{ github.job }}-${{ matrix.target }} path: dist windows: @@ -141,9 +141,9 @@ jobs: args: --release --out dist --interpreter '3.8 3.9 3.10 3.11 3.12' sccache: "true" - name: Upload wheels - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: wheels + name: dist-${{ github.job }}-${{ matrix.target }} path: dist macos: @@ -164,9 +164,9 @@ jobs: args: --release --out dist --interpreter '3.8 3.9 3.10 3.11 3.12 pypy3.8 pypy3.9 pypy3.10' sccache: "true" - name: Upload wheels - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: wheels + name: dist-${{ github.job }}-${{ matrix.target }} path: dist sdist: @@ -180,9 +180,9 @@ jobs: command: sdist args: --out dist - name: Upload sdist - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: wheels + name: dist-${{ github.job }} path: dist release: @@ -197,9 +197,10 @@ jobs: id-token: write steps: - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: - name: wheels + pattern: dist-* + merge-multiple: true - name: Publish to PyPI uses: PyO3/maturin-action@v1 with: From e4865c4695d61417d02d85752fa31ed85408a74e Mon Sep 17 00:00:00 2001 From: Roman Inflianskas Date: Mon, 8 Jul 2024 20:31:21 +0300 Subject: [PATCH 147/241] Make Python versions in GitHub Actions consistent To ensure consistently, use the following Python versions everywhere in CI: - 3.8 - 3.9 - 3.10 - 3.11 - 3.12 - 3.13 - pypy3.9 - pypy3.10 The wheels for Python 3.13 are beneficial for dependent packages such as `jsonschema`. Note that PyPy3.8 was dropped since the PyPy website (https://www.pypy.org/) states they currently support Python versions 3.10, 3.9, and 2.7. To build the extension for PyPy on Windows, "generate-import-lib" in `Cargo.toml` is needed, as per this GitHub issue: https://github.com/PyO3/maturin-action/issues/267#issuecomment-2106844429 --- .github/workflows/CI.yml | 60 ++++++++++++++++++++++++++++++++++------ Cargo.lock | 16 +++++++++++ Cargo.toml | 4 ++- 3 files changed, 71 insertions(+), 9 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 3e4aa0c..0a5ef17 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -56,6 +56,7 @@ jobs: 3.11 3.12 3.13 + pypy3.9 pypy3.10 allow-prereleases: true - name: Set up uv @@ -76,12 +77,21 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: "3.x" + python-version: | + 3.8 + 3.9 + 3.10 + 3.11 + 3.12 + 3.13 + pypy3.9 + pypy3.10 + allow-prereleases: true - name: Build wheels uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} - args: --release --out dist --interpreter '3.8 3.9 3.10 3.11 3.12 pypy3.8 pypy3.9 pypy3.10' + args: --release --out dist --interpreter '3.8 3.9 3.10 3.11 3.12 3.13 pypy3.9 pypy3.10' sccache: "true" manylinux: auto - name: Upload wheels @@ -103,12 +113,21 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: "3.x" + python-version: | + 3.8 + 3.9 + 3.10 + 3.11 + 3.12 + 3.13 + pypy3.9 + pypy3.10 + allow-prereleases: true - name: Build wheels uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} - args: --release --out dist --interpreter '3.8 3.9 3.10 3.11 3.12 pypy3.8 pypy3.9 pypy3.10' + args: --release --out dist --interpreter '3.8 3.9 3.10 3.11 3.12 3.13 pypy3.9 pypy3.10' manylinux: musllinux_1_2 sccache: "true" - name: Upload wheels @@ -122,7 +141,7 @@ jobs: runs-on: windows-latest strategy: matrix: - target: [x64, x86] + target: [x64, x86] # x86 is not supported by pypy steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 @@ -133,12 +152,16 @@ jobs: 3.10 3.11 3.12 + 3.13 + ${{ matrix.target == 'x64' && 'pypy3.9' || '' }} + ${{ matrix.target == 'x64' && 'pypy3.10' || '' }} + allow-prereleases: true architecture: ${{ matrix.target }} - name: Build wheels uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} - args: --release --out dist --interpreter '3.8 3.9 3.10 3.11 3.12' + args: --release --out dist --interpreter '3.8 3.9 3.10 3.11 3.12 3.13' --interpreter ${{ matrix.target == 'x64' && 'pypy3.9 pypy3.10' || '' }} sccache: "true" - name: Upload wheels uses: actions/upload-artifact@v4 @@ -156,12 +179,21 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: "3.x" + python-version: | + 3.8 + 3.9 + 3.10 + 3.11 + 3.12 + 3.13 + pypy3.9 + pypy3.10 + allow-prereleases: true - name: Build wheels uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} - args: --release --out dist --interpreter '3.8 3.9 3.10 3.11 3.12 pypy3.8 pypy3.9 pypy3.10' + args: --release --out dist --interpreter '3.8 3.9 3.10 3.11 3.12 3.13 pypy3.9 pypy3.10' sccache: "true" - name: Upload wheels uses: actions/upload-artifact@v4 @@ -174,6 +206,18 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: | + 3.8 + 3.9 + 3.10 + 3.11 + 3.12 + 3.13 + pypy3.9 + pypy3.10 + allow-prereleases: true - name: Build an sdist uses: PyO3/maturin-action@v1 with: diff --git a/Cargo.lock b/Cargo.lock index 850fdb6..6bb575a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -18,6 +18,12 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" +[[package]] +name = "cc" +version = "1.0.90" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5" + [[package]] name = "cfg-if" version = "1.0.0" @@ -97,6 +103,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7879eb018ac754bba32cb0eec7526391c02c14a093121857ed09fbf1d1057d41" dependencies = [ "once_cell", + "python3-dll-a", "target-lexicon", ] @@ -135,6 +142,15 @@ dependencies = [ "syn", ] +[[package]] +name = "python3-dll-a" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd0b78171a90d808b319acfad166c4790d9e9759bbc14ac8273fe133673dd41b" +dependencies = [ + "cc", +] + [[package]] name = "quote" version = "1.0.36" diff --git a/Cargo.toml b/Cargo.toml index 49c4671..46a410d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,4 +13,6 @@ archery = "1.2.0" [dependencies.pyo3] version = "0.22.1" -features = ["extension-module"] +# To build extension for PyPy on Windows, "generate-import-lib" is needed: +# https://github.com/PyO3/maturin-action/issues/267#issuecomment-2106844429 +features = ["extension-module", "generate-import-lib"] From 8164c3e222cc705dc97feea311329a31c7f10275 Mon Sep 17 00:00:00 2001 From: Heyuan Zeng Date: Thu, 11 Jul 2024 00:45:46 +0100 Subject: [PATCH 148/241] Re-implement __hash__ for unordered collections --- src/lib.rs | 158 +++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 117 insertions(+), 41 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index fefea62..c3a4e2d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,7 +1,4 @@ -use std::collections::hash_map::DefaultHasher; -use std::hash::{Hash, Hasher}; - -use pyo3::exceptions::PyIndexError; +use pyo3::exceptions::{PyIndexError, PyTypeError}; use pyo3::pyclass::CompareOp; use pyo3::types::{PyDict, PyIterator, PyTuple, PyType}; use pyo3::{exceptions::PyKeyError, types::PyMapping, types::PyTupleMethods}; @@ -9,6 +6,12 @@ use pyo3::{prelude::*, AsPyPointer, PyTypeInfo}; use rpds::{ HashTrieMap, HashTrieMapSync, HashTrieSet, HashTrieSetSync, List, ListSync, Queue, QueueSync, }; +use std::collections::hash_map::DefaultHasher; +use std::hash::{Hash, Hasher}; + +fn hash_shuffle_bits(h: usize) -> usize { + ((h ^ 89869747) ^ (h << 16)) * 3644798167 +} #[derive(Debug)] struct Key { @@ -178,28 +181,56 @@ impl HashTrieMapPy { } } - fn __hash__(&self, py: Python) -> PyResult { - let hash = PyModule::import_bound(py, "builtins")?.getattr("hash")?; + fn __hash__(&self, py: Python) -> PyResult { + // modified from https://github.com/python/cpython/blob/d69529d31ccd1510843cfac1ab53bb8cb027541f/Objects/setobject.c#L715 - let mut hasher = DefaultHasher::new(); - - let mut hash_vec = self + let mut hash_val = self .inner .iter() .map(|(key, val)| { - let key_hash: i64 = hash.call1((key.inner.clone_ref(py),))?.extract()?; - let val_hash: i64 = hash.call1((val.clone_ref(py),))?.extract()?; - Ok((key_hash, val_hash)) + let mut hasher = DefaultHasher::new(); + + let key_hash = key.inner.bind(py).hash().map_err(|_| { + PyTypeError::new_err(format!( + "Unhashable type in map key {}", + key.inner + .bind(py) + .repr() + .map_or(" error".to_string(), |e| { + e.to_str().unwrap().to_string() + }) + )) + })?; + + let val_hash = val.bind(py).hash().map_err(|_| { + PyTypeError::new_err(format!( + "Unhashable type in map value {}", + key.inner + .bind(py) + .repr() + .map_or(" error".to_string(), |e| { + e.to_str().unwrap().to_string() + }) + )) + })?; + + hasher.write_isize(key_hash); + hasher.write_isize(val_hash); + + Ok(hasher.finish() as usize) }) - .collect::>>()?; + .try_fold(0, |acc: usize, x: PyResult| { + PyResult::::Ok(acc ^ hash_shuffle_bits(x?)) + })?; - hash_vec.sort_unstable(); // Order of identical elements should not affect hash values (numbers) + // facto in the number of entries in the collection + hash_val ^= (self.inner.size() + 1) * 1927868237; - for (key_hash, val_hash) in hash_vec { - hasher.write_i128(((key_hash as i128) << 64) | (val_hash as i128)); - } + // dispense patterns in the hash value + hash_val ^= (hash_val >> 11) ^ (hash_val >> 25); + hash_val = hash_val * 69069 + 907133923; - Ok(hasher.finish()) + Ok(hash_val as isize) } fn __reduce__(slf: PyRef) -> (Bound<'_, PyType>, (Vec<(Key, PyObject)>,)) { @@ -799,27 +830,38 @@ impl HashTrieSetPy { Ok(true) } - fn __hash__(&self, py: Python) -> PyResult { - let hash = PyModule::import_bound(py, "builtins")?.getattr("hash")?; - - let mut hasher = DefaultHasher::new(); + fn __hash__(&self, py: Python) -> PyResult { + // modified from https://github.com/python/cpython/blob/d69529d31ccd1510843cfac1ab53bb8cb027541f/Objects/setobject.c#L715 - let mut hash_vec = self + let mut hash_val = self .inner .iter() .map(|k| { - let hash_val: i64 = hash.call1((k.inner.clone_ref(py),))?.extract()?; - Ok(hash_val) + let hash_val = k.inner.bind(py).hash().map_err(|_| { + PyTypeError::new_err(format!( + "Unhashable type in set {}", + k.inner + .bind(py) + .repr() + .map_or(" error".to_string(), |e| { + e.to_str().unwrap().to_string() + }) + )) + })?; + Ok(hash_val as usize) }) - .collect::>>()?; + .try_fold(0, |acc: usize, x: PyResult| { + PyResult::::Ok(acc ^ hash_shuffle_bits(x?)) + })?; - hash_vec.sort_unstable(); // Order of identical elements should not affect hash values (numbers) + // facto in the number of entries in the collection + hash_val ^= (self.inner.size() + 1) * 1927868237; - for hash_val in hash_vec { - hasher.write_i64(hash_val); - } + // dispense patterns in the hash value + hash_val ^= (hash_val >> 11) ^ (hash_val >> 25); + hash_val = hash_val * 69069 + 907133923; - Ok(hasher.finish()) + Ok(hash_val as isize) } fn __lt__(slf: PyRef<'_, Self>, other: Bound<'_, PyAny>, py: Python) -> PyResult { @@ -1084,12 +1126,29 @@ impl ListPy { } fn __hash__(&self, py: Python) -> PyResult { - let hash = PyModule::import_bound(py, "builtins")?.getattr("hash")?; let mut hasher = DefaultHasher::new(); - for each in &self.inner { - let n: i64 = hash.call1((each.clone_ref(py),))?.extract()?; - hasher.write_i64(n); - } + + self.inner + .iter() + .enumerate() + .map(|(index, each)| { + each.bind(py) + .hash() + .map_err(|_| { + PyTypeError::new_err(format!( + "Unhashable type at {} element in List: {}", + index, + each.bind(py) + .repr() + .map_or(" error".to_string(), |e| { + e.to_str().unwrap().to_string() + }) + )) + }) + .map(|x| hasher.write_isize(x)) + }) + .collect::>>()?; + Ok(hasher.finish()) } @@ -1235,12 +1294,29 @@ impl QueuePy { } fn __hash__(&self, py: Python<'_>) -> PyResult { - let hash = PyModule::import_bound(py, "builtins")?.getattr("hash")?; let mut hasher = DefaultHasher::new(); - for each in &self.inner { - let n: i64 = hash.call1((each.into_py(py),))?.extract()?; - hasher.write_i64(n); - } + + self.inner + .iter() + .enumerate() + .map(|(index, each)| { + each.bind(py) + .hash() + .map_err(|_| { + PyTypeError::new_err(format!( + "Unhashable type at {} element in Queue: {}", + index, + each.bind(py) + .repr() + .map_or(" error".to_string(), |e| { + e.to_str().unwrap().to_string() + }) + )) + }) + .map(|x| hasher.write_isize(x)) + }) + .collect::>>()?; + Ok(hasher.finish()) } From 41fcce3ddb00d30881a4193cc13c3c0c6ce59b4b Mon Sep 17 00:00:00 2001 From: Heyuan Zeng Date: Thu, 11 Jul 2024 00:56:48 +0100 Subject: [PATCH 149/241] Fix testing --- tests/test_hash_trie_map.py | 18 ---------------- tests/test_hash_trie_set.py | 41 +++++++++++++++---------------------- tests/test_list.py | 40 +++++++++++++++--------------------- tests/test_queue.py | 2 -- 4 files changed, 34 insertions(+), 67 deletions(-) diff --git a/tests/test_hash_trie_map.py b/tests/test_hash_trie_map.py index cbbe214..e65b601 100644 --- a/tests/test_hash_trie_map.py +++ b/tests/test_hash_trie_map.py @@ -337,24 +337,6 @@ def test_more_eq(): assert HashTrieMap([]) != HashTrieMap([(o, 1)]) -def test_hash(): - o = object() - - assert hash(HashTrieMap([(o, o), (1, o)])) == hash( - HashTrieMap([(o, o), (1, o)]) - ) - assert hash(HashTrieMap([(o, o), (1, o)])) == hash( - HashTrieMap([(1, o), (o, o)]) - ) - assert hash(HashTrieMap([(o, "foo")])) == hash(HashTrieMap([(o, "foo")])) - assert hash(HashTrieMap()) == hash(HashTrieMap([])) - - assert hash(HashTrieMap({1: 2})) != hash(HashTrieMap({1: 3})) - assert hash(HashTrieMap({o: 1})) != hash(HashTrieMap({o: o})) - assert hash(HashTrieMap([])) != hash(HashTrieMap([(o, 1)])) - assert hash(HashTrieMap({1: 2, 3: 4})) != hash(HashTrieMap({1: 3, 2: 4})) - - def test_pickle(): assert pickle.loads( pickle.dumps(HashTrieMap([(1, 2), (3, 4)])), diff --git a/tests/test_hash_trie_set.py b/tests/test_hash_trie_set.py index fbb078d..1dd21f4 100644 --- a/tests/test_hash_trie_set.py +++ b/tests/test_hash_trie_set.py @@ -34,8 +34,6 @@ from rpds import HashTrieSet -HASH_MSG = "Not sure HashTrieSet implements Hash, it has mutable methods" - def test_key_is_tuple(): with pytest.raises(KeyError): @@ -47,9 +45,23 @@ def test_key_is_not_tuple(): HashTrieSet().remove("asdf") -@pytest.mark.xfail(reason=HASH_MSG) -def test_supports_hash(): - assert hash(HashTrieSet((1, 2))) == hash(HashTrieSet(1, 2)) +def test_hashing(): + o = object() + + assert hash(HashTrieSet([o])) == hash(HashTrieSet([o])) + assert hash(HashTrieSet([o, o])) == hash(HashTrieSet([o, o])) + assert hash(HashTrieSet([])) == hash(HashTrieSet([])) + assert hash(HashTrieSet([1, 2])) == hash(HashTrieSet([1, 2])) + assert hash(HashTrieSet([1, 2])) == hash(HashTrieSet([2, 1])) + assert not (HashTrieSet([1, 2]) == HashTrieSet([1, 3])) + assert not (HashTrieSet([]) == HashTrieSet([o])) + + assert hash(HashTrieSet([1, 2])) != hash(HashTrieSet([1, 3])) + assert hash(HashTrieSet([1, o])) != hash(HashTrieSet([1, 2])) + assert hash(HashTrieSet([1, 2])) != hash(HashTrieSet([2, 1, 3])) + assert not (HashTrieSet([o]) != HashTrieSet([o, o])) + assert not (HashTrieSet([o, o]) != HashTrieSet([o, o])) + assert not (HashTrieSet() != HashTrieSet([])) def test_empty_truthiness(): @@ -181,25 +193,6 @@ def test_more_eq(): assert HashTrieSet([1, 2]) != [1, 2] -def test_hash(): - o = object() - - assert hash(HashTrieSet([o])) == hash(HashTrieSet([o])) - assert hash(HashTrieSet([o, o])) == hash(HashTrieSet([o, o])) - assert hash(HashTrieSet([])) == hash(HashTrieSet([])) - assert hash(HashTrieSet([1, 2])) == hash(HashTrieSet([1, 2])) - assert hash(HashTrieSet([1, 2])) == hash(HashTrieSet([2, 1])) - assert not (HashTrieSet([1, 2]) == HashTrieSet([1, 3])) - assert not (HashTrieSet([]) == HashTrieSet([o])) - - assert hash(HashTrieSet([1, 2])) != hash(HashTrieSet([1, 3])) - assert hash(HashTrieSet([1, o])) != hash(HashTrieSet([1, 2])) - assert hash(HashTrieSet([1, 2])) != hash(HashTrieSet([2, 1, 3])) - assert not (HashTrieSet([o]) != HashTrieSet([o, o])) - assert not (HashTrieSet([o, o]) != HashTrieSet([o, o])) - assert not (HashTrieSet() != HashTrieSet([])) - - def test_more_set_comparisons(): s = HashTrieSet([1, 2, 3]) diff --git a/tests/test_list.py b/tests/test_list.py index ed1ca16..5038676 100644 --- a/tests/test_list.py +++ b/tests/test_list.py @@ -33,8 +33,6 @@ from rpds import List -HASH_MSG = "Not sure List implements Hash, it has mutable methods" - def test_literalish_works(): assert List(1, 2, 3) == List([1, 2, 3]) @@ -100,10 +98,24 @@ def test_repr(): assert str(List([1, 2, 3])) in "List([1, 2, 3])" -@pytest.mark.xfail(reason=HASH_MSG) def test_hashing(): - assert hash(List([1, 2])) == hash(List([1, 2])) - assert hash(List([1, 2])) != hash(List([2, 1])) + o = object() + + assert hash(List([o, o])) == hash(List([o, o])) + assert hash(List([o])) == hash(List([o])) + assert hash(List()) == hash(List([])) + assert not (hash(List([1, 2])) == hash(List([1, 3]))) + assert not (hash(List[1, 2]) == hash(List[2, 1])) + assert not (hash(List([o])) == hash(List([o, o]))) + assert not (hash(List([])) == hash(List([o]))) + + assert hash(List([1, 2])) != hash(List([1, 3])) + assert hash(List[1, 2]) != hash(List[2, 1]) + assert hash(List([o])) != hash(List([o, o])) + assert hash(List([])) != hash(List([o])) + assert not (hash(List([o, o])) != hash(List([o, o]))) + assert not (hash(List([o])) != hash(List([o]))) + assert not (hash(List([])) != hash(List([]))) def test_sequence(): @@ -144,23 +156,5 @@ def test_more_eq(): assert not (List() != List([])) -def test_hash(): - o = object() - - assert hash(List([o, o])) == hash(List([o, o])) - assert hash(List([o])) == hash(List([o])) - assert hash(List()) == hash(List([])) - assert not (hash(List([1, 2])) == hash(List([1, 3]))) - assert not (hash(List([o])) == hash(List([o, o]))) - assert not (hash(List([])) == hash(List([o]))) - - assert hash(List([1, 2])) != hash(List([1, 3])) - assert hash(List([o])) != hash(List([o, o])) - assert hash(List([])) != hash(List([o])) - assert not (hash(List([o, o])) != hash(List([o, o]))) - assert not (hash(List([o])) != hash(List([o]))) - assert not (hash(List([])) != hash(List([]))) - - def test_pickle(): assert pickle.loads(pickle.dumps(List([1, 2, 3, 4]))) == List([1, 2, 3, 4]) diff --git a/tests/test_queue.py b/tests/test_queue.py index 402145e..e2dadab 100644 --- a/tests/test_queue.py +++ b/tests/test_queue.py @@ -31,8 +31,6 @@ from rpds import Queue -HASH_MSG = "Not sure Queue implements Hash, it has mutable methods" - def test_literalish_works(): assert Queue(1, 2, 3) == Queue([1, 2, 3]) From 781ba2dc6e14248561cf43204c5998b1ba0f3576 Mon Sep 17 00:00:00 2001 From: Heyuan Zeng Date: Thu, 11 Jul 2024 00:57:09 +0100 Subject: [PATCH 150/241] Remove __hash__ for HashTrieMap --- src/lib.rs | 52 ---------------------------------------------------- 1 file changed, 52 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index c3a4e2d..83adeb3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -181,58 +181,6 @@ impl HashTrieMapPy { } } - fn __hash__(&self, py: Python) -> PyResult { - // modified from https://github.com/python/cpython/blob/d69529d31ccd1510843cfac1ab53bb8cb027541f/Objects/setobject.c#L715 - - let mut hash_val = self - .inner - .iter() - .map(|(key, val)| { - let mut hasher = DefaultHasher::new(); - - let key_hash = key.inner.bind(py).hash().map_err(|_| { - PyTypeError::new_err(format!( - "Unhashable type in map key {}", - key.inner - .bind(py) - .repr() - .map_or(" error".to_string(), |e| { - e.to_str().unwrap().to_string() - }) - )) - })?; - - let val_hash = val.bind(py).hash().map_err(|_| { - PyTypeError::new_err(format!( - "Unhashable type in map value {}", - key.inner - .bind(py) - .repr() - .map_or(" error".to_string(), |e| { - e.to_str().unwrap().to_string() - }) - )) - })?; - - hasher.write_isize(key_hash); - hasher.write_isize(val_hash); - - Ok(hasher.finish() as usize) - }) - .try_fold(0, |acc: usize, x: PyResult| { - PyResult::::Ok(acc ^ hash_shuffle_bits(x?)) - })?; - - // facto in the number of entries in the collection - hash_val ^= (self.inner.size() + 1) * 1927868237; - - // dispense patterns in the hash value - hash_val ^= (hash_val >> 11) ^ (hash_val >> 25); - hash_val = hash_val * 69069 + 907133923; - - Ok(hash_val as isize) - } - fn __reduce__(slf: PyRef) -> (Bound<'_, PyType>, (Vec<(Key, PyObject)>,)) { ( HashTrieMapPy::type_object_bound(slf.py()), From 003fb6c6b3a5eeeea09cb149d0e72365207d8b95 Mon Sep 17 00:00:00 2001 From: Heyuan Zeng Date: Thu, 11 Jul 2024 00:58:55 +0100 Subject: [PATCH 151/241] Fix tests --- tests/test_list.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_list.py b/tests/test_list.py index 5038676..6f00b30 100644 --- a/tests/test_list.py +++ b/tests/test_list.py @@ -105,12 +105,12 @@ def test_hashing(): assert hash(List([o])) == hash(List([o])) assert hash(List()) == hash(List([])) assert not (hash(List([1, 2])) == hash(List([1, 3]))) - assert not (hash(List[1, 2]) == hash(List[2, 1])) + assert not (hash(List([1, 2])) == hash(List([2, 1]))) assert not (hash(List([o])) == hash(List([o, o]))) assert not (hash(List([])) == hash(List([o]))) assert hash(List([1, 2])) != hash(List([1, 3])) - assert hash(List[1, 2]) != hash(List[2, 1]) + assert hash(List([1, 2])) != hash(List([2, 1])) assert hash(List([o])) != hash(List([o, o])) assert hash(List([])) != hash(List([o])) assert not (hash(List([o, o])) != hash(List([o, o]))) From 26a8d37f0df74e545aef9f7803f906da55fed9c9 Mon Sep 17 00:00:00 2001 From: Heyuan Zeng Date: Thu, 11 Jul 2024 02:11:00 +0100 Subject: [PATCH 152/241] Implement __hash__ for HashTrieMap --- src/lib.rs | 45 +++++++++++++++++++++++++++++++++++++ tests/test_hash_trie_map.py | 20 ++++++++++++----- 2 files changed, 60 insertions(+), 5 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 83adeb3..b9b8bfe 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -181,6 +181,51 @@ impl HashTrieMapPy { } } + fn __hash__(&self, py: Python) -> PyResult { + // modified from https://github.com/python/cpython/blob/d69529d31ccd1510843cfac1ab53bb8cb027541f/Objects/setobject.c#L715 + + let mut hash_val = self + .inner + .iter() + .map(|(key, val)| { + let mut hasher = DefaultHasher::new(); + let val_bound = val.bind(py); + + let key_hash = key.hash; + let val_hash = val_bound.hash().map_err(|_| { + PyTypeError::new_err(format!( + "Unhashable type in HashTrieMap of key {}: {}", + key.inner + .bind(py) + .repr() + .map_or(" error".to_string(), |e| { + e.to_str().unwrap().to_string() + }), + val_bound.repr().map_or(" error".to_string(), |e| { + e.to_str().unwrap().to_string() + }) + )) + })?; + + hasher.write_isize(key_hash); + hasher.write_isize(val_hash); + + Ok(hasher.finish() as usize) + }) + .try_fold(0, |acc: usize, x: PyResult| { + PyResult::::Ok(acc ^ hash_shuffle_bits(x?)) + })?; + + // facto in the number of entries in the collection + hash_val ^= (self.inner.size() + 1) * 1927868237; + + // dispense patterns in the hash value + hash_val ^= (hash_val >> 11) ^ (hash_val >> 25); + hash_val = hash_val * 69069 + 907133923; + + Ok(hash_val as isize) + } + fn __reduce__(slf: PyRef) -> (Bound<'_, PyType>, (Vec<(Key, PyObject)>,)) { ( HashTrieMapPy::type_object_bound(slf.py()), diff --git a/tests/test_hash_trie_map.py b/tests/test_hash_trie_map.py index e65b601..717353b 100644 --- a/tests/test_hash_trie_map.py +++ b/tests/test_hash_trie_map.py @@ -154,12 +154,22 @@ def test_overwrite_existing_element(): assert map2["a"] == 3 -@pytest.mark.xfail(reason=HASH_MSG) -def test_hash(): - x = HashTrieMap(a=1, b=2, c=3) - y = HashTrieMap(a=1, b=2, c=3) +def test_hashing(): + o = object() + + assert hash(HashTrieMap([(o, o), (1, o)])) == hash( + HashTrieMap([(o, o), (1, o)]), + ) + assert hash(HashTrieMap([(o, o), (1, o)])) == hash( + HashTrieMap([(1, o), (o, o)]), + ) + assert hash(HashTrieMap([(o, "foo")])) == hash(HashTrieMap([(o, "foo")])) + assert hash(HashTrieMap()) == hash(HashTrieMap([])) - assert hash(x) == hash(y) + assert hash(HashTrieMap({1: 2})) != hash(HashTrieMap({1: 3})) + assert hash(HashTrieMap({o: 1})) != hash(HashTrieMap({o: o})) + assert hash(HashTrieMap([])) != hash(HashTrieMap([(o, 1)])) + assert hash(HashTrieMap({1: 2, 3: 4})) != hash(HashTrieMap({1: 3, 2: 4})) def test_same_hash_when_content_the_same_but_underlying_vector_size_differs(): From 376f3c9395bd022df367a5aea7e6f6a4ec5df607 Mon Sep 17 00:00:00 2001 From: Heyuan Zeng Date: Thu, 11 Jul 2024 02:13:48 +0100 Subject: [PATCH 153/241] Remove hash error handling for elements in HashTrieSet --- src/lib.rs | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index b9b8bfe..00d16fb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -823,26 +823,13 @@ impl HashTrieSetPy { Ok(true) } - fn __hash__(&self, py: Python) -> PyResult { + fn __hash__(&self) -> PyResult { // modified from https://github.com/python/cpython/blob/d69529d31ccd1510843cfac1ab53bb8cb027541f/Objects/setobject.c#L715 let mut hash_val = self .inner .iter() - .map(|k| { - let hash_val = k.inner.bind(py).hash().map_err(|_| { - PyTypeError::new_err(format!( - "Unhashable type in set {}", - k.inner - .bind(py) - .repr() - .map_or(" error".to_string(), |e| { - e.to_str().unwrap().to_string() - }) - )) - })?; - Ok(hash_val as usize) - }) + .map(|k| Ok(k.hash as usize)) .try_fold(0, |acc: usize, x: PyResult| { PyResult::::Ok(acc ^ hash_shuffle_bits(x?)) })?; From 191116e63eeda55fe677b0b7efeccb15f42bf159 Mon Sep 17 00:00:00 2001 From: Heyuan Zeng Date: Thu, 11 Jul 2024 02:17:46 +0100 Subject: [PATCH 154/241] Turn on hashing tests for HashTrieMap --- tests/test_hash_trie_map.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/test_hash_trie_map.py b/tests/test_hash_trie_map.py index 717353b..9e81770 100644 --- a/tests/test_hash_trie_map.py +++ b/tests/test_hash_trie_map.py @@ -35,10 +35,7 @@ from rpds import HashTrieMap -HASH_MSG = "Not sure HashTrieMap implements Hash, it has mutable methods" - -@pytest.mark.xfail(reason=HASH_MSG) def test_instance_of_hashable(): assert isinstance(HashTrieMap(), abc.Hashable) @@ -193,13 +190,17 @@ def __hash__(self): raise ValueError("I am not currently hashable.") -@pytest.mark.xfail(reason=HASH_MSG) def test_map_does_not_hash_values_on_second_hash_invocation(): hashable = HashabilityControlled() x = HashTrieMap(dict(el=hashable)) hash(x) - hashable.hashable = False - hash(x) + + with pytest.raises( + TypeError, + match=r"Unhashable type in HashTrieMap of key 'el'", + ): + hashable.hashable = False + hash(x) def test_equal(): From b29ac7289343329fd15e432def9afe249d9296ee Mon Sep 17 00:00:00 2001 From: Heyuan Zeng Date: Thu, 11 Jul 2024 02:18:33 +0100 Subject: [PATCH 155/241] Fix styling --- tests/test_hash_trie_map.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_hash_trie_map.py b/tests/test_hash_trie_map.py index 9e81770..9f2d763 100644 --- a/tests/test_hash_trie_map.py +++ b/tests/test_hash_trie_map.py @@ -195,11 +195,11 @@ def test_map_does_not_hash_values_on_second_hash_invocation(): x = HashTrieMap(dict(el=hashable)) hash(x) + hashable.hashable = False with pytest.raises( TypeError, match=r"Unhashable type in HashTrieMap of key 'el'", ): - hashable.hashable = False hash(x) From e4316ab05516b03bd6cdb15fbf48ac2e8f315c35 Mon Sep 17 00:00:00 2001 From: Heyuan Zeng Date: Thu, 11 Jul 2024 02:21:20 +0100 Subject: [PATCH 156/241] Fix ruff configuration section --- pyproject.toml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 94b2c2c..26da0de 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -85,6 +85,8 @@ exclude = [ [tool.ruff] line-length = 79 + +[tool.ruff.lint] select = ["ALL"] ignore = [ "A001", # It's fine to shadow builtins @@ -129,17 +131,18 @@ ignore = [ "TD", # These TODO style rules are also silly "UP007", # We support 3.8 + 3.9 ] + [tool.ruff.lint.flake8-pytest-style] mark-parentheses = false -[tool.ruff.flake8-quotes] +[tool.ruff.lint.flake8-quotes] docstring-quotes = "double" [tool.ruff.lint.isort] combine-as-imports = true from-first = true -[tool.ruff.per-file-ignores] +[tool.ruff.lint.per-file-ignores] "noxfile.py" = ["ANN", "D100", "S101", "T201"] "docs/*" = ["ANN", "D", "INP001"] "tests/*" = ["ANN", "B018", "D", "PLR", "RUF012", "S", "SIM", "TRY"] From ad668c5cec159dd9d9aa3cca119a25e96ce74c7e Mon Sep 17 00:00:00 2001 From: Heyuan Zeng Date: Thu, 11 Jul 2024 22:44:02 +0100 Subject: [PATCH 157/241] Better result handling --- src/lib.rs | 38 ++++++++++++++++---------------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 00d16fb..af95126 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -198,12 +198,12 @@ impl HashTrieMapPy { key.inner .bind(py) .repr() - .map_or(" error".to_string(), |e| { - e.to_str().unwrap().to_string() - }), - val_bound.repr().map_or(" error".to_string(), |e| { - e.to_str().unwrap().to_string() - }) + .and_then(|r| r.extract()) + .unwrap_or(" error".to_string()), + val_bound + .repr() + .and_then(|r| r.extract()) + .unwrap_or(" error".to_string()) )) })?; @@ -829,10 +829,8 @@ impl HashTrieSetPy { let mut hash_val = self .inner .iter() - .map(|k| Ok(k.hash as usize)) - .try_fold(0, |acc: usize, x: PyResult| { - PyResult::::Ok(acc ^ hash_shuffle_bits(x?)) - })?; + .map(|k| k.hash as usize) + .fold(0, |acc: usize, x: usize| acc ^ hash_shuffle_bits(x)); // facto in the number of entries in the collection hash_val ^= (self.inner.size() + 1) * 1927868237; @@ -1111,7 +1109,7 @@ impl ListPy { self.inner .iter() .enumerate() - .map(|(index, each)| { + .try_for_each(|(index, each)| { each.bind(py) .hash() .map_err(|_| { @@ -1120,14 +1118,12 @@ impl ListPy { index, each.bind(py) .repr() - .map_or(" error".to_string(), |e| { - e.to_str().unwrap().to_string() - }) + .and_then(|r| r.extract()) + .unwrap_or(" error".to_string()) )) }) .map(|x| hasher.write_isize(x)) - }) - .collect::>>()?; + })?; Ok(hasher.finish()) } @@ -1279,7 +1275,7 @@ impl QueuePy { self.inner .iter() .enumerate() - .map(|(index, each)| { + .try_for_each(|(index, each)| { each.bind(py) .hash() .map_err(|_| { @@ -1288,14 +1284,12 @@ impl QueuePy { index, each.bind(py) .repr() - .map_or(" error".to_string(), |e| { - e.to_str().unwrap().to_string() - }) + .and_then(|r| r.extract()) + .unwrap_or(" error".to_string()) )) }) .map(|x| hasher.write_isize(x)) - }) - .collect::>>()?; + })?; Ok(hasher.finish()) } From 2a639b4bb559edf086b25d10715b2bcd98f99b93 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Jul 2024 18:19:57 +0000 Subject: [PATCH 158/241] Bump pyo3 from 0.22.1 to 0.22.2 Bumps [pyo3](https://github.com/pyo3/pyo3) from 0.22.1 to 0.22.2. - [Release notes](https://github.com/pyo3/pyo3/releases) - [Changelog](https://github.com/PyO3/pyo3/blob/v0.22.2/CHANGELOG.md) - [Commits](https://github.com/pyo3/pyo3/compare/v0.22.1...v0.22.2) --- updated-dependencies: - dependency-name: pyo3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 20 ++++++++++---------- Cargo.toml | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 850fdb6..a868106 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -74,9 +74,9 @@ dependencies = [ [[package]] name = "pyo3" -version = "0.22.1" +version = "0.22.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e99090d12f6182924499253aaa1e73bf15c69cea8d2774c3c781e35badc3548" +checksum = "831e8e819a138c36e212f3af3fd9eeffed6bf1510a805af35b0edee5ffa59433" dependencies = [ "cfg-if", "indoc", @@ -92,9 +92,9 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.22.1" +version = "0.22.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7879eb018ac754bba32cb0eec7526391c02c14a093121857ed09fbf1d1057d41" +checksum = "1e8730e591b14492a8945cdff32f089250b05f5accecf74aeddf9e8272ce1fa8" dependencies = [ "once_cell", "target-lexicon", @@ -102,9 +102,9 @@ dependencies = [ [[package]] name = "pyo3-ffi" -version = "0.22.1" +version = "0.22.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce2baa5559a411fc1cf519295f24c34b53d5d725818bc96b5abf94762da09041" +checksum = "5e97e919d2df92eb88ca80a037969f44e5e70356559654962cbb3316d00300c6" dependencies = [ "libc", "pyo3-build-config", @@ -112,9 +112,9 @@ dependencies = [ [[package]] name = "pyo3-macros" -version = "0.22.1" +version = "0.22.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "049621c20a23f2def20f4fe67978d1da8d8a883d64b9c21362f3b776e254edc7" +checksum = "eb57983022ad41f9e683a599f2fd13c3664d7063a3ac5714cae4b7bee7d3f206" dependencies = [ "proc-macro2", "pyo3-macros-backend", @@ -124,9 +124,9 @@ dependencies = [ [[package]] name = "pyo3-macros-backend" -version = "0.22.1" +version = "0.22.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e969ee2e025435f1819d31a275ba4bb9cbbdf3ac535227fdbd85b9322ffe144" +checksum = "ec480c0c51ddec81019531705acac51bcdbeae563557c982aa8263bb96880372" dependencies = [ "heck", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index 49c4671..6de32d8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,5 +12,5 @@ rpds = "1.1.0" archery = "1.2.0" [dependencies.pyo3] -version = "0.22.1" +version = "0.22.2" features = ["extension-module"] From c581cfe0e5256997e95f3759f590fc55e72bb1f1 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Wed, 24 Jul 2024 09:12:30 -0400 Subject: [PATCH 159/241] Tag a release. --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c5992ac..31cad57 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -171,7 +171,7 @@ dependencies = [ [[package]] name = "rpds-py" -version = "0.19.0" +version = "0.19.1" dependencies = [ "archery", "pyo3", diff --git a/Cargo.toml b/Cargo.toml index 2abc4c6..93a1615 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rpds-py" -version = "0.19.0" +version = "0.19.1" edition = "2021" [lib] From 6707eacf7a6cad38484dd8d7ccdf849b10ec63ee Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 29 Jul 2024 18:09:51 +0000 Subject: [PATCH 160/241] Bump hynek/setup-cached-uv from 1 to 2 Bumps [hynek/setup-cached-uv](https://github.com/hynek/setup-cached-uv) from 1 to 2. - [Release notes](https://github.com/hynek/setup-cached-uv/releases) - [Changelog](https://github.com/hynek/setup-cached-uv/blob/main/CHANGELOG.md) - [Commits](https://github.com/hynek/setup-cached-uv/compare/v1...v2) --- updated-dependencies: - dependency-name: hynek/setup-cached-uv dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 0a5ef17..c589a06 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -60,7 +60,7 @@ jobs: pypy3.10 allow-prereleases: true - name: Set up uv - uses: hynek/setup-cached-uv@v1 + uses: hynek/setup-cached-uv@v2 - name: Set up nox uses: wntrblm/nox@2024.04.15 From 6fd15931eb90edaed216e0d6cd68abac0064fd2d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 5 Aug 2024 23:19:31 +0000 Subject: [PATCH 161/241] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/psf/black: 24.4.2 → 24.8.0](https://github.com/psf/black/compare/24.4.2...24.8.0) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 97473fa..52cf391 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -24,7 +24,7 @@ repos: - id: fmt - id: clippy - repo: https://github.com/psf/black - rev: 24.4.2 + rev: 24.8.0 hooks: - id: black - repo: https://github.com/pre-commit/mirrors-prettier From 75db433513ccb118194a0a4499ed026343390cce Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Tue, 6 Aug 2024 12:48:54 -0400 Subject: [PATCH 162/241] Minor comment typo. --- src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index af95126..3b0cfbd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -216,7 +216,7 @@ impl HashTrieMapPy { PyResult::::Ok(acc ^ hash_shuffle_bits(x?)) })?; - // facto in the number of entries in the collection + // factor in the number of entries in the collection hash_val ^= (self.inner.size() + 1) * 1927868237; // dispense patterns in the hash value @@ -832,7 +832,7 @@ impl HashTrieSetPy { .map(|k| k.hash as usize) .fold(0, |acc: usize, x: usize| acc ^ hash_shuffle_bits(x)); - // facto in the number of entries in the collection + // factor in the number of entries in the collection hash_val ^= (self.inner.size() + 1) * 1927868237; // dispense patterns in the hash value From fac4daa73aacf2df7b4341d51f0c24f5f80aa03d Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Tue, 6 Aug 2024 12:49:36 -0400 Subject: [PATCH 163/241] Tag a release. --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 31cad57..60ae0d4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -171,7 +171,7 @@ dependencies = [ [[package]] name = "rpds-py" -version = "0.19.1" +version = "0.20.0" dependencies = [ "archery", "pyo3", diff --git a/Cargo.toml b/Cargo.toml index 93a1615..128d9f2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rpds-py" -version = "0.19.1" +version = "0.20.0" edition = "2021" [lib] From d8a094cc43f7e16b715b8a2fed4c24a4040197ea Mon Sep 17 00:00:00 2001 From: Heyuan Zeng Date: Thu, 15 Aug 2024 00:13:20 +0200 Subject: [PATCH 164/241] Fix hashing overflow issues --- src/lib.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 3b0cfbd..47499bf 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -10,7 +10,7 @@ use std::collections::hash_map::DefaultHasher; use std::hash::{Hash, Hasher}; fn hash_shuffle_bits(h: usize) -> usize { - ((h ^ 89869747) ^ (h << 16)) * 3644798167 + ((h ^ 89869747) ^ (h << 16)).wrapping_mul(3644798167) } #[derive(Debug)] @@ -217,11 +217,11 @@ impl HashTrieMapPy { })?; // factor in the number of entries in the collection - hash_val ^= (self.inner.size() + 1) * 1927868237; + hash_val ^= self.inner.size().wrapping_add(1).wrapping_mul(1927868237); // dispense patterns in the hash value hash_val ^= (hash_val >> 11) ^ (hash_val >> 25); - hash_val = hash_val * 69069 + 907133923; + hash_val = hash_val.wrapping_mul(69069).wrapping_add(907133923); Ok(hash_val as isize) } @@ -833,11 +833,11 @@ impl HashTrieSetPy { .fold(0, |acc: usize, x: usize| acc ^ hash_shuffle_bits(x)); // factor in the number of entries in the collection - hash_val ^= (self.inner.size() + 1) * 1927868237; + hash_val ^= self.inner.size().wrapping_add(1).wrapping_mul(1927868237); // dispense patterns in the hash value hash_val ^= (hash_val >> 11) ^ (hash_val >> 25); - hash_val = hash_val * 69069 + 907133923; + hash_val = hash_val.wrapping_mul(69069).wrapping_add(907133923); Ok(hash_val as isize) } From d4a827a9fb476451d3496f6e78bca836afc42a67 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 Aug 2024 18:51:23 +0000 Subject: [PATCH 165/241] Bump archery from 1.2.0 to 1.2.1 Bumps [archery](https://github.com/orium/archery) from 1.2.0 to 1.2.1. - [Release notes](https://github.com/orium/archery/releases) - [Changelog](https://github.com/orium/archery/blob/main/release-notes.md) - [Commits](https://github.com/orium/archery/compare/v1.2.0...v1.2.1) --- updated-dependencies: - dependency-name: archery dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 11 ++--------- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 60ae0d4..79feeb4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,11 +4,10 @@ version = 3 [[package]] name = "archery" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8967cd1cc9e9e1954f644e14fbd6042fe9a37da96c52a67e44a2ac18261f8561" +checksum = "eae2ed21cd55021f05707a807a5fc85695dafb98832921f6cfa06db67ca5b869" dependencies = [ - "static_assertions", "triomphe", ] @@ -178,12 +177,6 @@ dependencies = [ "rpds", ] -[[package]] -name = "static_assertions" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" - [[package]] name = "syn" version = "2.0.69" diff --git a/Cargo.toml b/Cargo.toml index 128d9f2..f570ebd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ crate-type = ["cdylib"] [dependencies] rpds = "1.1.0" -archery = "1.2.0" +archery = "1.2.1" [dependencies.pyo3] version = "0.22.2" From 555e90e6dd17e71a03e162581b3349b1d8fda9ea Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Sep 2024 18:05:13 +0000 Subject: [PATCH 166/241] Bump pyo3 from 0.22.2 to 0.22.3 Bumps [pyo3](https://github.com/pyo3/pyo3) from 0.22.2 to 0.22.3. - [Release notes](https://github.com/pyo3/pyo3/releases) - [Changelog](https://github.com/PyO3/pyo3/blob/v0.22.3/CHANGELOG.md) - [Commits](https://github.com/pyo3/pyo3/compare/v0.22.2...v0.22.3) --- updated-dependencies: - dependency-name: pyo3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 20 ++++++++++---------- Cargo.toml | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 79feeb4..370a639 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -79,9 +79,9 @@ dependencies = [ [[package]] name = "pyo3" -version = "0.22.2" +version = "0.22.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "831e8e819a138c36e212f3af3fd9eeffed6bf1510a805af35b0edee5ffa59433" +checksum = "15ee168e30649f7f234c3d49ef5a7a6cbf5134289bc46c29ff3155fa3221c225" dependencies = [ "cfg-if", "indoc", @@ -97,9 +97,9 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.22.2" +version = "0.22.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e8730e591b14492a8945cdff32f089250b05f5accecf74aeddf9e8272ce1fa8" +checksum = "e61cef80755fe9e46bb8a0b8f20752ca7676dcc07a5277d8b7768c6172e529b3" dependencies = [ "once_cell", "python3-dll-a", @@ -108,9 +108,9 @@ dependencies = [ [[package]] name = "pyo3-ffi" -version = "0.22.2" +version = "0.22.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e97e919d2df92eb88ca80a037969f44e5e70356559654962cbb3316d00300c6" +checksum = "67ce096073ec5405f5ee2b8b31f03a68e02aa10d5d4f565eca04acc41931fa1c" dependencies = [ "libc", "pyo3-build-config", @@ -118,9 +118,9 @@ dependencies = [ [[package]] name = "pyo3-macros" -version = "0.22.2" +version = "0.22.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb57983022ad41f9e683a599f2fd13c3664d7063a3ac5714cae4b7bee7d3f206" +checksum = "2440c6d12bc8f3ae39f1e775266fa5122fd0c8891ce7520fa6048e683ad3de28" dependencies = [ "proc-macro2", "pyo3-macros-backend", @@ -130,9 +130,9 @@ dependencies = [ [[package]] name = "pyo3-macros-backend" -version = "0.22.2" +version = "0.22.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec480c0c51ddec81019531705acac51bcdbeae563557c982aa8263bb96880372" +checksum = "1be962f0e06da8f8465729ea2cb71a416d2257dff56cbe40a70d3e62a93ae5d1" dependencies = [ "heck", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index f570ebd..8f4f1ae 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ rpds = "1.1.0" archery = "1.2.1" [dependencies.pyo3] -version = "0.22.2" +version = "0.22.3" # To build extension for PyPy on Windows, "generate-import-lib" is needed: # https://github.com/PyO3/maturin-action/issues/267#issuecomment-2106844429 features = ["extension-module", "generate-import-lib"] From d65f637f63e412973b2279ef645ecd76b3133da2 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 8 Oct 2024 00:47:15 +0000 Subject: [PATCH 167/241] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/pre-commit-hooks: v4.6.0 → v5.0.0](https://github.com/pre-commit/pre-commit-hooks/compare/v4.6.0...v5.0.0) - [github.com/psf/black: 24.8.0 → 24.10.0](https://github.com/psf/black/compare/24.8.0...24.10.0) --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 52cf391..8dcb435 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,7 +6,7 @@ ci: repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v5.0.0 hooks: - id: check-ast - id: check-docstring-first @@ -24,7 +24,7 @@ repos: - id: fmt - id: clippy - repo: https://github.com/psf/black - rev: 24.8.0 + rev: 24.10.0 hooks: - id: black - repo: https://github.com/pre-commit/mirrors-prettier From 85f112972bb2970577d0d457a7ecfbd98175e8d3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Oct 2024 18:04:24 +0000 Subject: [PATCH 168/241] Bump wntrblm/nox from 2024.04.15 to 2024.10.09 Bumps [wntrblm/nox](https://github.com/wntrblm/nox) from 2024.04.15 to 2024.10.09. - [Release notes](https://github.com/wntrblm/nox/releases) - [Changelog](https://github.com/wntrblm/nox/blob/main/CHANGELOG.md) - [Commits](https://github.com/wntrblm/nox/compare/2024.04.15...2024.10.09) --- updated-dependencies: - dependency-name: wntrblm/nox dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- .github/workflows/CI.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index c589a06..69d6d47 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -22,7 +22,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Set up nox - uses: wntrblm/nox@2024.04.15 + uses: wntrblm/nox@2024.10.09 - id: noxenvs-matrix run: | echo >>$GITHUB_OUTPUT noxenvs=$( @@ -62,7 +62,7 @@ jobs: - name: Set up uv uses: hynek/setup-cached-uv@v2 - name: Set up nox - uses: wntrblm/nox@2024.04.15 + uses: wntrblm/nox@2024.10.09 - name: Run nox run: nox -s "${{ matrix.noxenv }}" From f63b5e56cece4c0e80043cecd8632bcf2f7f216e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Oct 2024 18:41:41 +0000 Subject: [PATCH 169/241] Bump pyo3 from 0.22.3 to 0.22.5 Bumps [pyo3](https://github.com/pyo3/pyo3) from 0.22.3 to 0.22.5. - [Release notes](https://github.com/pyo3/pyo3/releases) - [Changelog](https://github.com/PyO3/pyo3/blob/main/CHANGELOG.md) - [Commits](https://github.com/pyo3/pyo3/compare/v0.22.3...v0.22.5) --- updated-dependencies: - dependency-name: pyo3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 20 ++++++++++---------- Cargo.toml | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 370a639..ff29929 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -79,9 +79,9 @@ dependencies = [ [[package]] name = "pyo3" -version = "0.22.3" +version = "0.22.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15ee168e30649f7f234c3d49ef5a7a6cbf5134289bc46c29ff3155fa3221c225" +checksum = "3d922163ba1f79c04bc49073ba7b32fd5a8d3b76a87c955921234b8e77333c51" dependencies = [ "cfg-if", "indoc", @@ -97,9 +97,9 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.22.3" +version = "0.22.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e61cef80755fe9e46bb8a0b8f20752ca7676dcc07a5277d8b7768c6172e529b3" +checksum = "bc38c5feeb496c8321091edf3d63e9a6829eab4b863b4a6a65f26f3e9cc6b179" dependencies = [ "once_cell", "python3-dll-a", @@ -108,9 +108,9 @@ dependencies = [ [[package]] name = "pyo3-ffi" -version = "0.22.3" +version = "0.22.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67ce096073ec5405f5ee2b8b31f03a68e02aa10d5d4f565eca04acc41931fa1c" +checksum = "94845622d88ae274d2729fcefc850e63d7a3ddff5e3ce11bd88486db9f1d357d" dependencies = [ "libc", "pyo3-build-config", @@ -118,9 +118,9 @@ dependencies = [ [[package]] name = "pyo3-macros" -version = "0.22.3" +version = "0.22.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2440c6d12bc8f3ae39f1e775266fa5122fd0c8891ce7520fa6048e683ad3de28" +checksum = "e655aad15e09b94ffdb3ce3d217acf652e26bbc37697ef012f5e5e348c716e5e" dependencies = [ "proc-macro2", "pyo3-macros-backend", @@ -130,9 +130,9 @@ dependencies = [ [[package]] name = "pyo3-macros-backend" -version = "0.22.3" +version = "0.22.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1be962f0e06da8f8465729ea2cb71a416d2257dff56cbe40a70d3e62a93ae5d1" +checksum = "ae1e3f09eecd94618f60a455a23def79f79eba4dc561a97324bf9ac8c6df30ce" dependencies = [ "heck", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index 8f4f1ae..34fd1d7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ rpds = "1.1.0" archery = "1.2.1" [dependencies.pyo3] -version = "0.22.3" +version = "0.22.5" # To build extension for PyPy on Windows, "generate-import-lib" is needed: # https://github.com/PyO3/maturin-action/issues/267#issuecomment-2106844429 features = ["extension-module", "generate-import-lib"] From edc02d68279f3a7e6a569204518e43886639b596 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Thu, 31 Oct 2024 10:03:50 -0400 Subject: [PATCH 170/241] Set --profile=dev in tests to catch issues like #86. --- noxfile.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/noxfile.py b/noxfile.py index 11e1f98..92655fa 100644 --- a/noxfile.py +++ b/noxfile.py @@ -38,7 +38,18 @@ def tests(session): """ Run the test suite with a corresponding Python version. """ - session.install("-r", REQUIREMENTS["tests"]) + # Really we want --profile=test here (for + # https://github.com/crate-py/rpds/pull/87#issuecomment-2291409297) + # but it produces strange symbol errors saying: + # dynamic module does not define module export function (PyInit_rpds) + # so OK, dev it is. + session.install( + "--config-settings", + "build-args=--profile=dev", + "--no-cache", + "-r", + REQUIREMENTS["tests"], + ) if session.posargs and session.posargs[0] == "coverage": if len(session.posargs) > 1 and session.posargs[1] == "github": From 1b5852dca46ad6ebc8ccb65e0610cc2c5d390cd9 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Thu, 31 Oct 2024 10:15:08 -0400 Subject: [PATCH 171/241] Bump to 0.20.1. --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ff29929..9feda02 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -170,7 +170,7 @@ dependencies = [ [[package]] name = "rpds-py" -version = "0.20.0" +version = "0.20.1" dependencies = [ "archery", "pyo3", diff --git a/Cargo.toml b/Cargo.toml index 34fd1d7..5606b4a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rpds-py" -version = "0.20.0" +version = "0.20.1" edition = "2021" [lib] From f949b5bf80c0e516ba5d4a47075bcaf5fb2d4a67 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Thu, 31 Oct 2024 10:19:22 -0400 Subject: [PATCH 172/241] Drop support for 3.8, which is EOL. --- .github/workflows/CI.yml | 14 ++++---------- noxfile.py | 4 ++-- pyproject.toml | 5 ++--- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 69d6d47..20273e4 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -50,7 +50,6 @@ jobs: uses: actions/setup-python@v5 with: python-version: | - 3.8 3.9 3.10 3.11 @@ -78,7 +77,6 @@ jobs: - uses: actions/setup-python@v5 with: python-version: | - 3.8 3.9 3.10 3.11 @@ -91,7 +89,7 @@ jobs: uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} - args: --release --out dist --interpreter '3.8 3.9 3.10 3.11 3.12 3.13 pypy3.9 pypy3.10' + args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13 pypy3.9 pypy3.10' sccache: "true" manylinux: auto - name: Upload wheels @@ -114,7 +112,6 @@ jobs: - uses: actions/setup-python@v5 with: python-version: | - 3.8 3.9 3.10 3.11 @@ -127,7 +124,7 @@ jobs: uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} - args: --release --out dist --interpreter '3.8 3.9 3.10 3.11 3.12 3.13 pypy3.9 pypy3.10' + args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13 pypy3.9 pypy3.10' manylinux: musllinux_1_2 sccache: "true" - name: Upload wheels @@ -147,7 +144,6 @@ jobs: - uses: actions/setup-python@v5 with: python-version: | - 3.8 3.9 3.10 3.11 @@ -161,7 +157,7 @@ jobs: uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} - args: --release --out dist --interpreter '3.8 3.9 3.10 3.11 3.12 3.13' --interpreter ${{ matrix.target == 'x64' && 'pypy3.9 pypy3.10' || '' }} + args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13' --interpreter ${{ matrix.target == 'x64' && 'pypy3.9 pypy3.10' || '' }} sccache: "true" - name: Upload wheels uses: actions/upload-artifact@v4 @@ -180,7 +176,6 @@ jobs: - uses: actions/setup-python@v5 with: python-version: | - 3.8 3.9 3.10 3.11 @@ -193,7 +188,7 @@ jobs: uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} - args: --release --out dist --interpreter '3.8 3.9 3.10 3.11 3.12 3.13 pypy3.9 pypy3.10' + args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13 pypy3.9 pypy3.10' sccache: "true" - name: Upload wheels uses: actions/upload-artifact@v4 @@ -209,7 +204,6 @@ jobs: - uses: actions/setup-python@v5 with: python-version: | - 3.8 3.9 3.10 3.11 diff --git a/noxfile.py b/noxfile.py index 92655fa..c0d707b 100644 --- a/noxfile.py +++ b/noxfile.py @@ -17,8 +17,8 @@ (path.parent / f"{path.stem}.in", path) for path in REQUIREMENTS.values() ] -SUPPORTED = ["3.8", "3.9", "3.10", "pypy3.10", "3.11", "3.12", "3.13"] -LATEST = "3.12" +SUPPORTED = ["3.9", "3.10", "pypy3.10", "3.11", "3.12", "3.13"] +LATEST = "3.13" nox.options.default_venv_backend = "uv|virtualenv" nox.options.sessions = [] diff --git a/pyproject.toml b/pyproject.toml index 87d01a7..a35ca4b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ build-backend = "maturin" [project] name = "rpds-py" description = "Python bindings to Rust's persistent data structures (rpds)" -requires-python = ">=3.8" +requires-python = ">=3.9" readme = "README.rst" license = {text = "MIT"} keywords = ["data structures", "rust", "persistent"] @@ -18,7 +18,6 @@ classifiers = [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Rust", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", @@ -121,7 +120,7 @@ ignore = [ "SIM300", # Not sure what heuristic this uses, but it's easily incorrect "SLF001", # Private usage within this package itself is fine "TD", # These TODO style rules are also silly - "UP007", # We support 3.8 + 3.9 + "UP007", # We support 3.9 ] [tool.ruff.lint.flake8-pytest-style] From de9cf8d770c4ab4b9aa232ace9b3252df22323eb Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Thu, 31 Oct 2024 12:25:55 -0400 Subject: [PATCH 173/241] Update requirements. --- docs/requirements.txt | 40 ++++++++++++++++++---------------------- tests/requirements.txt | 10 +++------- 2 files changed, 21 insertions(+), 29 deletions(-) diff --git a/docs/requirements.txt b/docs/requirements.txt index 75ce514..cad8ef1 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,30 +1,26 @@ -# -# This file is autogenerated by pip-compile with Python 3.12 -# by the following command: -# -# pip-compile --strip-extras docs/requirements.in -# -alabaster==0.7.16 +# This file was autogenerated by uv via the following command: +# uv pip compile --output-file /Users/julian/Development/rpds.py/docs/requirements.txt docs/requirements.in +alabaster==1.0.0 # via sphinx -babel==2.15.0 +babel==2.16.0 # via sphinx beautifulsoup4==4.12.3 # via furo -certifi==2024.7.4 +certifi==2024.8.30 # via requests -charset-normalizer==3.3.2 +charset-normalizer==3.4.0 # via requests docutils==0.21.2 # via sphinx -furo==2024.5.6 +furo==2024.8.6 # via -r docs/requirements.in -idna==3.7 +idna==3.10 # via requests imagesize==1.4.1 # via sphinx jinja2==3.1.4 # via sphinx -markupsafe==2.1.5 +markupsafe==3.0.2 # via jinja2 packaging==24.1 # via sphinx @@ -43,9 +39,9 @@ file:.#egg=rpds-py # via -r docs/requirements.in snowballstemmer==2.2.0 # via sphinx -soupsieve==2.5 +soupsieve==2.6 # via beautifulsoup4 -sphinx==7.3.7 +sphinx==8.1.3 # via # -r docs/requirements.in # furo @@ -57,23 +53,23 @@ sphinx-basic-ng==1.0.0b2 # via furo sphinx-copybutton==0.5.2 # via -r docs/requirements.in -sphinxcontrib-applehelp==1.0.8 +sphinxcontrib-applehelp==2.0.0 # via sphinx -sphinxcontrib-devhelp==1.0.6 +sphinxcontrib-devhelp==2.0.0 # via sphinx -sphinxcontrib-htmlhelp==2.0.5 +sphinxcontrib-htmlhelp==2.1.0 # via sphinx sphinxcontrib-jsmath==1.0.1 # via sphinx -sphinxcontrib-qthelp==1.0.7 +sphinxcontrib-qthelp==2.0.0 # via sphinx -sphinxcontrib-serializinghtml==1.1.10 +sphinxcontrib-serializinghtml==2.0.0 # via sphinx sphinxcontrib-spelling==8.0.0 # via -r docs/requirements.in sphinxext-opengraph==0.9.1 # via -r docs/requirements.in -url-py==0.11.3 +url-py==0.13.0 # via -r docs/requirements.in -urllib3==2.2.2 +urllib3==2.2.3 # via requests diff --git a/tests/requirements.txt b/tests/requirements.txt index a1693cf..325c3ee 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -1,16 +1,12 @@ -# -# This file is autogenerated by pip-compile with Python 3.12 -# by the following command: -# -# pip-compile --strip-extras tests/requirements.in -# +# This file was autogenerated by uv via the following command: +# uv pip compile --output-file /Users/julian/Development/rpds.py/tests/requirements.txt tests/requirements.in iniconfig==2.0.0 # via pytest packaging==24.1 # via pytest pluggy==1.5.0 # via pytest -pytest==8.2.2 +pytest==8.3.3 # via -r tests/requirements.in file:.#egg=rpds-py # via -r tests/requirements.in From c0f173e3f257be85d936559a999bd947639a171b Mon Sep 17 00:00:00 2001 From: Min RK Date: Wed, 6 Nov 2024 09:37:18 +0100 Subject: [PATCH 174/241] bump pyO3 to 0.22.6 causes installation to fail (rightly so) on free-threaded Python, instead of installing a version that segfaults. This was the intended behavior of pyO3 starting with 0.22.2 --- Cargo.lock | 20 ++++++++++---------- Cargo.toml | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9feda02..158f315 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -79,9 +79,9 @@ dependencies = [ [[package]] name = "pyo3" -version = "0.22.5" +version = "0.22.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d922163ba1f79c04bc49073ba7b32fd5a8d3b76a87c955921234b8e77333c51" +checksum = "f402062616ab18202ae8319da13fa4279883a2b8a9d9f83f20dbade813ce1884" dependencies = [ "cfg-if", "indoc", @@ -97,9 +97,9 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.22.5" +version = "0.22.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc38c5feeb496c8321091edf3d63e9a6829eab4b863b4a6a65f26f3e9cc6b179" +checksum = "b14b5775b5ff446dd1056212d778012cbe8a0fbffd368029fd9e25b514479c38" dependencies = [ "once_cell", "python3-dll-a", @@ -108,9 +108,9 @@ dependencies = [ [[package]] name = "pyo3-ffi" -version = "0.22.5" +version = "0.22.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94845622d88ae274d2729fcefc850e63d7a3ddff5e3ce11bd88486db9f1d357d" +checksum = "9ab5bcf04a2cdcbb50c7d6105de943f543f9ed92af55818fd17b660390fc8636" dependencies = [ "libc", "pyo3-build-config", @@ -118,9 +118,9 @@ dependencies = [ [[package]] name = "pyo3-macros" -version = "0.22.5" +version = "0.22.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e655aad15e09b94ffdb3ce3d217acf652e26bbc37697ef012f5e5e348c716e5e" +checksum = "0fd24d897903a9e6d80b968368a34e1525aeb719d568dba8b3d4bfa5dc67d453" dependencies = [ "proc-macro2", "pyo3-macros-backend", @@ -130,9 +130,9 @@ dependencies = [ [[package]] name = "pyo3-macros-backend" -version = "0.22.5" +version = "0.22.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae1e3f09eecd94618f60a455a23def79f79eba4dc561a97324bf9ac8c6df30ce" +checksum = "36c011a03ba1e50152b4b394b479826cad97e7a21eb52df179cd91ac411cbfbe" dependencies = [ "heck", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index 5606b4a..3c13613 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ rpds = "1.1.0" archery = "1.2.1" [dependencies.pyo3] -version = "0.22.5" +version = "0.22.6" # To build extension for PyPy on Windows, "generate-import-lib" is needed: # https://github.com/PyO3/maturin-action/issues/267#issuecomment-2106844429 features = ["extension-module", "generate-import-lib"] From 30de85b475ea1f3e72de83c86eaa2a88b22a58a7 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Tue, 5 Nov 2024 10:59:14 -0500 Subject: [PATCH 175/241] The packaging docs apparently discourage license. They say to just use the classifier. --- .github/workflows/CI.yml | 1 + pyproject.toml | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 20273e4..0ede65e 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -58,6 +58,7 @@ jobs: pypy3.9 pypy3.10 allow-prereleases: true + - name: Set up uv uses: hynek/setup-cached-uv@v2 - name: Set up nox diff --git a/pyproject.toml b/pyproject.toml index a35ca4b..2113e39 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,6 @@ name = "rpds-py" description = "Python bindings to Rust's persistent data structures (rpds)" requires-python = ">=3.9" readme = "README.rst" -license = {text = "MIT"} keywords = ["data structures", "rust", "persistent"] authors = [ { name = "Julian Berman", email = "Julian+rpds@GrayVines.com" }, From da707ab4f460148330a90e9cf656f7cefab4c6f2 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Tue, 5 Nov 2024 10:59:33 -0500 Subject: [PATCH 176/241] Add a link to the upstream repo. --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 2113e39..26c56df 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -35,6 +35,7 @@ Issues = "https://github.com/crate-py/rpds/issues/" Funding = "https://github.com/sponsors/Julian" Tidelift = "https://tidelift.com/subscription/pkg/pypi-rpds-py?utm_source=pypi-rpds-py&utm_medium=referral&utm_campaign=pypi-link" Source = "https://github.com/crate-py/rpds" +Upstream = "https://github.com/orium/rpds" [tool.black] line-length = 79 From 32c53dcabf8d44430a51a5a62ad309d0b2c214d5 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Wed, 6 Nov 2024 08:50:03 -0500 Subject: [PATCH 177/241] Oh hello there zizmor. --- .github/workflows/CI.yml | 14 ++++++++++++++ .github/workflows/zizmor.yml | 34 ++++++++++++++++++++++++++++++++++ .github/zizmor.yml | 5 +++++ .pre-commit-config.yaml | 4 ++++ 4 files changed, 57 insertions(+) create mode 100644 .github/workflows/zizmor.yml create mode 100644 .github/zizmor.yml diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 0ede65e..9060c5c 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -21,6 +21,8 @@ jobs: noxenvs: ${{ steps.noxenvs-matrix.outputs.noxenvs }} steps: - uses: actions/checkout@v4 + with: + persist-credentials: false - name: Set up nox uses: wntrblm/nox@2024.10.09 - id: noxenvs-matrix @@ -40,6 +42,8 @@ jobs: steps: - uses: actions/checkout@v4 + with: + persist-credentials: false - name: Install dependencies run: sudo apt-get update && sudo apt-get install -y libenchant-2-dev if: runner.os == 'Linux' && startsWith(matrix.noxenv, 'docs') @@ -75,6 +79,8 @@ jobs: target: [x86_64, x86, aarch64, armv7, s390x, ppc64le] steps: - uses: actions/checkout@v4 + with: + persist-credentials: false - uses: actions/setup-python@v5 with: python-version: | @@ -110,6 +116,8 @@ jobs: - x86_64-unknown-linux-musl steps: - uses: actions/checkout@v4 + with: + persist-credentials: false - uses: actions/setup-python@v5 with: python-version: | @@ -142,6 +150,8 @@ jobs: target: [x64, x86] # x86 is not supported by pypy steps: - uses: actions/checkout@v4 + with: + persist-credentials: false - uses: actions/setup-python@v5 with: python-version: | @@ -174,6 +184,8 @@ jobs: target: [x86_64, aarch64] steps: - uses: actions/checkout@v4 + with: + persist-credentials: false - uses: actions/setup-python@v5 with: python-version: | @@ -202,6 +214,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + persist-credentials: false - uses: actions/setup-python@v5 with: python-version: | diff --git a/.github/workflows/zizmor.yml b/.github/workflows/zizmor.yml new file mode 100644 index 0000000..bdba878 --- /dev/null +++ b/.github/workflows/zizmor.yml @@ -0,0 +1,34 @@ +name: GitHub Actions Security Analysis with zizmor 🌈 + +on: + push: + branches: ["main"] + pull_request: + branches: ["**"] + +jobs: + zizmor: + runs-on: ubuntu-latest + + permissions: + security-events: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + persist-credentials: false + - name: Setup Rust + uses: actions-rust-lang/setup-rust-toolchain@v1 + - name: Install zizmor + run: cargo install zizmor + - name: Run zizmor 🌈 + run: zizmor --format sarif . > results.sarif + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Upload SARIF file + uses: github/codeql-action/upload-sarif@v3 + with: + sarif_file: results.sarif + category: zizmor diff --git a/.github/zizmor.yml b/.github/zizmor.yml new file mode 100644 index 0000000..a9729df --- /dev/null +++ b/.github/zizmor.yml @@ -0,0 +1,5 @@ +rules: + template-injection: + ignore: + # our matrix is dynamically generated via `nox -l` but with no user input + - CI.yml:71:9 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8dcb435..40200ae 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -31,3 +31,7 @@ repos: rev: "v4.0.0-alpha.8" hooks: - id: prettier + - repo: https://github.com/woodruffw/zizmor + rev: v0.1.6 + hooks: + - id: zizmor From 73581d8dfc56a24eac6ee32c83e6759b4506bb71 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Wed, 6 Nov 2024 08:50:40 -0500 Subject: [PATCH 178/241] Release v0.21.0 --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 158f315..de806d0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -170,7 +170,7 @@ dependencies = [ [[package]] name = "rpds-py" -version = "0.20.1" +version = "0.21.0" dependencies = [ "archery", "pyo3", diff --git a/Cargo.toml b/Cargo.toml index 3c13613..6e20805 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rpds-py" -version = "0.20.1" +version = "0.21.0" edition = "2021" [lib] From ca1f567f62cfe5c947708a615d56e592cd12c9e1 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Wed, 6 Nov 2024 10:27:33 -0500 Subject: [PATCH 179/241] Bump the zizmor version. --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 40200ae..95f5dff 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -32,6 +32,6 @@ repos: hooks: - id: prettier - repo: https://github.com/woodruffw/zizmor - rev: v0.1.6 + rev: v0.2.0 hooks: - id: zizmor From e35ade2d7939b5618f2b42d68e1755abb3fa52df Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 11 Nov 2024 23:10:04 +0000 Subject: [PATCH 180/241] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/woodruffw/zizmor: v0.2.0 → v0.3.0](https://github.com/woodruffw/zizmor/compare/v0.2.0...v0.3.0) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 95f5dff..0518b17 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -32,6 +32,6 @@ repos: hooks: - id: prettier - repo: https://github.com/woodruffw/zizmor - rev: v0.2.0 + rev: v0.3.0 hooks: - id: zizmor From b24f5f663849ef65e8f27448a191fbecda41a9e9 Mon Sep 17 00:00:00 2001 From: Nathan Goldbaum Date: Tue, 12 Nov 2024 15:56:06 -0700 Subject: [PATCH 181/241] update rpds.py for PyO3 0.23 --- src/lib.rs | 254 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 143 insertions(+), 111 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 47499bf..09583f8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,7 +2,7 @@ use pyo3::exceptions::{PyIndexError, PyTypeError}; use pyo3::pyclass::CompareOp; use pyo3::types::{PyDict, PyIterator, PyTuple, PyType}; use pyo3::{exceptions::PyKeyError, types::PyMapping, types::PyTupleMethods}; -use pyo3::{prelude::*, AsPyPointer, PyTypeInfo}; +use pyo3::{prelude::*, AsPyPointer, BoundObject, PyTypeInfo}; use rpds::{ HashTrieMap, HashTrieMapSync, HashTrieSet, HashTrieSetSync, List, ListSync, Queue, QueueSync, }; @@ -19,6 +19,26 @@ struct Key { inner: PyObject, } +impl<'py> IntoPyObject<'py> for Key { + type Target = PyAny; + type Output = Bound<'py, Self::Target>; + type Error = std::convert::Infallible; + + fn into_pyobject(self, py: Python<'py>) -> Result { + Ok(self.inner.into_bound(py)) + } +} + +impl<'a, 'py> IntoPyObject<'py> for &'a Key { + type Target = PyAny; + type Output = Borrowed<'a, 'py, Self::Target>; + type Error = std::convert::Infallible; + + fn into_pyobject(self, py: Python<'py>) -> Result { + Ok(self.inner.bind_borrowed(py)) + } +} + impl Hash for Key { fn hash(&self, state: &mut H) { state.write_isize(self.hash); @@ -47,12 +67,6 @@ impl Key { } } -impl IntoPy for Key { - fn into_py(self, py: Python<'_>) -> PyObject { - self.inner.into_py(py) - } -} - unsafe impl AsPyPointer for Key { fn as_ptr(&self) -> *mut pyo3::ffi::PyObject { self.inner.as_ptr() @@ -84,13 +98,13 @@ impl<'source> FromPyObject<'source> for HashTrieMapPy { fn extract_bound(ob: &Bound<'source, PyAny>) -> PyResult { let mut ret = HashTrieMap::new_sync(); if let Ok(mapping) = ob.downcast::() { - for each in mapping.items()?.iter()? { - let (k, v): (Key, PyObject) = each?.extract()?; + for each in mapping.items()?.iter() { + let (k, v): (Key, PyObject) = each.extract()?; ret.insert_mut(k, v); } } else { - for each in ob.iter()? { - let (k, v): (Key, PyObject) = each?.extract()?; + for each in ob.try_iter()? { + let (k, v) = each?.extract()?; ret.insert_mut(k, v); } } @@ -159,24 +173,30 @@ impl HashTrieMapPy { ) } - fn __richcmp__(&self, other: &Self, op: CompareOp, py: Python<'_>) -> PyResult { + fn __richcmp__<'py>(&self, other: &Self, op: CompareOp, py: Python<'py>) -> PyResult { match op { - CompareOp::Eq => Ok((self.inner.size() == other.inner.size() + CompareOp::Eq => (self.inner.size() == other.inner.size() && self .inner .iter() .map(|(k1, v1)| (v1, other.inner.get(k1))) .map(|(v1, v2)| v1.bind(py).eq(v2)) .all(|r| r.unwrap_or(false))) - .into_py(py)), - CompareOp::Ne => Ok((self.inner.size() != other.inner.size() + .into_pyobject(py) + .map_err(Into::into) + .map(BoundObject::into_any) + .map(BoundObject::unbind), + CompareOp::Ne => (self.inner.size() != other.inner.size() || self .inner .iter() .map(|(k1, v1)| (v1, other.inner.get(k1))) .map(|(v1, v2)| v1.bind(py).ne(v2)) .all(|r| r.unwrap_or(true))) - .into_py(py)), + .into_pyobject(py) + .map_err(Into::into) + .map(BoundObject::into_any) + .map(BoundObject::unbind), _ => Ok(py.NotImplemented()), } } @@ -228,7 +248,7 @@ impl HashTrieMapPy { fn __reduce__(slf: PyRef) -> (Bound<'_, PyType>, (Vec<(Key, PyObject)>,)) { ( - HashTrieMapPy::type_object_bound(slf.py()), + HashTrieMapPy::type_object(slf.py()), (slf.inner .iter() .map(|(k, v)| (k.clone_ref(slf.py()), v.clone_ref(slf.py()))) @@ -245,7 +265,10 @@ impl HashTrieMapPy { if value.is_instance_of::() { Ok(value.unbind()) } else { - Ok(HashTrieMapPy::extract_bound(&value)?.into_py(py)) + HashTrieMapPy::extract_bound(&value)? + .into_pyobject(py) + .map(BoundObject::into_any) + .map(BoundObject::unbind) } } @@ -260,7 +283,7 @@ impl HashTrieMapPy { let mut inner = HashTrieMap::new_sync(); let none = py.None().into_bound(py); let value = val.unwrap_or(&none); - for each in keys.iter()? { + for each in keys.try_iter()? { let key = Key::extract_bound(&each?)?; inner.insert_mut(key, value.clone().unbind()); } @@ -413,11 +436,11 @@ impl KeysView { } fn __eq__(slf: PyRef<'_, Self>, other: &Bound<'_, PyAny>, py: Python) -> PyResult { - let abc = PyModule::import_bound(py, "collections.abc")?; + let abc = PyModule::import(py, "collections.abc")?; if !other.is_instance(&abc.getattr("Set")?)? || other.len()? != slf.inner.size() { return Ok(false); } - for each in other.iter()? { + for each in other.try_iter()? { if !slf.inner.contains_key(&Key::extract_bound(&each?)?) { return Ok(false); } @@ -426,7 +449,7 @@ impl KeysView { } fn __lt__(slf: PyRef<'_, Self>, other: &Bound<'_, PyAny>, py: Python) -> PyResult { - let abc = PyModule::import_bound(py, "collections.abc")?; + let abc = PyModule::import(py, "collections.abc")?; if !other.is_instance(&abc.getattr("Set")?)? || other.len()? <= slf.inner.size() { return Ok(false); } @@ -440,7 +463,7 @@ impl KeysView { } fn __le__(slf: PyRef<'_, Self>, other: &Bound<'_, PyAny>, py: Python) -> PyResult { - let abc = PyModule::import_bound(py, "collections.abc")?; + let abc = PyModule::import(py, "collections.abc")?; if !other.is_instance(&abc.getattr("Set")?)? || other.len()? < slf.inner.size() { return Ok(false); } @@ -454,11 +477,11 @@ impl KeysView { } fn __gt__(slf: PyRef<'_, Self>, other: &Bound<'_, PyAny>, py: Python) -> PyResult { - let abc = PyModule::import_bound(py, "collections.abc")?; + let abc = PyModule::import(py, "collections.abc")?; if !other.is_instance(&abc.getattr("Set")?)? || other.len()? >= slf.inner.size() { return Ok(false); } - for each in other.iter()? { + for each in other.try_iter()? { if !slf.inner.contains_key(&Key::extract_bound(&each?)?) { return Ok(false); } @@ -467,11 +490,11 @@ impl KeysView { } fn __ge__(slf: PyRef<'_, Self>, other: &Bound<'_, PyAny>, py: Python) -> PyResult { - let abc = PyModule::import_bound(py, "collections.abc")?; + let abc = PyModule::import(py, "collections.abc")?; if !other.is_instance(&abc.getattr("Set")?)? || other.len()? > slf.inner.size() { return Ok(false); } - for each in other.iter()? { + for each in other.try_iter()? { if !slf.inner.contains_key(&Key::extract_bound(&each?)?) { return Ok(false); } @@ -497,22 +520,23 @@ impl KeysView { KeysView::union(slf, other, py) } - fn __repr__(&self, py: Python) -> String { + fn __repr__(&self, py: Python) -> PyResult { let contents = self.inner.into_iter().map(|(k, _)| { - k.clone_ref(py) + Ok(k.clone_ref(py) .inner - .into_py(py) - .call_method0(py, "__repr__") - .and_then(|r| r.extract(py)) - .unwrap_or("".to_owned()) + .into_pyobject(py)? + .call_method0("__repr__") + .and_then(|r| r.extract()) + .unwrap_or("".to_owned())) }); - format!("keys_view({{{}}})", contents.collect::>().join(", ")) + let contents = contents.collect::, PyErr>>()?; + Ok(format!("keys_view({{{}}})", contents.join(", "))) } fn intersection(slf: PyRef<'_, Self>, other: &Bound<'_, PyAny>) -> PyResult { // TODO: iterate over the shorter one if it's got a length let mut inner = HashTrieSet::new_sync(); - for each in other.iter()? { + for each in other.try_iter()? { let key = Key::extract_bound(&each?)?; if slf.inner.contains_key(&key) { inner.insert_mut(key); @@ -525,7 +549,7 @@ impl KeysView { // There doesn't seem to be a low-effort way to get a HashTrieSet out of a map, // so we just keep our map and add values we'll ignore. let mut inner = slf.inner.clone(); - for each in other.iter()? { + for each in other.try_iter()? { inner.insert_mut(Key::extract_bound(&each?)?, py.None()); } Ok(KeysView { inner }) @@ -549,14 +573,15 @@ impl ValuesView { slf.inner.size() } - fn __repr__(&self, py: Python) -> String { + fn __repr__(&self, py: Python) -> PyResult { let contents = self.inner.into_iter().map(|(_, v)| { - v.into_py(py) - .call_method0(py, "__repr__") - .and_then(|r| r.extract(py)) - .unwrap_or("".to_owned()) + Ok(v.into_pyobject(py)? + .call_method0("__repr__") + .and_then(|r| r.extract()) + .unwrap_or("".to_owned())) }); - format!("values_view([{}])", contents.collect::>().join(", ")) + let contents = contents.collect::, PyErr>>()?; + Ok(format!("values_view([{}])", contents.join(", "))) } } @@ -589,7 +614,7 @@ impl ItemsView { } fn __eq__(slf: PyRef<'_, Self>, other: &Bound<'_, PyAny>, py: Python) -> PyResult { - let abc = PyModule::import_bound(py, "collections.abc")?; + let abc = PyModule::import(py, "collections.abc")?; if !other.is_instance(&abc.getattr("Set")?)? || other.len()? != slf.inner.size() { return Ok(false); } @@ -601,21 +626,22 @@ impl ItemsView { Ok(true) } - fn __repr__(&self, py: Python) -> String { + fn __repr__(&self, py: Python) -> PyResult { let contents = self.inner.into_iter().map(|(k, v)| { - let tuple = PyTuple::new_bound(py, [k.inner.clone_ref(py), v.clone_ref(py)]); - format!("{:?}", tuple) + let tuple = PyTuple::new(py, [k.inner.clone_ref(py), v.clone_ref(py)])?; + Ok(format!("{:?}", tuple)) }); - format!("items_view([{}])", contents.collect::>().join(", ")) + let contents = contents.collect::, PyErr>>()?; + Ok(format!("items_view([{}])", contents.join(", "))) } fn __lt__(slf: PyRef<'_, Self>, other: &Bound<'_, PyAny>, py: Python) -> PyResult { - let abc = PyModule::import_bound(py, "collections.abc")?; + let abc = PyModule::import(py, "collections.abc")?; if !other.is_instance(&abc.getattr("Set")?)? || other.len()? <= slf.inner.size() { return Ok(false); } for (k, v) in slf.inner.iter() { - let pair = PyTuple::new_bound(py, [k.inner.clone_ref(py), v.clone_ref(py)]); + let pair = PyTuple::new(py, [k.inner.clone_ref(py), v.clone_ref(py)])?; // FIXME: needs to compare if !other.contains(pair)? { return Ok(false); @@ -625,12 +651,12 @@ impl ItemsView { } fn __le__(slf: PyRef<'_, Self>, other: &Bound<'_, PyAny>, py: Python) -> PyResult { - let abc = PyModule::import_bound(py, "collections.abc")?; + let abc = PyModule::import(py, "collections.abc")?; if !other.is_instance(&abc.getattr("Set")?)? || other.len()? < slf.inner.size() { return Ok(false); } for (k, v) in slf.inner.iter() { - let pair = PyTuple::new_bound(py, [k.inner.clone_ref(py), v.clone_ref(py)]); + let pair = PyTuple::new(py, [k.inner.clone_ref(py), v.clone_ref(py)])?; // FIXME: needs to compare if !other.contains(pair)? { return Ok(false); @@ -640,16 +666,16 @@ impl ItemsView { } fn __gt__(slf: PyRef<'_, Self>, other: &Bound<'_, PyAny>, py: Python) -> PyResult { - let abc = PyModule::import_bound(py, "collections.abc")?; + let abc = PyModule::import(py, "collections.abc")?; if !other.is_instance(&abc.getattr("Set")?)? || other.len()? >= slf.inner.size() { return Ok(false); } - for each in other.iter()? { + for each in other.try_iter()? { let kv = each?; let k = kv.get_item(0)?; match slf.inner.get(&Key::extract_bound(&k)?) { Some(value) => { - let pair = PyTuple::new_bound(py, [k, value.bind(py).clone()]); + let pair = PyTuple::new(py, [k, value.bind(py).clone()])?; if !pair.eq(kv)? { return Ok(false); } @@ -661,16 +687,16 @@ impl ItemsView { } fn __ge__(slf: PyRef<'_, Self>, other: &Bound<'_, PyAny>, py: Python) -> PyResult { - let abc = PyModule::import_bound(py, "collections.abc")?; + let abc = PyModule::import(py, "collections.abc")?; if !other.is_instance(&abc.getattr("Set")?)? || other.len()? > slf.inner.size() { return Ok(false); } - for each in other.iter()? { + for each in other.try_iter()? { let kv = each?; let k = kv.get_item(0)?; match slf.inner.get(&Key::extract_bound(&k)?) { Some(value) => { - let pair = PyTuple::new_bound(py, [k, value.bind(py).clone()]); + let pair = PyTuple::new(py, [k, value.bind(py).clone()])?; if !pair.eq(kv)? { return Ok(false); } @@ -704,11 +730,11 @@ impl ItemsView { ) -> PyResult { // TODO: iterate over the shorter one if it's got a length let mut inner = HashTrieSet::new_sync(); - for each in other.iter()? { + for each in other.try_iter()? { let kv = each?; let k = kv.get_item(0)?; if let Some(value) = slf.inner.get(&Key::extract_bound(&k)?) { - let pair = PyTuple::new_bound(py, [k, value.bind(py).clone()]); + let pair = PyTuple::new(py, [k, value.bind(py).clone()])?; if pair.eq(kv)? { inner.insert_mut(Key::extract_bound(&pair)?); } @@ -725,10 +751,10 @@ impl ItemsView { // TODO: this is very inefficient, but again can't seem to get a HashTrieSet out of ourself let mut inner = HashTrieSet::new_sync(); for (k, v) in slf.inner.iter() { - let pair = PyTuple::new_bound(py, [k.inner.clone_ref(py), v.clone_ref(py)]); + let pair = PyTuple::new(py, [k.inner.clone_ref(py), v.clone_ref(py)])?; inner.insert_mut(Key::extract_bound(&pair)?); } - for each in other.iter()? { + for each in other.try_iter()? { inner.insert_mut(Key::extract_bound(&each?)?); } Ok(HashTrieSetPy { inner }) @@ -744,7 +770,7 @@ struct HashTrieSetPy { impl<'source> FromPyObject<'source> for HashTrieSetPy { fn extract_bound(ob: &Bound<'source, PyAny>) -> PyResult { let mut ret = HashTrieSet::new_sync(); - for each in ob.iter()? { + for each in ob.try_iter()? { let k: Key = each?.extract()?; ret.insert_mut(k); } @@ -796,26 +822,24 @@ impl HashTrieSetPy { self.inner.size() } - fn __repr__(&self, py: Python) -> String { + fn __repr__(&self, py: Python) -> PyResult { let contents = self.inner.into_iter().map(|k| { - k.clone_ref(py) - .into_py(py) - .call_method0(py, "__repr__") - .and_then(|r| r.extract(py)) - .unwrap_or("".to_owned()) + Ok(k.clone_ref(py) + .into_pyobject(py)? + .call_method0("__repr__") + .and_then(|r| r.extract()) + .unwrap_or("".to_owned())) }); - format!( - "HashTrieSet({{{}}})", - contents.collect::>().join(", ") - ) + let contents = contents.collect::, PyErr>>()?; + Ok(format!("HashTrieSet({{{}}})", contents.join(", "))) } fn __eq__(slf: PyRef<'_, Self>, other: Bound<'_, PyAny>, py: Python) -> PyResult { - let abc = PyModule::import_bound(py, "collections.abc")?; + let abc = PyModule::import(py, "collections.abc")?; if !other.is_instance(&abc.getattr("Set")?)? || other.len()? != slf.inner.size() { return Ok(false); } - for each in other.iter()? { + for each in other.try_iter()? { if !slf.inner.contains(&Key::extract_bound(&each?)?) { return Ok(false); } @@ -843,7 +867,7 @@ impl HashTrieSetPy { } fn __lt__(slf: PyRef<'_, Self>, other: Bound<'_, PyAny>, py: Python) -> PyResult { - let abc = PyModule::import_bound(py, "collections.abc")?; + let abc = PyModule::import(py, "collections.abc")?; if !other.is_instance(&abc.getattr("Set")?)? || other.len()? <= slf.inner.size() { return Ok(false); } @@ -856,7 +880,7 @@ impl HashTrieSetPy { } fn __le__(slf: PyRef<'_, Self>, other: Bound<'_, PyAny>, py: Python) -> PyResult { - let abc = PyModule::import_bound(py, "collections.abc")?; + let abc = PyModule::import(py, "collections.abc")?; if !other.is_instance(&abc.getattr("Set")?)? || other.len()? < slf.inner.size() { return Ok(false); } @@ -869,11 +893,11 @@ impl HashTrieSetPy { } fn __gt__(slf: PyRef<'_, Self>, other: Bound<'_, PyAny>, py: Python) -> PyResult { - let abc = PyModule::import_bound(py, "collections.abc")?; + let abc = PyModule::import(py, "collections.abc")?; if !other.is_instance(&abc.getattr("Set")?)? || other.len()? >= slf.inner.size() { return Ok(false); } - for each in other.iter()? { + for each in other.try_iter()? { if !slf.inner.contains(&Key::extract_bound(&each?)?) { return Ok(false); } @@ -882,11 +906,11 @@ impl HashTrieSetPy { } fn __ge__(slf: PyRef<'_, Self>, other: Bound<'_, PyAny>, py: Python) -> PyResult { - let abc = PyModule::import_bound(py, "collections.abc")?; + let abc = PyModule::import(py, "collections.abc")?; if !other.is_instance(&abc.getattr("Set")?)? || other.len()? > slf.inner.size() { return Ok(false); } - for each in other.iter()? { + for each in other.try_iter()? { if !slf.inner.contains(&Key::extract_bound(&each?)?) { return Ok(false); } @@ -896,7 +920,7 @@ impl HashTrieSetPy { fn __reduce__(slf: PyRef) -> (Bound<'_, PyType>, (Vec,)) { ( - HashTrieSetPy::type_object_bound(slf.py()), + HashTrieSetPy::type_object(slf.py()), (slf.inner.iter().map(|e| e.clone_ref(slf.py())).collect(),), ) } @@ -994,7 +1018,7 @@ impl HashTrieSetPy { fn update(&self, iterables: Bound<'_, PyTuple>) -> PyResult { let mut inner = self.inner.clone(); for each in iterables { - let iter = each.iter()?; + let iter = each.try_iter()?; for value in iter { inner.insert_mut(Key::extract_bound(&value?)?); } @@ -1036,8 +1060,8 @@ impl From> for ListPy { impl<'source> FromPyObject<'source> for ListPy { fn extract_bound(ob: &Bound<'source, PyAny>) -> PyResult { let mut ret = List::new_sync(); - let reversed = PyModule::import_bound(ob.py(), "builtins")?.getattr("reversed")?; - let rob: Bound<'_, PyIterator> = reversed.call1((ob,))?.iter()?; + let reversed = PyModule::import(ob.py(), "builtins")?.getattr("reversed")?; + let rob: Bound<'_, PyIterator> = reversed.call1((ob,))?.try_iter()?; for each in rob { ret.push_front_mut(each?.extract()?); } @@ -1071,34 +1095,41 @@ impl ListPy { self.inner.len() } - fn __repr__(&self, py: Python) -> String { + fn __repr__(&self, py: Python) -> PyResult { let contents = self.inner.into_iter().map(|k| { - k.into_py(py) - .call_method0(py, "__repr__") - .and_then(|r| r.extract(py)) - .unwrap_or("".to_owned()) + Ok(k.into_pyobject(py)? + .call_method0("__repr__") + .and_then(|r| r.extract()) + .unwrap_or("".to_owned())) }); - format!("List([{}])", contents.collect::>().join(", ")) + let contents = contents.collect::, PyErr>>()?; + Ok(format!("List([{}])", contents.join(", "))) } fn __richcmp__(&self, other: &Self, op: CompareOp, py: Python<'_>) -> PyResult { match op { - CompareOp::Eq => Ok((self.inner.len() == other.inner.len() + CompareOp::Eq => (self.inner.len() == other.inner.len() && self .inner .iter() .zip(other.inner.iter()) .map(|(e1, e2)| e1.bind(py).eq(e2)) .all(|r| r.unwrap_or(false))) - .into_py(py)), - CompareOp::Ne => Ok((self.inner.len() != other.inner.len() + .into_pyobject(py) + .map_err(Into::into) + .map(BoundObject::into_any) + .map(BoundObject::unbind), + CompareOp::Ne => (self.inner.len() != other.inner.len() || self .inner .iter() .zip(other.inner.iter()) .map(|(e1, e2)| e1.bind(py).ne(e2)) .any(|r| r.unwrap_or(true))) - .into_py(py)), + .into_pyobject(py) + .map_err(Into::into) + .map(BoundObject::into_any) + .map(BoundObject::unbind), _ => Ok(py.NotImplemented()), } } @@ -1142,7 +1173,7 @@ impl ListPy { fn __reduce__(slf: PyRef) -> (Bound<'_, PyType>, (Vec,)) { ( - ListPy::type_object_bound(slf.py()), + ListPy::type_object(slf.py()), (slf.inner.iter().map(|e| e.clone_ref(slf.py())).collect(),), ) } @@ -1231,7 +1262,7 @@ impl From> for QueuePy { impl<'source> FromPyObject<'source> for QueuePy { fn extract_bound(ob: &Bound<'source, PyAny>) -> PyResult { let mut ret = Queue::new_sync(); - for each in ob.iter()? { + for each in ob.try_iter()? { ret.enqueue_mut(each?.extract()?); } Ok(QueuePy { inner: ret }) @@ -1252,7 +1283,7 @@ impl QueuePy { }; if elements.len() > 1 { for each in elements { - ret.inner.enqueue_mut(each.into_py(py)); + ret.inner.enqueue_mut(each.into_pyobject(py)?.unbind()); } } } @@ -1314,14 +1345,15 @@ impl QueuePy { self.inner.len() } - fn __repr__(&self, py: Python) -> String { + fn __repr__(&self, py: Python) -> PyResult { let contents = self.inner.into_iter().map(|k| { - k.into_py(py) - .call_method0(py, "__repr__") - .and_then(|r| r.extract(py)) - .unwrap_or("".to_owned()) + Ok(k.into_pyobject(py)? + .call_method0("__repr__") + .and_then(|r| r.extract()) + .unwrap_or("".to_owned())) }); - format!("Queue([{}])", contents.collect::>().join(", ")) + let contents = contents.collect::, PyErr>>()?; + Ok(format!("Queue([{}])", contents.join(", "))) } #[getter] @@ -1363,24 +1395,24 @@ fn rpds_py(py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> { PyMapping::register::(py)?; - let abc = PyModule::import_bound(py, "collections.abc")?; + let abc = PyModule::import(py, "collections.abc")?; abc.getattr("Set")? - .call_method1("register", (HashTrieSetPy::type_object_bound(py),))?; + .call_method1("register", (HashTrieSetPy::type_object(py),))?; abc.getattr("MappingView")? - .call_method1("register", (KeysView::type_object_bound(py),))?; + .call_method1("register", (KeysView::type_object(py),))?; abc.getattr("MappingView")? - .call_method1("register", (ValuesView::type_object_bound(py),))?; + .call_method1("register", (ValuesView::type_object(py),))?; abc.getattr("MappingView")? - .call_method1("register", (ItemsView::type_object_bound(py),))?; + .call_method1("register", (ItemsView::type_object(py),))?; abc.getattr("KeysView")? - .call_method1("register", (KeysView::type_object_bound(py),))?; + .call_method1("register", (KeysView::type_object(py),))?; abc.getattr("ValuesView")? - .call_method1("register", (ValuesView::type_object_bound(py),))?; + .call_method1("register", (ValuesView::type_object(py),))?; abc.getattr("ItemsView")? - .call_method1("register", (ItemsView::type_object_bound(py),))?; + .call_method1("register", (ItemsView::type_object(py),))?; Ok(()) } From fb37e4b47fc36c3c6c3ac5a8da1f5f03315987e3 Mon Sep 17 00:00:00 2001 From: Nathan Goldbaum Date: Fri, 15 Nov 2024 14:07:10 -0700 Subject: [PATCH 182/241] point Cargo.toml at pyo3 0.23 on crates.io --- Cargo.lock | 20 ++++++++++---------- Cargo.toml | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index de806d0..d965979 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -79,9 +79,9 @@ dependencies = [ [[package]] name = "pyo3" -version = "0.22.6" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f402062616ab18202ae8319da13fa4279883a2b8a9d9f83f20dbade813ce1884" +checksum = "d51da03e17ef97ae4185cd606a4b316e04bb6f047d66913d6b57d4e6acfb41ec" dependencies = [ "cfg-if", "indoc", @@ -97,9 +97,9 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.22.6" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b14b5775b5ff446dd1056212d778012cbe8a0fbffd368029fd9e25b514479c38" +checksum = "455f646b3d007fb6d85cffccff9c7dfb752f24ec9fb0a04cb49537e7e9bdc2dd" dependencies = [ "once_cell", "python3-dll-a", @@ -108,9 +108,9 @@ dependencies = [ [[package]] name = "pyo3-ffi" -version = "0.22.6" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ab5bcf04a2cdcbb50c7d6105de943f543f9ed92af55818fd17b660390fc8636" +checksum = "432fc20d4dd419f8d1dd402a659bb42e75430706b50d367cc978978778638084" dependencies = [ "libc", "pyo3-build-config", @@ -118,9 +118,9 @@ dependencies = [ [[package]] name = "pyo3-macros" -version = "0.22.6" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fd24d897903a9e6d80b968368a34e1525aeb719d568dba8b3d4bfa5dc67d453" +checksum = "ae1cd532e9356f90d1be1317d8bf51873e4a9468b9305b950c20e8aef786cc16" dependencies = [ "proc-macro2", "pyo3-macros-backend", @@ -130,9 +130,9 @@ dependencies = [ [[package]] name = "pyo3-macros-backend" -version = "0.22.6" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36c011a03ba1e50152b4b394b479826cad97e7a21eb52df179cd91ac411cbfbe" +checksum = "975b289b3d3901442a6def73eedf8251dc1aed2cdc0a80d1c4f3998d868a97aa" dependencies = [ "heck", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index 6e20805..d7589a1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ rpds = "1.1.0" archery = "1.2.1" [dependencies.pyo3] -version = "0.22.6" +version = "0.23.0" # To build extension for PyPy on Windows, "generate-import-lib" is needed: # https://github.com/PyO3/maturin-action/issues/267#issuecomment-2106844429 features = ["extension-module", "generate-import-lib"] From ec3c8992db79347938d313cadf8725f67c11e605 Mon Sep 17 00:00:00 2001 From: Nathan Goldbaum Date: Fri, 15 Nov 2024 14:09:05 -0700 Subject: [PATCH 183/241] add 3.13t to CI config --- .github/workflows/CI.yml | 3 ++- noxfile.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 9060c5c..fde2efc 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -51,7 +51,7 @@ jobs: run: brew install enchant if: runner.os == 'macOS' && startsWith(matrix.noxenv, 'docs') - name: Set up Python - uses: actions/setup-python@v5 + uses: quansight-labs/setup-python@v5 with: python-version: | 3.9 @@ -59,6 +59,7 @@ jobs: 3.11 3.12 3.13 + 3.13t pypy3.9 pypy3.10 allow-prereleases: true diff --git a/noxfile.py b/noxfile.py index c0d707b..0a708de 100644 --- a/noxfile.py +++ b/noxfile.py @@ -17,7 +17,7 @@ (path.parent / f"{path.stem}.in", path) for path in REQUIREMENTS.values() ] -SUPPORTED = ["3.9", "3.10", "pypy3.10", "3.11", "3.12", "3.13"] +SUPPORTED = ["3.9", "3.10", "pypy3.10", "3.11", "3.12", "3.13", "3.13t"] LATEST = "3.13" nox.options.default_venv_backend = "uv|virtualenv" From 82d457997078c5967f69d7c5d96505ad82a52190 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Mon, 18 Nov 2024 12:03:50 -0500 Subject: [PATCH 184/241] Skip zizmor in pre-commit.ci as well. --- .pre-commit-config.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0518b17..4cf504f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,6 +3,7 @@ ci: # pre-commit.ci doesn't have Rust installed - fmt - clippy + - zizmor repos: - repo: https://github.com/pre-commit/pre-commit-hooks From 7653271a4ac82c502526f47c891076b098fbb98d Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Mon, 18 Nov 2024 12:04:02 -0500 Subject: [PATCH 185/241] Build on all branches. --- .github/workflows/CI.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index fde2efc..895b48c 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -2,13 +2,11 @@ name: CI on: push: - branches: - - main + branches-ignore: + - "wip*" tags: - "v[0-9].*" pull_request: - release: - types: [published] schedule: # Daily at 5:33 - cron: "33 5 * * *" From 10480d135ed050e802348080ab972e00e830dd21 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Nov 2024 18:38:39 +0000 Subject: [PATCH 186/241] Bump pyo3 from 0.23.0 to 0.23.1 Bumps [pyo3](https://github.com/pyo3/pyo3) from 0.23.0 to 0.23.1. - [Release notes](https://github.com/pyo3/pyo3/releases) - [Changelog](https://github.com/PyO3/pyo3/blob/main/CHANGELOG.md) - [Commits](https://github.com/pyo3/pyo3/compare/v0.23.0...v0.23.1) --- updated-dependencies: - dependency-name: pyo3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 20 ++++++++++---------- Cargo.toml | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d965979..a69648d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -79,9 +79,9 @@ dependencies = [ [[package]] name = "pyo3" -version = "0.23.0" +version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d51da03e17ef97ae4185cd606a4b316e04bb6f047d66913d6b57d4e6acfb41ec" +checksum = "7ebb0c0cc0de9678e53be9ccf8a2ab53045e6e3a8be03393ceccc5e7396ccb40" dependencies = [ "cfg-if", "indoc", @@ -97,9 +97,9 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.23.0" +version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "455f646b3d007fb6d85cffccff9c7dfb752f24ec9fb0a04cb49537e7e9bdc2dd" +checksum = "80e3ce69c4ec34476534b490e412b871ba03a82e35604c3dfb95fcb6bfb60c09" dependencies = [ "once_cell", "python3-dll-a", @@ -108,9 +108,9 @@ dependencies = [ [[package]] name = "pyo3-ffi" -version = "0.23.0" +version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "432fc20d4dd419f8d1dd402a659bb42e75430706b50d367cc978978778638084" +checksum = "3b09f311c76b36dfd6dd6f7fa6f9f18e7e46a1c937110d283e80b12ba2468a75" dependencies = [ "libc", "pyo3-build-config", @@ -118,9 +118,9 @@ dependencies = [ [[package]] name = "pyo3-macros" -version = "0.23.0" +version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae1cd532e9356f90d1be1317d8bf51873e4a9468b9305b950c20e8aef786cc16" +checksum = "fd4f74086536d1e1deaff99ec0387481fb3325c82e4e48be0e75ab3d3fcb487a" dependencies = [ "proc-macro2", "pyo3-macros-backend", @@ -130,9 +130,9 @@ dependencies = [ [[package]] name = "pyo3-macros-backend" -version = "0.23.0" +version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "975b289b3d3901442a6def73eedf8251dc1aed2cdc0a80d1c4f3998d868a97aa" +checksum = "9e77dfeb76b32bbf069144a5ea0a36176ab59c8db9ce28732d0f06f096bbfbc8" dependencies = [ "heck", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index d7589a1..a6b2562 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ rpds = "1.1.0" archery = "1.2.1" [dependencies.pyo3] -version = "0.23.0" +version = "0.23.1" # To build extension for PyPy on Windows, "generate-import-lib" is needed: # https://github.com/PyO3/maturin-action/issues/267#issuecomment-2106844429 features = ["extension-module", "generate-import-lib"] From 3712da1a262734f12a1cceeed40d4a7315b4a4eb Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 18 Nov 2024 23:13:50 +0000 Subject: [PATCH 187/241] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/woodruffw/zizmor: v0.3.0 → v0.4.0](https://github.com/woodruffw/zizmor/compare/v0.3.0...v0.4.0) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4cf504f..a7eeda2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -33,6 +33,6 @@ repos: hooks: - id: prettier - repo: https://github.com/woodruffw/zizmor - rev: v0.3.0 + rev: v0.4.0 hooks: - id: zizmor From 563ecdf3f097a1add976d900ccc14440aae822f7 Mon Sep 17 00:00:00 2001 From: Nathan Goldbaum Date: Tue, 19 Nov 2024 14:55:56 -0700 Subject: [PATCH 188/241] declare support for free-threading --- .github/workflows/CI.yml | 30 +++++++++++++----------------- noxfile.py | 2 +- src/lib.rs | 2 +- tests/requirements.in | 1 + tests/requirements.txt | 6 +++++- 5 files changed, 21 insertions(+), 20 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 895b48c..5a7f65a 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -80,7 +80,7 @@ jobs: - uses: actions/checkout@v4 with: persist-credentials: false - - uses: actions/setup-python@v5 + - uses: quansight-labs/setup-python@v5 with: python-version: | 3.9 @@ -88,6 +88,7 @@ jobs: 3.11 3.12 3.13 + 3.13t pypy3.9 pypy3.10 allow-prereleases: true @@ -95,7 +96,7 @@ jobs: uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} - args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13 pypy3.9 pypy3.10' + args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13 3.13t pypy3.9 pypy3.10' sccache: "true" manylinux: auto - name: Upload wheels @@ -117,7 +118,7 @@ jobs: - uses: actions/checkout@v4 with: persist-credentials: false - - uses: actions/setup-python@v5 + - uses: quansight-labs/setup-python@v5 with: python-version: | 3.9 @@ -125,6 +126,7 @@ jobs: 3.11 3.12 3.13 + 3.13t pypy3.9 pypy3.10 allow-prereleases: true @@ -132,7 +134,7 @@ jobs: uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} - args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13 pypy3.9 pypy3.10' + args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13 3.13t pypy3.9 pypy3.10' manylinux: musllinux_1_2 sccache: "true" - name: Upload wheels @@ -151,7 +153,7 @@ jobs: - uses: actions/checkout@v4 with: persist-credentials: false - - uses: actions/setup-python@v5 + - uses: quansight-labs/setup-python@v5 with: python-version: | 3.9 @@ -159,6 +161,7 @@ jobs: 3.11 3.12 3.13 + 3.13t ${{ matrix.target == 'x64' && 'pypy3.9' || '' }} ${{ matrix.target == 'x64' && 'pypy3.10' || '' }} allow-prereleases: true @@ -167,7 +170,7 @@ jobs: uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} - args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13' --interpreter ${{ matrix.target == 'x64' && 'pypy3.9 pypy3.10' || '' }} + args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13 3.13t' --interpreter ${{ matrix.target == 'x64' && 'pypy3.9 pypy3.10' || '' }} sccache: "true" - name: Upload wheels uses: actions/upload-artifact@v4 @@ -185,7 +188,7 @@ jobs: - uses: actions/checkout@v4 with: persist-credentials: false - - uses: actions/setup-python@v5 + - uses: quansight-labs/setup-python@v5 with: python-version: | 3.9 @@ -193,6 +196,7 @@ jobs: 3.11 3.12 3.13 + 3.13t pypy3.9 pypy3.10 allow-prereleases: true @@ -200,7 +204,7 @@ jobs: uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} - args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13 pypy3.9 pypy3.10' + args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13 3.13t pypy3.9 pypy3.10' sccache: "true" - name: Upload wheels uses: actions/upload-artifact@v4 @@ -217,15 +221,7 @@ jobs: persist-credentials: false - uses: actions/setup-python@v5 with: - python-version: | - 3.9 - 3.10 - 3.11 - 3.12 - 3.13 - pypy3.9 - pypy3.10 - allow-prereleases: true + python-version: 3.13 - name: Build an sdist uses: PyO3/maturin-action@v1 with: diff --git a/noxfile.py b/noxfile.py index 0a708de..0ec7240 100644 --- a/noxfile.py +++ b/noxfile.py @@ -72,7 +72,7 @@ def tests(session): stdout=summary, ) else: - session.run("pytest", *session.posargs, TESTS) + session.run("pytest", "--parallel-threads=10", *session.posargs, TESTS) @session() diff --git a/src/lib.rs b/src/lib.rs index 09583f8..c95c40a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1385,7 +1385,7 @@ impl QueuePy { } } -#[pymodule] +#[pymodule(gil_used = false)] #[pyo3(name = "rpds")] fn rpds_py(py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> { m.add_class::()?; diff --git a/tests/requirements.in b/tests/requirements.in index 1c3a2db..425a283 100644 --- a/tests/requirements.in +++ b/tests/requirements.in @@ -1,2 +1,3 @@ file:.#egg=rpds-py pytest +pytest-run-parallel \ No newline at end of file diff --git a/tests/requirements.txt b/tests/requirements.txt index 325c3ee..0a7421a 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -1,5 +1,5 @@ # This file was autogenerated by uv via the following command: -# uv pip compile --output-file /Users/julian/Development/rpds.py/tests/requirements.txt tests/requirements.in +# uv pip compile --output-file tests/requirements.txt tests/requirements.in iniconfig==2.0.0 # via pytest packaging==24.1 @@ -7,6 +7,10 @@ packaging==24.1 pluggy==1.5.0 # via pytest pytest==8.3.3 + # via + # -r tests/requirements.in + # pytest-run-parallel +pytest-run-parallel==0.2.0 # via -r tests/requirements.in file:.#egg=rpds-py # via -r tests/requirements.in From db5c80d37d263bd06457ed76f325f71cb39a1bc4 Mon Sep 17 00:00:00 2001 From: Nathan Goldbaum Date: Wed, 20 Nov 2024 13:18:43 -0700 Subject: [PATCH 189/241] work around CPython issue 127065 --- tests/test_hash_trie_map.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/test_hash_trie_map.py b/tests/test_hash_trie_map.py index 9f2d763..3544305 100644 --- a/tests/test_hash_trie_map.py +++ b/tests/test_hash_trie_map.py @@ -30,11 +30,20 @@ from collections import abc from operator import methodcaller import pickle +import sysconfig import pytest from rpds import HashTrieMap +# see https://github.com/python/cpython/issues/127065, +# remove this when the CPython bug is fixed in a released version +if bool(sysconfig.get_config_var("Py_GIL_DISABLED")): + def methodcaller(name, /, *args, **kwargs): + def caller(obj): + return getattr(obj, name)(*args, **kwargs) + return caller + def test_instance_of_hashable(): assert isinstance(HashTrieMap(), abc.Hashable) From 42b39551578e46153b3738f49aa0a9ac089e1656 Mon Sep 17 00:00:00 2001 From: Nathan Goldbaum Date: Wed, 20 Nov 2024 13:40:58 -0700 Subject: [PATCH 190/241] revert changes to wheel-building config --- .github/workflows/CI.yml | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 5a7f65a..895b48c 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -80,7 +80,7 @@ jobs: - uses: actions/checkout@v4 with: persist-credentials: false - - uses: quansight-labs/setup-python@v5 + - uses: actions/setup-python@v5 with: python-version: | 3.9 @@ -88,7 +88,6 @@ jobs: 3.11 3.12 3.13 - 3.13t pypy3.9 pypy3.10 allow-prereleases: true @@ -96,7 +95,7 @@ jobs: uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} - args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13 3.13t pypy3.9 pypy3.10' + args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13 pypy3.9 pypy3.10' sccache: "true" manylinux: auto - name: Upload wheels @@ -118,7 +117,7 @@ jobs: - uses: actions/checkout@v4 with: persist-credentials: false - - uses: quansight-labs/setup-python@v5 + - uses: actions/setup-python@v5 with: python-version: | 3.9 @@ -126,7 +125,6 @@ jobs: 3.11 3.12 3.13 - 3.13t pypy3.9 pypy3.10 allow-prereleases: true @@ -134,7 +132,7 @@ jobs: uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} - args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13 3.13t pypy3.9 pypy3.10' + args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13 pypy3.9 pypy3.10' manylinux: musllinux_1_2 sccache: "true" - name: Upload wheels @@ -153,7 +151,7 @@ jobs: - uses: actions/checkout@v4 with: persist-credentials: false - - uses: quansight-labs/setup-python@v5 + - uses: actions/setup-python@v5 with: python-version: | 3.9 @@ -161,7 +159,6 @@ jobs: 3.11 3.12 3.13 - 3.13t ${{ matrix.target == 'x64' && 'pypy3.9' || '' }} ${{ matrix.target == 'x64' && 'pypy3.10' || '' }} allow-prereleases: true @@ -170,7 +167,7 @@ jobs: uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} - args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13 3.13t' --interpreter ${{ matrix.target == 'x64' && 'pypy3.9 pypy3.10' || '' }} + args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13' --interpreter ${{ matrix.target == 'x64' && 'pypy3.9 pypy3.10' || '' }} sccache: "true" - name: Upload wheels uses: actions/upload-artifact@v4 @@ -188,7 +185,7 @@ jobs: - uses: actions/checkout@v4 with: persist-credentials: false - - uses: quansight-labs/setup-python@v5 + - uses: actions/setup-python@v5 with: python-version: | 3.9 @@ -196,7 +193,6 @@ jobs: 3.11 3.12 3.13 - 3.13t pypy3.9 pypy3.10 allow-prereleases: true @@ -204,7 +200,7 @@ jobs: uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} - args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13 3.13t pypy3.9 pypy3.10' + args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13 pypy3.9 pypy3.10' sccache: "true" - name: Upload wheels uses: actions/upload-artifact@v4 @@ -221,7 +217,15 @@ jobs: persist-credentials: false - uses: actions/setup-python@v5 with: - python-version: 3.13 + python-version: | + 3.9 + 3.10 + 3.11 + 3.12 + 3.13 + pypy3.9 + pypy3.10 + allow-prereleases: true - name: Build an sdist uses: PyO3/maturin-action@v1 with: From 76f1cfcfe64a87fa21dfbcce12027c71482adcc1 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 20 Nov 2024 20:43:41 +0000 Subject: [PATCH 191/241] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/requirements.in | 2 +- tests/test_hash_trie_map.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/requirements.in b/tests/requirements.in index 425a283..8dc90bd 100644 --- a/tests/requirements.in +++ b/tests/requirements.in @@ -1,3 +1,3 @@ file:.#egg=rpds-py pytest -pytest-run-parallel \ No newline at end of file +pytest-run-parallel diff --git a/tests/test_hash_trie_map.py b/tests/test_hash_trie_map.py index 3544305..3dec414 100644 --- a/tests/test_hash_trie_map.py +++ b/tests/test_hash_trie_map.py @@ -39,9 +39,11 @@ # see https://github.com/python/cpython/issues/127065, # remove this when the CPython bug is fixed in a released version if bool(sysconfig.get_config_var("Py_GIL_DISABLED")): + def methodcaller(name, /, *args, **kwargs): def caller(obj): return getattr(obj, name)(*args, **kwargs) + return caller From b03c790b61a199b470b87b3e029e12d9f4bfdfeb Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 25 Nov 2024 23:06:45 +0000 Subject: [PATCH 192/241] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/woodruffw/zizmor: v0.4.0 → v0.5.0](https://github.com/woodruffw/zizmor/compare/v0.4.0...v0.5.0) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a7eeda2..da205b6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -33,6 +33,6 @@ repos: hooks: - id: prettier - repo: https://github.com/woodruffw/zizmor - rev: v0.4.0 + rev: v0.5.0 hooks: - id: zizmor From 344c4894d209197c6167cc4c87a09ecee836bbb2 Mon Sep 17 00:00:00 2001 From: Nathan Goldbaum Date: Tue, 26 Nov 2024 14:32:52 -0700 Subject: [PATCH 193/241] Enable free-threaded wheel builds This reverts commit 42b39551578e46153b3738f49aa0a9ac089e1656. --- .github/workflows/CI.yml | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 895b48c..5a7f65a 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -80,7 +80,7 @@ jobs: - uses: actions/checkout@v4 with: persist-credentials: false - - uses: actions/setup-python@v5 + - uses: quansight-labs/setup-python@v5 with: python-version: | 3.9 @@ -88,6 +88,7 @@ jobs: 3.11 3.12 3.13 + 3.13t pypy3.9 pypy3.10 allow-prereleases: true @@ -95,7 +96,7 @@ jobs: uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} - args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13 pypy3.9 pypy3.10' + args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13 3.13t pypy3.9 pypy3.10' sccache: "true" manylinux: auto - name: Upload wheels @@ -117,7 +118,7 @@ jobs: - uses: actions/checkout@v4 with: persist-credentials: false - - uses: actions/setup-python@v5 + - uses: quansight-labs/setup-python@v5 with: python-version: | 3.9 @@ -125,6 +126,7 @@ jobs: 3.11 3.12 3.13 + 3.13t pypy3.9 pypy3.10 allow-prereleases: true @@ -132,7 +134,7 @@ jobs: uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} - args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13 pypy3.9 pypy3.10' + args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13 3.13t pypy3.9 pypy3.10' manylinux: musllinux_1_2 sccache: "true" - name: Upload wheels @@ -151,7 +153,7 @@ jobs: - uses: actions/checkout@v4 with: persist-credentials: false - - uses: actions/setup-python@v5 + - uses: quansight-labs/setup-python@v5 with: python-version: | 3.9 @@ -159,6 +161,7 @@ jobs: 3.11 3.12 3.13 + 3.13t ${{ matrix.target == 'x64' && 'pypy3.9' || '' }} ${{ matrix.target == 'x64' && 'pypy3.10' || '' }} allow-prereleases: true @@ -167,7 +170,7 @@ jobs: uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} - args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13' --interpreter ${{ matrix.target == 'x64' && 'pypy3.9 pypy3.10' || '' }} + args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13 3.13t' --interpreter ${{ matrix.target == 'x64' && 'pypy3.9 pypy3.10' || '' }} sccache: "true" - name: Upload wheels uses: actions/upload-artifact@v4 @@ -185,7 +188,7 @@ jobs: - uses: actions/checkout@v4 with: persist-credentials: false - - uses: actions/setup-python@v5 + - uses: quansight-labs/setup-python@v5 with: python-version: | 3.9 @@ -193,6 +196,7 @@ jobs: 3.11 3.12 3.13 + 3.13t pypy3.9 pypy3.10 allow-prereleases: true @@ -200,7 +204,7 @@ jobs: uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} - args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13 pypy3.9 pypy3.10' + args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13 3.13t pypy3.9 pypy3.10' sccache: "true" - name: Upload wheels uses: actions/upload-artifact@v4 @@ -217,15 +221,7 @@ jobs: persist-credentials: false - uses: actions/setup-python@v5 with: - python-version: | - 3.9 - 3.10 - 3.11 - 3.12 - 3.13 - pypy3.9 - pypy3.10 - allow-prereleases: true + python-version: 3.13 - name: Build an sdist uses: PyO3/maturin-action@v1 with: From 72244696bc3b12935f47a5a15045ba48f05ff22b Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Mon, 2 Dec 2024 13:16:55 -0500 Subject: [PATCH 194/241] Bump to 0.22.0 for a free-threading-supported beta release. --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a69648d..3435dcb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "archery" @@ -170,7 +170,7 @@ dependencies = [ [[package]] name = "rpds-py" -version = "0.21.0" +version = "0.22.0" dependencies = [ "archery", "pyo3", diff --git a/Cargo.toml b/Cargo.toml index a6b2562..5ab74f6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rpds-py" -version = "0.21.0" +version = "0.22.0" edition = "2021" [lib] From 6043127a214561fc3dfe64cc114d6bd9ec3fa06b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 2 Dec 2024 18:48:36 +0000 Subject: [PATCH 195/241] Bump pyo3 from 0.23.1 to 0.23.2 Bumps [pyo3](https://github.com/pyo3/pyo3) from 0.23.1 to 0.23.2. - [Release notes](https://github.com/pyo3/pyo3/releases) - [Changelog](https://github.com/PyO3/pyo3/blob/main/CHANGELOG.md) - [Commits](https://github.com/pyo3/pyo3/compare/v0.23.1...v0.23.2) --- updated-dependencies: - dependency-name: pyo3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 20 ++++++++++---------- Cargo.toml | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3435dcb..2be409e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -79,9 +79,9 @@ dependencies = [ [[package]] name = "pyo3" -version = "0.23.1" +version = "0.23.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ebb0c0cc0de9678e53be9ccf8a2ab53045e6e3a8be03393ceccc5e7396ccb40" +checksum = "f54b3d09cbdd1f8c20650b28e7b09e338881482f4aa908a5f61a00c98fba2690" dependencies = [ "cfg-if", "indoc", @@ -97,9 +97,9 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.23.1" +version = "0.23.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80e3ce69c4ec34476534b490e412b871ba03a82e35604c3dfb95fcb6bfb60c09" +checksum = "3015cf985888fe66cfb63ce0e321c603706cd541b7aec7ddd35c281390af45d8" dependencies = [ "once_cell", "python3-dll-a", @@ -108,9 +108,9 @@ dependencies = [ [[package]] name = "pyo3-ffi" -version = "0.23.1" +version = "0.23.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b09f311c76b36dfd6dd6f7fa6f9f18e7e46a1c937110d283e80b12ba2468a75" +checksum = "6fca7cd8fd809b5ac4eefb89c1f98f7a7651d3739dfb341ca6980090f554c270" dependencies = [ "libc", "pyo3-build-config", @@ -118,9 +118,9 @@ dependencies = [ [[package]] name = "pyo3-macros" -version = "0.23.1" +version = "0.23.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd4f74086536d1e1deaff99ec0387481fb3325c82e4e48be0e75ab3d3fcb487a" +checksum = "34e657fa5379a79151b6ff5328d9216a84f55dc93b17b08e7c3609a969b73aa0" dependencies = [ "proc-macro2", "pyo3-macros-backend", @@ -130,9 +130,9 @@ dependencies = [ [[package]] name = "pyo3-macros-backend" -version = "0.23.1" +version = "0.23.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e77dfeb76b32bbf069144a5ea0a36176ab59c8db9ce28732d0f06f096bbfbc8" +checksum = "295548d5ffd95fd1981d2d3cf4458831b21d60af046b729b6fd143b0ba7aee2f" dependencies = [ "heck", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index 5ab74f6..38e5151 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ rpds = "1.1.0" archery = "1.2.1" [dependencies.pyo3] -version = "0.23.1" +version = "0.23.2" # To build extension for PyPy on Windows, "generate-import-lib" is needed: # https://github.com/PyO3/maturin-action/issues/267#issuecomment-2106844429 features = ["extension-module", "generate-import-lib"] From 5f169738b5d0d1d21aad4f35ae8e128117507c71 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 2 Dec 2024 23:43:53 +0000 Subject: [PATCH 196/241] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/woodruffw/zizmor: v0.5.0 → v0.6.0](https://github.com/woodruffw/zizmor/compare/v0.5.0...v0.6.0) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index da205b6..152c646 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -33,6 +33,6 @@ repos: hooks: - id: prettier - repo: https://github.com/woodruffw/zizmor - rev: v0.5.0 + rev: v0.6.0 hooks: - id: zizmor From 7f99ea8cd88bc6698a93b30702b751bd27698374 Mon Sep 17 00:00:00 2001 From: Roberto Pastor Muela <37798125+RobPasMue@users.noreply.github.com> Date: Tue, 3 Dec 2024 09:22:27 +0100 Subject: [PATCH 197/241] ci: separate free-threaded and standard 3.13 distribution builds --- .github/workflows/CI.yml | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 5a7f65a..b0e5dc6 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -161,7 +161,6 @@ jobs: 3.11 3.12 3.13 - 3.13t ${{ matrix.target == 'x64' && 'pypy3.9' || '' }} ${{ matrix.target == 'x64' && 'pypy3.10' || '' }} allow-prereleases: true @@ -170,7 +169,7 @@ jobs: uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} - args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13 3.13t' --interpreter ${{ matrix.target == 'x64' && 'pypy3.9 pypy3.10' || '' }} + args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13' --interpreter ${{ matrix.target == 'x64' && 'pypy3.9 pypy3.10' || '' }} sccache: "true" - name: Upload wheels uses: actions/upload-artifact@v4 @@ -178,6 +177,33 @@ jobs: name: dist-${{ github.job }}-${{ matrix.target }} path: dist + windows-free-threaded: + needs: test + runs-on: windows-latest + strategy: + matrix: + target: [x64, x86] # x86 is not supported by pypy + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + - uses: quansight-labs/setup-python@v5 + with: + python-version: 3.13t + allow-prereleases: true + architecture: ${{ matrix.target }} + - name: Build wheels + uses: PyO3/maturin-action@v1 + with: + target: ${{ matrix.target }} + args: --release --out dist --interpreter '3.13t' + sccache: "true" + - name: Upload wheels + uses: actions/upload-artifact@v4 + with: + name: dist-${{ github.job }}-${{ matrix.target }}-free-threaded + path: dist + macos: needs: test runs-on: macos-latest @@ -234,7 +260,7 @@ jobs: path: dist release: - needs: [manylinux, musllinux, windows, macos] + needs: [manylinux, musllinux, windows, windows-free-threaded, macos] runs-on: ubuntu-latest if: "startsWith(github.ref, 'refs/tags/')" environment: From 5ecc066c2b3a4b5a03d8ba4b5734a15af74d4607 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Tue, 3 Dec 2024 11:16:54 -0500 Subject: [PATCH 198/241] Tag a release for regaining all the Windows wheels. --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2be409e..6f7ca52 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -170,7 +170,7 @@ dependencies = [ [[package]] name = "rpds-py" -version = "0.22.0" +version = "0.22.1" dependencies = [ "archery", "pyo3", diff --git a/Cargo.toml b/Cargo.toml index 38e5151..b818a09 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rpds-py" -version = "0.22.0" +version = "0.22.1" edition = "2021" [lib] From 177b17b6462753a8f645edb0bce90752cb2ca721 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Wed, 4 Dec 2024 10:00:39 -0500 Subject: [PATCH 199/241] Bump to PyO3 0.23.3, avoiding 0.23.x's previous soundness issues. Previous builds were corrupt when done with multiple interpreters at the same time (meaning while sharing cross-build state). This resolves segfaults seen with the latest rpds.py release, which we will yank, following PyO3 itself (which is yanking these versions). We should also generally reconsider doing these builds separately (using separate jobs for each interpreter). Closes: #112 Refs: PyO3/pyo3#4757 Refs: rustsec/advisory-db#2159 --- Cargo.lock | 24 ++++++++++++------------ Cargo.toml | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6f7ca52..46be002 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -79,9 +79,9 @@ dependencies = [ [[package]] name = "pyo3" -version = "0.23.2" +version = "0.23.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f54b3d09cbdd1f8c20650b28e7b09e338881482f4aa908a5f61a00c98fba2690" +checksum = "e484fd2c8b4cb67ab05a318f1fd6fa8f199fcc30819f08f07d200809dba26c15" dependencies = [ "cfg-if", "indoc", @@ -97,9 +97,9 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.23.2" +version = "0.23.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3015cf985888fe66cfb63ce0e321c603706cd541b7aec7ddd35c281390af45d8" +checksum = "dc0e0469a84f208e20044b98965e1561028180219e35352a2afaf2b942beff3b" dependencies = [ "once_cell", "python3-dll-a", @@ -108,9 +108,9 @@ dependencies = [ [[package]] name = "pyo3-ffi" -version = "0.23.2" +version = "0.23.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fca7cd8fd809b5ac4eefb89c1f98f7a7651d3739dfb341ca6980090f554c270" +checksum = "eb1547a7f9966f6f1a0f0227564a9945fe36b90da5a93b3933fc3dc03fae372d" dependencies = [ "libc", "pyo3-build-config", @@ -118,9 +118,9 @@ dependencies = [ [[package]] name = "pyo3-macros" -version = "0.23.2" +version = "0.23.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34e657fa5379a79151b6ff5328d9216a84f55dc93b17b08e7c3609a969b73aa0" +checksum = "fdb6da8ec6fa5cedd1626c886fc8749bdcbb09424a86461eb8cdf096b7c33257" dependencies = [ "proc-macro2", "pyo3-macros-backend", @@ -130,9 +130,9 @@ dependencies = [ [[package]] name = "pyo3-macros-backend" -version = "0.23.2" +version = "0.23.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "295548d5ffd95fd1981d2d3cf4458831b21d60af046b729b6fd143b0ba7aee2f" +checksum = "38a385202ff5a92791168b1136afae5059d3ac118457bb7bc304c197c2d33e7d" dependencies = [ "heck", "proc-macro2", @@ -143,9 +143,9 @@ dependencies = [ [[package]] name = "python3-dll-a" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd0b78171a90d808b319acfad166c4790d9e9759bbc14ac8273fe133673dd41b" +checksum = "9b9e268ee1be609e93a13eb06839f68f67e5fe0fb4049834d261c2d5091c1b6d" dependencies = [ "cc", ] diff --git a/Cargo.toml b/Cargo.toml index b818a09..7357a15 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ rpds = "1.1.0" archery = "1.2.1" [dependencies.pyo3] -version = "0.23.2" +version = "0.23.3" # To build extension for PyPy on Windows, "generate-import-lib" is needed: # https://github.com/PyO3/maturin-action/issues/267#issuecomment-2106844429 features = ["extension-module", "generate-import-lib"] From ada6b46cb9836fb25e57e6450eb16f4af9080009 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Wed, 4 Dec 2024 10:20:49 -0500 Subject: [PATCH 200/241] Properly tag a release fixing the soundness issue. --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 46be002..2ad0d95 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -170,7 +170,7 @@ dependencies = [ [[package]] name = "rpds-py" -version = "0.22.1" +version = "0.22.3" dependencies = [ "archery", "pyo3", diff --git a/Cargo.toml b/Cargo.toml index 7357a15..081662d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rpds-py" -version = "0.22.1" +version = "0.22.3" edition = "2021" [lib] From 351d781b3e4da26fe0c05157664d633ea72db594 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 9 Dec 2024 23:15:31 +0000 Subject: [PATCH 201/241] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/woodruffw/zizmor: v0.6.0 → v0.8.0](https://github.com/woodruffw/zizmor/compare/v0.6.0...v0.8.0) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 152c646..949a268 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -33,6 +33,6 @@ repos: hooks: - id: prettier - repo: https://github.com/woodruffw/zizmor - rev: v0.6.0 + rev: v0.8.0 hooks: - id: zizmor From 086a3f9366eb94ecac862be6b6dc7df08193c892 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Jan 2025 18:32:03 +0000 Subject: [PATCH 202/241] Bump pyo3 from 0.23.3 to 0.23.4 Bumps [pyo3](https://github.com/pyo3/pyo3) from 0.23.3 to 0.23.4. - [Release notes](https://github.com/pyo3/pyo3/releases) - [Changelog](https://github.com/PyO3/pyo3/blob/v0.23.4/CHANGELOG.md) - [Commits](https://github.com/pyo3/pyo3/compare/v0.23.3...v0.23.4) --- updated-dependencies: - dependency-name: pyo3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 24 ++++++++++++------------ Cargo.toml | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2ad0d95..a4130e8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -79,9 +79,9 @@ dependencies = [ [[package]] name = "pyo3" -version = "0.23.3" +version = "0.23.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e484fd2c8b4cb67ab05a318f1fd6fa8f199fcc30819f08f07d200809dba26c15" +checksum = "57fe09249128b3173d092de9523eaa75136bf7ba85e0d69eca241c7939c933cc" dependencies = [ "cfg-if", "indoc", @@ -97,9 +97,9 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.23.3" +version = "0.23.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc0e0469a84f208e20044b98965e1561028180219e35352a2afaf2b942beff3b" +checksum = "1cd3927b5a78757a0d71aa9dff669f903b1eb64b54142a9bd9f757f8fde65fd7" dependencies = [ "once_cell", "python3-dll-a", @@ -108,9 +108,9 @@ dependencies = [ [[package]] name = "pyo3-ffi" -version = "0.23.3" +version = "0.23.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb1547a7f9966f6f1a0f0227564a9945fe36b90da5a93b3933fc3dc03fae372d" +checksum = "dab6bb2102bd8f991e7749f130a70d05dd557613e39ed2deeee8e9ca0c4d548d" dependencies = [ "libc", "pyo3-build-config", @@ -118,9 +118,9 @@ dependencies = [ [[package]] name = "pyo3-macros" -version = "0.23.3" +version = "0.23.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdb6da8ec6fa5cedd1626c886fc8749bdcbb09424a86461eb8cdf096b7c33257" +checksum = "91871864b353fd5ffcb3f91f2f703a22a9797c91b9ab497b1acac7b07ae509c7" dependencies = [ "proc-macro2", "pyo3-macros-backend", @@ -130,9 +130,9 @@ dependencies = [ [[package]] name = "pyo3-macros-backend" -version = "0.23.3" +version = "0.23.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38a385202ff5a92791168b1136afae5059d3ac118457bb7bc304c197c2d33e7d" +checksum = "43abc3b80bc20f3facd86cd3c60beed58c3e2aa26213f3cda368de39c60a27e4" dependencies = [ "heck", "proc-macro2", @@ -143,9 +143,9 @@ dependencies = [ [[package]] name = "python3-dll-a" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b9e268ee1be609e93a13eb06839f68f67e5fe0fb4049834d261c2d5091c1b6d" +checksum = "9b66f9171950e674e64bad3456e11bb3cca108e5c34844383cfe277f45c8a7a8" dependencies = [ "cc", ] diff --git a/Cargo.toml b/Cargo.toml index 081662d..9c7c27e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ rpds = "1.1.0" archery = "1.2.1" [dependencies.pyo3] -version = "0.23.3" +version = "0.23.4" # To build extension for PyPy on Windows, "generate-import-lib" is needed: # https://github.com/PyO3/maturin-action/issues/267#issuecomment-2106844429 features = ["extension-module", "generate-import-lib"] From 54e9eb6f6315a3e67f3f56c7d2b429704f8074c5 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 4 Feb 2025 00:14:18 +0000 Subject: [PATCH 203/241] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/psf/black: 24.10.0 → 25.1.0](https://github.com/psf/black/compare/24.10.0...25.1.0) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 949a268..70a87a4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -25,7 +25,7 @@ repos: - id: fmt - id: clippy - repo: https://github.com/psf/black - rev: 24.10.0 + rev: 25.1.0 hooks: - id: black - repo: https://github.com/pre-commit/mirrors-prettier From 9b85b8ce40dd0b285587057d8e800a472947fb76 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Mon, 17 Feb 2025 10:40:40 -0500 Subject: [PATCH 204/241] Run nox via uvx. --- .github/workflows/CI.yml | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index b0e5dc6..ff97271 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -21,12 +21,11 @@ jobs: - uses: actions/checkout@v4 with: persist-credentials: false - - name: Set up nox - uses: wntrblm/nox@2024.10.09 + - uses: astral-sh/setup-uv@v5 - id: noxenvs-matrix run: | echo >>$GITHUB_OUTPUT noxenvs=$( - nox --list-sessions --json | jq '[.[].session]' + uvx nox --list-sessions --json | jq '[.[].session]' ) test: @@ -62,13 +61,9 @@ jobs: pypy3.10 allow-prereleases: true - - name: Set up uv - uses: hynek/setup-cached-uv@v2 - - name: Set up nox - uses: wntrblm/nox@2024.10.09 - + - uses: astral-sh/setup-uv@v5 - name: Run nox - run: nox -s "${{ matrix.noxenv }}" + run: uvx nox -s "${{ matrix.noxenv }}" -- ${{ matrix.posargs }} # zizmor: ignore[template-injection] manylinux: needs: test From 9785b76cfc96fa11ef6af303201feba69d9c9a7f Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Mon, 17 Feb 2025 10:48:10 -0500 Subject: [PATCH 205/241] Disable caching for release builds as per zizmor recommendation. 'https://woodruffw.github.io/zizmor/audits/#cache-poisoning --- .github/workflows/CI.yml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index ff97271..8fc0603 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -22,6 +22,8 @@ jobs: with: persist-credentials: false - uses: astral-sh/setup-uv@v5 + with: + enable-cache: ${{ github.ref_type != 'tag' }} # zizmor: ignore[cache-poisoning] - id: noxenvs-matrix run: | echo >>$GITHUB_OUTPUT noxenvs=$( @@ -62,6 +64,8 @@ jobs: allow-prereleases: true - uses: astral-sh/setup-uv@v5 + with: + enable-cache: ${{ github.ref_type != 'tag' }} # zizmor: ignore[cache-poisoning] - name: Run nox run: uvx nox -s "${{ matrix.noxenv }}" -- ${{ matrix.posargs }} # zizmor: ignore[template-injection] @@ -92,7 +96,7 @@ jobs: with: target: ${{ matrix.target }} args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13 3.13t pypy3.9 pypy3.10' - sccache: "true" + sccache: ${{ github.ref_type != 'tag' }} # zizmor: ignore[cache-poisoning] manylinux: auto - name: Upload wheels uses: actions/upload-artifact@v4 @@ -131,7 +135,7 @@ jobs: target: ${{ matrix.target }} args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13 3.13t pypy3.9 pypy3.10' manylinux: musllinux_1_2 - sccache: "true" + sccache: ${{ github.ref_type != 'tag' }} # zizmor: ignore[cache-poisoning] - name: Upload wheels uses: actions/upload-artifact@v4 with: @@ -165,7 +169,7 @@ jobs: with: target: ${{ matrix.target }} args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13' --interpreter ${{ matrix.target == 'x64' && 'pypy3.9 pypy3.10' || '' }} - sccache: "true" + sccache: ${{ github.ref_type != 'tag' }} # zizmor: ignore[cache-poisoning] - name: Upload wheels uses: actions/upload-artifact@v4 with: @@ -192,7 +196,7 @@ jobs: with: target: ${{ matrix.target }} args: --release --out dist --interpreter '3.13t' - sccache: "true" + sccache: ${{ github.ref_type != 'tag' }} # zizmor: ignore[cache-poisoning] - name: Upload wheels uses: actions/upload-artifact@v4 with: @@ -226,7 +230,7 @@ jobs: with: target: ${{ matrix.target }} args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13 3.13t pypy3.9 pypy3.10' - sccache: "true" + sccache: ${{ github.ref_type != 'tag' }} # zizmor: ignore[cache-poisoning] - name: Upload wheels uses: actions/upload-artifact@v4 with: From 9c07fe61af35db7a70384792ad1be382b15d389a Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Mon, 17 Feb 2025 10:53:19 -0500 Subject: [PATCH 206/241] Also limit permissions globally. https://woodruffw.github.io/zizmor/audits/#excessive-permissions --- .github/workflows/CI.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 8fc0603..85dd45a 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -12,6 +12,8 @@ on: - cron: "33 5 * * *" workflow_dispatch: +permissions: {} + jobs: list: runs-on: ubuntu-latest From 6f6ba8db6426ede8a11e769d1433628bd4b8d5c4 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Mon, 17 Feb 2025 10:54:00 -0500 Subject: [PATCH 207/241] Update requirements. --- docs/requirements.txt | 28 ++++++++++++++++------------ tests/requirements.txt | 10 +++++----- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/docs/requirements.txt b/docs/requirements.txt index cad8ef1..7a4ba2a 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -2,13 +2,13 @@ # uv pip compile --output-file /Users/julian/Development/rpds.py/docs/requirements.txt docs/requirements.in alabaster==1.0.0 # via sphinx -babel==2.16.0 +babel==2.17.0 # via sphinx -beautifulsoup4==4.12.3 +beautifulsoup4==4.13.3 # via furo -certifi==2024.8.30 +certifi==2025.1.31 # via requests -charset-normalizer==3.4.0 +charset-normalizer==3.4.1 # via requests docutils==0.21.2 # via sphinx @@ -18,15 +18,15 @@ idna==3.10 # via requests imagesize==1.4.1 # via sphinx -jinja2==3.1.4 +jinja2==3.1.5 # via sphinx markupsafe==3.0.2 # via jinja2 -packaging==24.1 +packaging==24.2 # via sphinx pyenchant==3.2.2 # via sphinxcontrib-spelling -pygments==2.18.0 +pygments==2.19.1 # via # furo # pygments-github-lexers @@ -34,8 +34,10 @@ pygments==2.18.0 pygments-github-lexers==0.0.5 # via -r docs/requirements.in requests==2.32.3 - # via sphinx -file:.#egg=rpds-py + # via + # sphinx + # sphinxcontrib-spelling +rpds-py @ file:.#egg=rpds-py # via -r docs/requirements.in snowballstemmer==2.2.0 # via sphinx @@ -65,11 +67,13 @@ sphinxcontrib-qthelp==2.0.0 # via sphinx sphinxcontrib-serializinghtml==2.0.0 # via sphinx -sphinxcontrib-spelling==8.0.0 +sphinxcontrib-spelling==8.0.1 # via -r docs/requirements.in sphinxext-opengraph==0.9.1 # via -r docs/requirements.in -url-py==0.13.0 +typing-extensions==4.12.2 + # via beautifulsoup4 +url-py==0.14.1 # via -r docs/requirements.in -urllib3==2.2.3 +urllib3==2.3.0 # via requests diff --git a/tests/requirements.txt b/tests/requirements.txt index 0a7421a..81a3c0d 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -1,16 +1,16 @@ # This file was autogenerated by uv via the following command: -# uv pip compile --output-file tests/requirements.txt tests/requirements.in +# uv pip compile --output-file /Users/julian/Development/rpds.py/tests/requirements.txt tests/requirements.in iniconfig==2.0.0 # via pytest -packaging==24.1 +packaging==24.2 # via pytest pluggy==1.5.0 # via pytest -pytest==8.3.3 +pytest==8.3.4 # via # -r tests/requirements.in # pytest-run-parallel -pytest-run-parallel==0.2.0 +pytest-run-parallel==0.3.1 # via -r tests/requirements.in -file:.#egg=rpds-py +rpds-py @ file:.#egg=rpds-py # via -r tests/requirements.in From a1454cc3626c81566189a8ae58968a432054bf87 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Thu, 20 Feb 2025 11:54:27 -0500 Subject: [PATCH 208/241] Declare license via (the accepted) PEP 639. The License field is deprecated, as is the trove classifier. Note that pip show does not support properly detecting these yet, but it will. Refs: https://peps.python.org/pep-0639/ Refs: pypa/pip#13112 Refs: pypa/pip#6677 --- pyproject.toml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 26c56df..f399294 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,6 +7,8 @@ name = "rpds-py" description = "Python bindings to Rust's persistent data structures (rpds)" requires-python = ">=3.9" readme = "README.rst" +license = "MIT" +license-files = ["COPYING"] keywords = ["data structures", "rust", "persistent"] authors = [ { name = "Julian Berman", email = "Julian+rpds@GrayVines.com" }, @@ -14,7 +16,6 @@ authors = [ classifiers = [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", - "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Rust", "Programming Language :: Python :: 3.9", @@ -59,8 +60,8 @@ skip_covered = true [tool.doc8] ignore = [ - "D000", # see PyCQA/doc8#125 - "D001", # one sentence per line, so max length doesn't make sense + "D000", # see PyCQA/doc8#125 + "D001", # one sentence per line, so max length doesn't make sense ] [tool.maturin] @@ -83,6 +84,7 @@ ignore = [ "A001", # It's fine to shadow builtins "A002", "A003", + "A005", "ARG", # This is all wrong whenever an interface is involved "ANN", # Just let the type checker do this "B006", # Mutable arguments require care but are OK if you don't abuse them From 5403f5a31c18ac6581bba5a400099d8fdaf2b8af Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Thu, 20 Feb 2025 11:56:05 -0500 Subject: [PATCH 209/241] Tag v0.23.0 for release. Closes: #118 --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a4130e8..7a6be4d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -170,7 +170,7 @@ dependencies = [ [[package]] name = "rpds-py" -version = "0.22.3" +version = "0.23.0" dependencies = [ "archery", "pyo3", diff --git a/Cargo.toml b/Cargo.toml index 9c7c27e..791cefb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rpds-py" -version = "0.22.3" +version = "0.23.0" edition = "2021" [lib] From d2cfa4c99b29e3947574da165acc2f9a55851f1d Mon Sep 17 00:00:00 2001 From: Nicholas Bollweg Date: Fri, 21 Feb 2025 08:34:11 -0600 Subject: [PATCH 210/241] update license file --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index f399294..a995f55 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ description = "Python bindings to Rust's persistent data structures (rpds)" requires-python = ">=3.9" readme = "README.rst" license = "MIT" -license-files = ["COPYING"] +license-files = ["LICENSE"] keywords = ["data structures", "rust", "persistent"] authors = [ { name = "Julian Berman", email = "Julian+rpds@GrayVines.com" }, From b59fa1e871b86b5fcbc321a6e4cb7791793fc510 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Fri, 21 Feb 2025 09:50:11 -0500 Subject: [PATCH 211/241] v0.23.1 to fix the license file naming. --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7a6be4d..4c10e63 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -170,7 +170,7 @@ dependencies = [ [[package]] name = "rpds-py" -version = "0.23.0" +version = "0.23.1" dependencies = [ "archery", "pyo3", diff --git a/Cargo.toml b/Cargo.toml index 791cefb..234cc20 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rpds-py" -version = "0.23.0" +version = "0.23.1" edition = "2021" [lib] From e0894a3923f7f49ddeab4868827a225d138e606a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Mar 2025 18:37:09 +0000 Subject: [PATCH 212/241] Bump pyo3 from 0.23.4 to 0.24.0 Bumps [pyo3](https://github.com/pyo3/pyo3) from 0.23.4 to 0.24.0. - [Release notes](https://github.com/pyo3/pyo3/releases) - [Changelog](https://github.com/PyO3/pyo3/blob/main/CHANGELOG.md) - [Commits](https://github.com/pyo3/pyo3/compare/v0.23.4...v0.24.0) --- updated-dependencies: - dependency-name: pyo3 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Cargo.lock | 24 ++++++++++++------------ Cargo.toml | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4c10e63..6b75db9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -79,9 +79,9 @@ dependencies = [ [[package]] name = "pyo3" -version = "0.23.4" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57fe09249128b3173d092de9523eaa75136bf7ba85e0d69eca241c7939c933cc" +checksum = "7f1c6c3591120564d64db2261bec5f910ae454f01def849b9c22835a84695e86" dependencies = [ "cfg-if", "indoc", @@ -97,9 +97,9 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.23.4" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cd3927b5a78757a0d71aa9dff669f903b1eb64b54142a9bd9f757f8fde65fd7" +checksum = "e9b6c2b34cf71427ea37c7001aefbaeb85886a074795e35f161f5aecc7620a7a" dependencies = [ "once_cell", "python3-dll-a", @@ -108,9 +108,9 @@ dependencies = [ [[package]] name = "pyo3-ffi" -version = "0.23.4" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dab6bb2102bd8f991e7749f130a70d05dd557613e39ed2deeee8e9ca0c4d548d" +checksum = "5507651906a46432cdda02cd02dd0319f6064f1374c9147c45b978621d2c3a9c" dependencies = [ "libc", "pyo3-build-config", @@ -118,9 +118,9 @@ dependencies = [ [[package]] name = "pyo3-macros" -version = "0.23.4" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91871864b353fd5ffcb3f91f2f703a22a9797c91b9ab497b1acac7b07ae509c7" +checksum = "b0d394b5b4fd8d97d48336bb0dd2aebabad39f1d294edd6bcd2cccf2eefe6f42" dependencies = [ "proc-macro2", "pyo3-macros-backend", @@ -130,9 +130,9 @@ dependencies = [ [[package]] name = "pyo3-macros-backend" -version = "0.23.4" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43abc3b80bc20f3facd86cd3c60beed58c3e2aa26213f3cda368de39c60a27e4" +checksum = "fd72da09cfa943b1080f621f024d2ef7e2773df7badd51aa30a2be1f8caa7c8e" dependencies = [ "heck", "proc-macro2", @@ -190,9 +190,9 @@ dependencies = [ [[package]] name = "target-lexicon" -version = "0.12.14" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1fc403891a21bcfb7c37834ba66a547a8f402146eba7265b5a6d88059c9ff2f" +checksum = "e502f78cdbb8ba4718f566c418c52bc729126ffd16baee5baa718cf25dd5a69a" [[package]] name = "triomphe" diff --git a/Cargo.toml b/Cargo.toml index 234cc20..2f220e7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ rpds = "1.1.0" archery = "1.2.1" [dependencies.pyo3] -version = "0.23.4" +version = "0.24.0" # To build extension for PyPy on Windows, "generate-import-lib" is needed: # https://github.com/PyO3/maturin-action/issues/267#issuecomment-2106844429 features = ["extension-module", "generate-import-lib"] From 3f01851ae33f414eaf9bbc843db2e90c0afcd553 Mon Sep 17 00:00:00 2001 From: Nathan Goldbaum Date: Tue, 25 Mar 2025 08:10:19 -0600 Subject: [PATCH 213/241] replace quansight-labs/setup-python with actions/setup-python --- .github/workflows/CI.yml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 85dd45a..77c2527 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -52,7 +52,7 @@ jobs: run: brew install enchant if: runner.os == 'macOS' && startsWith(matrix.noxenv, 'docs') - name: Set up Python - uses: quansight-labs/setup-python@v5 + uses: actions/setup-python@v5 with: python-version: | 3.9 @@ -81,7 +81,7 @@ jobs: - uses: actions/checkout@v4 with: persist-credentials: false - - uses: quansight-labs/setup-python@v5 + - uses: actions/setup-python@v5 with: python-version: | 3.9 @@ -119,7 +119,7 @@ jobs: - uses: actions/checkout@v4 with: persist-credentials: false - - uses: quansight-labs/setup-python@v5 + - uses: actions/setup-python@v5 with: python-version: | 3.9 @@ -154,7 +154,7 @@ jobs: - uses: actions/checkout@v4 with: persist-credentials: false - - uses: quansight-labs/setup-python@v5 + - uses: actions/setup-python@v5 with: python-version: | 3.9 @@ -178,6 +178,8 @@ jobs: name: dist-${{ github.job }}-${{ matrix.target }} path: dist + # free-threaded and normal builds share a site-packages folder on Windows so + # we must build free-threaded separately windows-free-threaded: needs: test runs-on: windows-latest @@ -188,7 +190,7 @@ jobs: - uses: actions/checkout@v4 with: persist-credentials: false - - uses: quansight-labs/setup-python@v5 + - uses: actions/setup-python@v5 with: python-version: 3.13t allow-prereleases: true @@ -215,7 +217,7 @@ jobs: - uses: actions/checkout@v4 with: persist-credentials: false - - uses: quansight-labs/setup-python@v5 + - uses: actions/setup-python@v5 with: python-version: | 3.9 From fadf75232a2feef26435c035074cf32ff42232ba Mon Sep 17 00:00:00 2001 From: Pierre-Yves David Date: Wed, 26 Mar 2025 09:45:06 +0100 Subject: [PATCH 214/241] noxfile: mark pypy 3.11 as supported With pull request #123 merged, this compile with pypy3.11 fine. --- noxfile.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/noxfile.py b/noxfile.py index 0ec7240..6234959 100644 --- a/noxfile.py +++ b/noxfile.py @@ -17,7 +17,16 @@ (path.parent / f"{path.stem}.in", path) for path in REQUIREMENTS.values() ] -SUPPORTED = ["3.9", "3.10", "pypy3.10", "3.11", "3.12", "3.13", "3.13t"] +SUPPORTED = [ + "3.9", + "3.10", + "pypy3.10", + "3.11", + "pypy3.11", + "3.12", + "3.13", + "3.13t", +] LATEST = "3.13" nox.options.default_venv_backend = "uv|virtualenv" From cada83c01d0173e2587302e562d57497682ead70 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Wed, 26 Mar 2025 07:58:48 -0400 Subject: [PATCH 215/241] Update requirements. --- docs/requirements.txt | 8 +++++--- tests/requirements.txt | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/docs/requirements.txt b/docs/requirements.txt index 7a4ba2a..906fb44 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -18,7 +18,7 @@ idna==3.10 # via requests imagesize==1.4.1 # via sphinx -jinja2==3.1.5 +jinja2==3.1.6 # via sphinx markupsafe==3.0.2 # via jinja2 @@ -37,13 +37,15 @@ requests==2.32.3 # via # sphinx # sphinxcontrib-spelling +roman-numerals-py==3.1.0 + # via sphinx rpds-py @ file:.#egg=rpds-py # via -r docs/requirements.in snowballstemmer==2.2.0 # via sphinx soupsieve==2.6 # via beautifulsoup4 -sphinx==8.1.3 +sphinx==8.2.3 # via # -r docs/requirements.in # furo @@ -71,7 +73,7 @@ sphinxcontrib-spelling==8.0.1 # via -r docs/requirements.in sphinxext-opengraph==0.9.1 # via -r docs/requirements.in -typing-extensions==4.12.2 +typing-extensions==4.13.0 # via beautifulsoup4 url-py==0.14.1 # via -r docs/requirements.in diff --git a/tests/requirements.txt b/tests/requirements.txt index 81a3c0d..c3242ee 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -1,12 +1,12 @@ # This file was autogenerated by uv via the following command: # uv pip compile --output-file /Users/julian/Development/rpds.py/tests/requirements.txt tests/requirements.in -iniconfig==2.0.0 +iniconfig==2.1.0 # via pytest packaging==24.2 # via pytest pluggy==1.5.0 # via pytest -pytest==8.3.4 +pytest==8.3.5 # via # -r tests/requirements.in # pytest-run-parallel From db578a1671a50092c373cc0c43dd98a9b08e5f13 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Wed, 26 Mar 2025 08:16:46 -0400 Subject: [PATCH 216/241] Don't fail fast on wheel builds. --- .github/workflows/CI.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 77c2527..d742168 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -74,9 +74,12 @@ jobs: manylinux: needs: test runs-on: ubuntu-latest + strategy: + fail-fast: false matrix: target: [x86_64, x86, aarch64, armv7, s390x, ppc64le] + steps: - uses: actions/checkout@v4 with: @@ -109,12 +112,15 @@ jobs: musllinux: needs: test runs-on: ubuntu-latest + strategy: + fail-fast: false matrix: target: - aarch64-unknown-linux-musl - i686-unknown-linux-musl - x86_64-unknown-linux-musl + steps: - uses: actions/checkout@v4 with: @@ -147,9 +153,12 @@ jobs: windows: needs: test runs-on: windows-latest + strategy: + fail-fast: false matrix: target: [x64, x86] # x86 is not supported by pypy + steps: - uses: actions/checkout@v4 with: @@ -183,9 +192,12 @@ jobs: windows-free-threaded: needs: test runs-on: windows-latest + strategy: + fail-fast: false matrix: target: [x64, x86] # x86 is not supported by pypy + steps: - uses: actions/checkout@v4 with: @@ -210,9 +222,12 @@ jobs: macos: needs: test runs-on: macos-latest + strategy: + fail-fast: false matrix: target: [x86_64, aarch64] + steps: - uses: actions/checkout@v4 with: From a3118d0ca3c11e29d37ecc6bac6a7b4d6e2f1a78 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Mon, 17 Feb 2025 11:14:40 -0500 Subject: [PATCH 217/241] Build for PyPy 3.11 Blocked on PyO3/pyo3#4689 --- .github/workflows/CI.yml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index d742168..f866d20 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -63,6 +63,7 @@ jobs: 3.13t pypy3.9 pypy3.10 + pypy3.11 allow-prereleases: true - uses: astral-sh/setup-uv@v5 @@ -95,12 +96,13 @@ jobs: 3.13t pypy3.9 pypy3.10 + pypy3.11 allow-prereleases: true - name: Build wheels uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} - args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13 3.13t pypy3.9 pypy3.10' + args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13 3.13t pypy3.9 pypy3.10 pypy3.11' sccache: ${{ github.ref_type != 'tag' }} # zizmor: ignore[cache-poisoning] manylinux: auto - name: Upload wheels @@ -136,12 +138,13 @@ jobs: 3.13t pypy3.9 pypy3.10 + pypy3.11 allow-prereleases: true - name: Build wheels uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} - args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13 3.13t pypy3.9 pypy3.10' + args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13 3.13t pypy3.9 pypy3.10 pypy3.11' manylinux: musllinux_1_2 sccache: ${{ github.ref_type != 'tag' }} # zizmor: ignore[cache-poisoning] - name: Upload wheels @@ -173,13 +176,14 @@ jobs: 3.13 ${{ matrix.target == 'x64' && 'pypy3.9' || '' }} ${{ matrix.target == 'x64' && 'pypy3.10' || '' }} + ${{ matrix.target == 'x64' && 'pypy3.11' || '' }} allow-prereleases: true architecture: ${{ matrix.target }} - name: Build wheels uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} - args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13' --interpreter ${{ matrix.target == 'x64' && 'pypy3.9 pypy3.10' || '' }} + args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13' --interpreter ${{ matrix.target == 'x64' && 'pypy3.9 pypy3.10 pypy3.11' || '' }} sccache: ${{ github.ref_type != 'tag' }} # zizmor: ignore[cache-poisoning] - name: Upload wheels uses: actions/upload-artifact@v4 @@ -243,12 +247,13 @@ jobs: 3.13t pypy3.9 pypy3.10 + pypy3.11 allow-prereleases: true - name: Build wheels uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} - args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13 3.13t pypy3.9 pypy3.10' + args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13 3.13t pypy3.9 pypy3.10 pypy3.11' sccache: ${{ github.ref_type != 'tag' }} # zizmor: ignore[cache-poisoning] - name: Upload wheels uses: actions/upload-artifact@v4 From 187d6cdf4488d1c6632aa8c740448299466e4f0a Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Wed, 26 Mar 2025 10:17:07 -0400 Subject: [PATCH 218/241] PyPy3.11 appears not to work even on Windows x64 quite yet. --- .github/workflows/CI.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index f866d20..ed86cfb 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -176,14 +176,13 @@ jobs: 3.13 ${{ matrix.target == 'x64' && 'pypy3.9' || '' }} ${{ matrix.target == 'x64' && 'pypy3.10' || '' }} - ${{ matrix.target == 'x64' && 'pypy3.11' || '' }} allow-prereleases: true architecture: ${{ matrix.target }} - name: Build wheels uses: PyO3/maturin-action@v1 with: target: ${{ matrix.target }} - args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13' --interpreter ${{ matrix.target == 'x64' && 'pypy3.9 pypy3.10 pypy3.11' || '' }} + args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13' --interpreter ${{ matrix.target == 'x64' && 'pypy3.9 pypy3.10' || '' }} sccache: ${{ github.ref_type != 'tag' }} # zizmor: ignore[cache-poisoning] - name: Upload wheels uses: actions/upload-artifact@v4 From c89ed6d5082cf73b6c2822dc00edbec35650a55f Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Wed, 26 Mar 2025 10:39:33 -0400 Subject: [PATCH 219/241] Release v0.24.0 --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6b75db9..09e0281 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -170,7 +170,7 @@ dependencies = [ [[package]] name = "rpds-py" -version = "0.23.1" +version = "0.24.0" dependencies = [ "archery", "pyo3", diff --git a/Cargo.toml b/Cargo.toml index 2f220e7..273dcd2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rpds-py" -version = "0.23.1" +version = "0.24.0" edition = "2021" [lib] From 9c266e7db3952ceb76a9b60b6ead200b2cb7dc53 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 2 Apr 2025 13:24:42 +0000 Subject: [PATCH 220/241] Bump pyo3 from 0.24.0 to 0.24.1 Bumps [pyo3](https://github.com/pyo3/pyo3) from 0.24.0 to 0.24.1. - [Release notes](https://github.com/pyo3/pyo3/releases) - [Changelog](https://github.com/PyO3/pyo3/blob/v0.24.1/CHANGELOG.md) - [Commits](https://github.com/pyo3/pyo3/compare/v0.24.0...v0.24.1) --- updated-dependencies: - dependency-name: pyo3 dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- Cargo.lock | 20 ++++++++++---------- Cargo.toml | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 09e0281..a2509b7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -79,9 +79,9 @@ dependencies = [ [[package]] name = "pyo3" -version = "0.24.0" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f1c6c3591120564d64db2261bec5f910ae454f01def849b9c22835a84695e86" +checksum = "17da310086b068fbdcefbba30aeb3721d5bb9af8db4987d6735b2183ca567229" dependencies = [ "cfg-if", "indoc", @@ -97,9 +97,9 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.24.0" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9b6c2b34cf71427ea37c7001aefbaeb85886a074795e35f161f5aecc7620a7a" +checksum = "e27165889bd793000a098bb966adc4300c312497ea25cf7a690a9f0ac5aa5fc1" dependencies = [ "once_cell", "python3-dll-a", @@ -108,9 +108,9 @@ dependencies = [ [[package]] name = "pyo3-ffi" -version = "0.24.0" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5507651906a46432cdda02cd02dd0319f6064f1374c9147c45b978621d2c3a9c" +checksum = "05280526e1dbf6b420062f3ef228b78c0c54ba94e157f5cb724a609d0f2faabc" dependencies = [ "libc", "pyo3-build-config", @@ -118,9 +118,9 @@ dependencies = [ [[package]] name = "pyo3-macros" -version = "0.24.0" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0d394b5b4fd8d97d48336bb0dd2aebabad39f1d294edd6bcd2cccf2eefe6f42" +checksum = "5c3ce5686aa4d3f63359a5100c62a127c9f15e8398e5fdeb5deef1fed5cd5f44" dependencies = [ "proc-macro2", "pyo3-macros-backend", @@ -130,9 +130,9 @@ dependencies = [ [[package]] name = "pyo3-macros-backend" -version = "0.24.0" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd72da09cfa943b1080f621f024d2ef7e2773df7badd51aa30a2be1f8caa7c8e" +checksum = "f4cf6faa0cbfb0ed08e89beb8103ae9724eb4750e3a78084ba4017cbe94f3855" dependencies = [ "heck", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index 273dcd2..24a2b49 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ rpds = "1.1.0" archery = "1.2.1" [dependencies.pyo3] -version = "0.24.0" +version = "0.24.1" # To build extension for PyPy on Windows, "generate-import-lib" is needed: # https://github.com/PyO3/maturin-action/issues/267#issuecomment-2106844429 features = ["extension-module", "generate-import-lib"] From 72d13f9729735415205302b72f025591b1468d07 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Apr 2025 19:02:33 +0000 Subject: [PATCH 221/241] Bump rpds from 1.1.0 to 1.1.1 Bumps [rpds](https://github.com/orium/rpds) from 1.1.0 to 1.1.1. - [Release notes](https://github.com/orium/rpds/releases) - [Changelog](https://github.com/orium/rpds/blob/main/release-notes.md) - [Commits](https://github.com/orium/rpds/compare/v1.1.0...v1.1.1) --- updated-dependencies: - dependency-name: rpds dependency-version: 1.1.1 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a2509b7..81ac569 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -161,9 +161,9 @@ dependencies = [ [[package]] name = "rpds" -version = "1.1.0" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0e15515d3ce3313324d842629ea4905c25a13f81953eadb88f85516f59290a4" +checksum = "a7f89f654d51fffdd6026289d07d1fd523244d46ae0a8bc22caa6dd7f9e8cb0b" dependencies = [ "archery", ] diff --git a/Cargo.toml b/Cargo.toml index 24a2b49..a329723 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ name = "rpds" crate-type = ["cdylib"] [dependencies] -rpds = "1.1.0" +rpds = "1.1.1" archery = "1.2.1" [dependencies.pyo3] From 75f397c8879ab4d8b291a41cd93a3feafa2d7b3c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 28 Apr 2025 19:20:32 +0000 Subject: [PATCH 222/241] Bump pyo3 from 0.24.1 to 0.24.2 Bumps [pyo3](https://github.com/pyo3/pyo3) from 0.24.1 to 0.24.2. - [Release notes](https://github.com/pyo3/pyo3/releases) - [Changelog](https://github.com/PyO3/pyo3/blob/main/CHANGELOG.md) - [Commits](https://github.com/pyo3/pyo3/compare/v0.24.1...v0.24.2) --- updated-dependencies: - dependency-name: pyo3 dependency-version: 0.24.2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 20 ++++++++++---------- Cargo.toml | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 81ac569..cd5f1c0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -79,9 +79,9 @@ dependencies = [ [[package]] name = "pyo3" -version = "0.24.1" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17da310086b068fbdcefbba30aeb3721d5bb9af8db4987d6735b2183ca567229" +checksum = "e5203598f366b11a02b13aa20cab591229ff0a89fd121a308a5df751d5fc9219" dependencies = [ "cfg-if", "indoc", @@ -97,9 +97,9 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.24.1" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e27165889bd793000a098bb966adc4300c312497ea25cf7a690a9f0ac5aa5fc1" +checksum = "99636d423fa2ca130fa5acde3059308006d46f98caac629418e53f7ebb1e9999" dependencies = [ "once_cell", "python3-dll-a", @@ -108,9 +108,9 @@ dependencies = [ [[package]] name = "pyo3-ffi" -version = "0.24.1" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05280526e1dbf6b420062f3ef228b78c0c54ba94e157f5cb724a609d0f2faabc" +checksum = "78f9cf92ba9c409279bc3305b5409d90db2d2c22392d443a87df3a1adad59e33" dependencies = [ "libc", "pyo3-build-config", @@ -118,9 +118,9 @@ dependencies = [ [[package]] name = "pyo3-macros" -version = "0.24.1" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c3ce5686aa4d3f63359a5100c62a127c9f15e8398e5fdeb5deef1fed5cd5f44" +checksum = "0b999cb1a6ce21f9a6b147dcf1be9ffedf02e0043aec74dc390f3007047cecd9" dependencies = [ "proc-macro2", "pyo3-macros-backend", @@ -130,9 +130,9 @@ dependencies = [ [[package]] name = "pyo3-macros-backend" -version = "0.24.1" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4cf6faa0cbfb0ed08e89beb8103ae9724eb4750e3a78084ba4017cbe94f3855" +checksum = "822ece1c7e1012745607d5cf0bcb2874769f0f7cb34c4cde03b9358eb9ef911a" dependencies = [ "heck", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index a329723..8f8b481 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ rpds = "1.1.1" archery = "1.2.1" [dependencies.pyo3] -version = "0.24.1" +version = "0.24.2" # To build extension for PyPy on Windows, "generate-import-lib" is needed: # https://github.com/PyO3/maturin-action/issues/267#issuecomment-2106844429 features = ["extension-module", "generate-import-lib"] From f8501627383afbfd10b16770f4cdf22b2aeb7de3 Mon Sep 17 00:00:00 2001 From: Finn Womack Date: Sun, 4 May 2025 23:45:16 -0700 Subject: [PATCH 223/241] Add windows arm64 builds for python 3.11, 3.12, and 3.13 --- .github/workflows/CI.yml | 53 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index ed86cfb..451dfdf 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -190,6 +190,59 @@ jobs: name: dist-${{ github.job }}-${{ matrix.target }} path: dist + windows-arm: + needs: test + runs-on: windows-11-arm + + strategy: + fail-fast: false + matrix: + target: + - aarch64-pc-windows-msvc + + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + # Install each python version seperatly so that the paths can be passed to maturin + # to prevent it from finding the x64 pythons pre-installed on the runner instead. + - uses: actions/setup-python@v5 + id: cp311 + with: + python-version: 3.11 + allow-prereleases: true + architecture: arm64 + - uses: actions/setup-python@v5 + id: cp312 + with: + python-version: 3.12 + allow-prereleases: true + architecture: arm64 + - uses: actions/setup-python@v5 + id: cp313 + with: + python-version: 3.13 + allow-prereleases: true + architecture: arm64 + # rust toolchain is not currently installed on windopws arm64 images https://github.com/actions/partner-runner-images/issues/77 + - name: Setup rust + id: setup-rust + run: | + Invoke-WebRequest https://static.rust-lang.org/rustup/dist/aarch64-pc-windows-msvc/rustup-init.exe -OutFile .\rustup-init.exe + .\rustup-init.exe -y + Add-Content $env:GITHUB_PATH "$env:USERPROFILE\.cargo\bin" + - name: Build wheels + uses: PyO3/maturin-action@v1 + with: + target: ${{ matrix.target }} + args: --release --out dist --interpreter ${{ steps.cp311.outputs.python-path }} ${{ steps.cp312.outputs.python-path }} ${{ steps.cp313.outputs.python-path }} + sccache: ${{ github.ref_type != 'tag' }} # zizmor: ignore[cache-poisoning] + - name: Upload wheels + uses: actions/upload-artifact@v4 + with: + name: dist-${{ github.job }}-${{ matrix.target }} + path: dist + # free-threaded and normal builds share a site-packages folder on Windows so # we must build free-threaded separately windows-free-threaded: From bb9ba9e93cd66279a9b57b406963681246f53321 Mon Sep 17 00:00:00 2001 From: Finn Womack Date: Wed, 14 May 2025 00:32:42 -0700 Subject: [PATCH 224/241] add windows-arm to release needs --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 451dfdf..b32f9bb 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -335,7 +335,7 @@ jobs: path: dist release: - needs: [manylinux, musllinux, windows, windows-free-threaded, macos] + needs: [manylinux, musllinux, windows, windows-free-threaded, macos, windows-arm] runs-on: ubuntu-latest if: "startsWith(github.ref, 'refs/tags/')" environment: From 2531d3be39109507d76c88b89f999ca5f4706fcf Mon Sep 17 00:00:00 2001 From: Finn Womack Date: Wed, 14 May 2025 01:23:56 -0700 Subject: [PATCH 225/241] remove trailing whitespace --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index b32f9bb..1e82a22 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -197,7 +197,7 @@ jobs: strategy: fail-fast: false matrix: - target: + target: - aarch64-pc-windows-msvc steps: From f8ad05f251787dfa562b8519082059d63bdc9987 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edgar=20Ram=C3=ADrez=20Mondrag=C3=B3n?= Date: Wed, 14 May 2025 10:43:10 -0600 Subject: [PATCH 226/241] Bump PyO3 to 0.25 --- Cargo.lock | 88 ++++++++++++++++++++++++++++-------------------------- Cargo.toml | 2 +- src/lib.rs | 8 +---- 3 files changed, 47 insertions(+), 51 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cd5f1c0..b35bf1d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13,21 +13,18 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "cc" -version = "1.0.90" +version = "1.2.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +checksum = "32db95edf998450acc7881c932f94cd9b05c87b4b2599e8bab064753da4acfd1" +dependencies = [ + "shlex", +] [[package]] name = "heck" @@ -37,15 +34,15 @@ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "indoc" -version = "2.0.5" +version = "2.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b248f5224d1d606005e02c97f5aa4e88eeb230488bcc03bc9ca4d7991399f2b5" +checksum = "f4c7245a08504955605670dbf141fceab975f15ca21570696aebe9d2e71576bd" [[package]] name = "libc" -version = "0.2.155" +version = "0.2.172" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" +checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa" [[package]] name = "memoffset" @@ -58,32 +55,31 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.19.0" +version = "1.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" [[package]] name = "portable-atomic" -version = "1.6.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7170ef9988bc169ba16dd36a7fa041e5c4cbeb6a35b76d4c03daded371eae7c0" +checksum = "350e9b48cbc6b0e028b0473b114454c6316e57336ee184ceab6e53f72c178b3e" [[package]] name = "proc-macro2" -version = "1.0.86" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" dependencies = [ "unicode-ident", ] [[package]] name = "pyo3" -version = "0.24.2" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5203598f366b11a02b13aa20cab591229ff0a89fd121a308a5df751d5fc9219" +checksum = "f239d656363bcee73afef85277f1b281e8ac6212a1d42aa90e55b90ed43c47a4" dependencies = [ - "cfg-if", "indoc", "libc", "memoffset", @@ -97,9 +93,9 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.24.2" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99636d423fa2ca130fa5acde3059308006d46f98caac629418e53f7ebb1e9999" +checksum = "755ea671a1c34044fa165247aaf6f419ca39caa6003aee791a0df2713d8f1b6d" dependencies = [ "once_cell", "python3-dll-a", @@ -108,9 +104,9 @@ dependencies = [ [[package]] name = "pyo3-ffi" -version = "0.24.2" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78f9cf92ba9c409279bc3305b5409d90db2d2c22392d443a87df3a1adad59e33" +checksum = "fc95a2e67091e44791d4ea300ff744be5293f394f1bafd9f78c080814d35956e" dependencies = [ "libc", "pyo3-build-config", @@ -118,9 +114,9 @@ dependencies = [ [[package]] name = "pyo3-macros" -version = "0.24.2" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b999cb1a6ce21f9a6b147dcf1be9ffedf02e0043aec74dc390f3007047cecd9" +checksum = "a179641d1b93920829a62f15e87c0ed791b6c8db2271ba0fd7c2686090510214" dependencies = [ "proc-macro2", "pyo3-macros-backend", @@ -130,9 +126,9 @@ dependencies = [ [[package]] name = "pyo3-macros-backend" -version = "0.24.2" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "822ece1c7e1012745607d5cf0bcb2874769f0f7cb34c4cde03b9358eb9ef911a" +checksum = "9dff85ebcaab8c441b0e3f7ae40a6963ecea8a9f5e74f647e33fcf5ec9a1e89e" dependencies = [ "heck", "proc-macro2", @@ -143,18 +139,18 @@ dependencies = [ [[package]] name = "python3-dll-a" -version = "0.2.12" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b66f9171950e674e64bad3456e11bb3cca108e5c34844383cfe277f45c8a7a8" +checksum = "49fe4227a288cf9493942ad0220ea3f185f4d1f2a14f197f7344d6d02f4ed4ed" dependencies = [ "cc", ] [[package]] name = "quote" -version = "1.0.36" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" dependencies = [ "proc-macro2", ] @@ -177,11 +173,17 @@ dependencies = [ "rpds", ] +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + [[package]] name = "syn" -version = "2.0.69" +version = "2.0.101" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "201fcda3845c23e8212cd466bfebf0bd20694490fc0356ae8e428e0824a915a6" +checksum = "8ce2b7fc941b3a24138a0a7cf8e858bfc6a992e7978a068a5c760deb0ed43caf" dependencies = [ "proc-macro2", "quote", @@ -196,18 +198,18 @@ checksum = "e502f78cdbb8ba4718f566c418c52bc729126ffd16baee5baa718cf25dd5a69a" [[package]] name = "triomphe" -version = "0.1.13" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6631e42e10b40c0690bf92f404ebcfe6e1fdb480391d15f17cc8e96eeed5369" +checksum = "ef8f7726da4807b58ea5c96fdc122f80702030edc33b35aff9190a51148ccc85" [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" [[package]] name = "unindent" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7de7d73e1754487cb58364ee906a499937a0dfabd86bcb980fa99ec8c8fa2ce" +checksum = "7264e107f553ccae879d21fbea1d6724ac785e8c3bfc762137959b5802826ef3" diff --git a/Cargo.toml b/Cargo.toml index 8f8b481..7c9745c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ rpds = "1.1.1" archery = "1.2.1" [dependencies.pyo3] -version = "0.24.2" +version = "0.25.0" # To build extension for PyPy on Windows, "generate-import-lib" is needed: # https://github.com/PyO3/maturin-action/issues/267#issuecomment-2106844429 features = ["extension-module", "generate-import-lib"] diff --git a/src/lib.rs b/src/lib.rs index c95c40a..9f266a8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,7 +2,7 @@ use pyo3::exceptions::{PyIndexError, PyTypeError}; use pyo3::pyclass::CompareOp; use pyo3::types::{PyDict, PyIterator, PyTuple, PyType}; use pyo3::{exceptions::PyKeyError, types::PyMapping, types::PyTupleMethods}; -use pyo3::{prelude::*, AsPyPointer, BoundObject, PyTypeInfo}; +use pyo3::{prelude::*, BoundObject, PyTypeInfo}; use rpds::{ HashTrieMap, HashTrieMapSync, HashTrieSet, HashTrieSetSync, List, ListSync, Queue, QueueSync, }; @@ -67,12 +67,6 @@ impl Key { } } -unsafe impl AsPyPointer for Key { - fn as_ptr(&self) -> *mut pyo3::ffi::PyObject { - self.inner.as_ptr() - } -} - impl<'source> FromPyObject<'source> for Key { fn extract_bound(ob: &Bound<'source, PyAny>) -> PyResult { Ok(Key { From 2550d1d0429d5a0b2cb65734c8d7b068ac598845 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Thu, 15 May 2025 09:23:40 -0400 Subject: [PATCH 227/241] Update dependencies. --- docs/requirements.txt | 18 +++++++++--------- tests/requirements.txt | 6 +++--- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/requirements.txt b/docs/requirements.txt index 906fb44..3171c85 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -4,11 +4,11 @@ alabaster==1.0.0 # via sphinx babel==2.17.0 # via sphinx -beautifulsoup4==4.13.3 +beautifulsoup4==4.13.4 # via furo -certifi==2025.1.31 +certifi==2025.4.26 # via requests -charset-normalizer==3.4.1 +charset-normalizer==3.4.2 # via requests docutils==0.21.2 # via sphinx @@ -22,7 +22,7 @@ jinja2==3.1.6 # via sphinx markupsafe==3.0.2 # via jinja2 -packaging==24.2 +packaging==25.0 # via sphinx pyenchant==3.2.2 # via sphinxcontrib-spelling @@ -41,9 +41,9 @@ roman-numerals-py==3.1.0 # via sphinx rpds-py @ file:.#egg=rpds-py # via -r docs/requirements.in -snowballstemmer==2.2.0 +snowballstemmer==3.0.1 # via sphinx -soupsieve==2.6 +soupsieve==2.7 # via beautifulsoup4 sphinx==8.2.3 # via @@ -71,11 +71,11 @@ sphinxcontrib-serializinghtml==2.0.0 # via sphinx sphinxcontrib-spelling==8.0.1 # via -r docs/requirements.in -sphinxext-opengraph==0.9.1 +sphinxext-opengraph==0.10.0 # via -r docs/requirements.in -typing-extensions==4.13.0 +typing-extensions==4.13.2 # via beautifulsoup4 url-py==0.14.1 # via -r docs/requirements.in -urllib3==2.3.0 +urllib3==2.4.0 # via requests diff --git a/tests/requirements.txt b/tests/requirements.txt index c3242ee..6d2db2e 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -2,15 +2,15 @@ # uv pip compile --output-file /Users/julian/Development/rpds.py/tests/requirements.txt tests/requirements.in iniconfig==2.1.0 # via pytest -packaging==24.2 +packaging==25.0 # via pytest -pluggy==1.5.0 +pluggy==1.6.0 # via pytest pytest==8.3.5 # via # -r tests/requirements.in # pytest-run-parallel -pytest-run-parallel==0.3.1 +pytest-run-parallel==0.4.2 # via -r tests/requirements.in rpds-py @ file:.#egg=rpds-py # via -r tests/requirements.in From f4070f93e6fa9e39749f395d01c18450d110e0ed Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Thu, 15 May 2025 09:27:54 -0400 Subject: [PATCH 228/241] Release v0.25.0. --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b35bf1d..2c51abc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -166,7 +166,7 @@ dependencies = [ [[package]] name = "rpds-py" -version = "0.24.0" +version = "0.25.0" dependencies = [ "archery", "pyo3", diff --git a/Cargo.toml b/Cargo.toml index 7c9745c..c6b066d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rpds-py" -version = "0.24.0" +version = "0.25.0" edition = "2021" [lib] From 1571595d8db67196e41451c9e12c4b65a7a8b2a1 Mon Sep 17 00:00:00 2001 From: Finn Womack Date: Mon, 19 May 2025 12:28:36 -0700 Subject: [PATCH 229/241] pin maturin-action steps to hash --- .github/workflows/CI.yml | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 1e82a22..ae948ca 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -99,7 +99,7 @@ jobs: pypy3.11 allow-prereleases: true - name: Build wheels - uses: PyO3/maturin-action@v1 + uses: PyO3/maturin-action@aef21716ff3dcae8a1c301d23ec3e4446972a6e3 # v1.49.1 with: target: ${{ matrix.target }} args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13 3.13t pypy3.9 pypy3.10 pypy3.11' @@ -141,7 +141,7 @@ jobs: pypy3.11 allow-prereleases: true - name: Build wheels - uses: PyO3/maturin-action@v1 + uses: PyO3/maturin-action@aef21716ff3dcae8a1c301d23ec3e4446972a6e3 # v1.49.1 with: target: ${{ matrix.target }} args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13 3.13t pypy3.9 pypy3.10 pypy3.11' @@ -179,7 +179,7 @@ jobs: allow-prereleases: true architecture: ${{ matrix.target }} - name: Build wheels - uses: PyO3/maturin-action@v1 + uses: PyO3/maturin-action@aef21716ff3dcae8a1c301d23ec3e4446972a6e3 # v1.49.1 with: target: ${{ matrix.target }} args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13' --interpreter ${{ matrix.target == 'x64' && 'pypy3.9 pypy3.10' || '' }} @@ -204,8 +204,7 @@ jobs: - uses: actions/checkout@v4 with: persist-credentials: false - # Install each python version seperatly so that the paths can be passed to maturin - # to prevent it from finding the x64 pythons pre-installed on the runner instead. + # Install each python version seperatly so that the paths can be passed to maturin. (otherwise finds pre-installed x64 versions) - uses: actions/setup-python@v5 id: cp311 with: @@ -224,7 +223,7 @@ jobs: python-version: 3.13 allow-prereleases: true architecture: arm64 - # rust toolchain is not currently installed on windopws arm64 images https://github.com/actions/partner-runner-images/issues/77 + # rust toolchain is not currently installed on windopws arm64 images: https://github.com/actions/partner-runner-images/issues/77 - name: Setup rust id: setup-rust run: | @@ -232,7 +231,7 @@ jobs: .\rustup-init.exe -y Add-Content $env:GITHUB_PATH "$env:USERPROFILE\.cargo\bin" - name: Build wheels - uses: PyO3/maturin-action@v1 + uses: PyO3/maturin-action@aef21716ff3dcae8a1c301d23ec3e4446972a6e3 # v1.49.1 with: target: ${{ matrix.target }} args: --release --out dist --interpreter ${{ steps.cp311.outputs.python-path }} ${{ steps.cp312.outputs.python-path }} ${{ steps.cp313.outputs.python-path }} @@ -264,7 +263,7 @@ jobs: allow-prereleases: true architecture: ${{ matrix.target }} - name: Build wheels - uses: PyO3/maturin-action@v1 + uses: PyO3/maturin-action@aef21716ff3dcae8a1c301d23ec3e4446972a6e3 # v1.49.1 with: target: ${{ matrix.target }} args: --release --out dist --interpreter '3.13t' @@ -302,7 +301,7 @@ jobs: pypy3.11 allow-prereleases: true - name: Build wheels - uses: PyO3/maturin-action@v1 + uses: PyO3/maturin-action@aef21716ff3dcae8a1c301d23ec3e4446972a6e3 # v1.49.1 with: target: ${{ matrix.target }} args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13 3.13t pypy3.9 pypy3.10 pypy3.11' @@ -324,7 +323,7 @@ jobs: with: python-version: 3.13 - name: Build an sdist - uses: PyO3/maturin-action@v1 + uses: PyO3/maturin-action@aef21716ff3dcae8a1c301d23ec3e4446972a6e3 # v1.49.1 with: command: sdist args: --out dist @@ -351,7 +350,7 @@ jobs: pattern: dist-* merge-multiple: true - name: Publish to PyPI - uses: PyO3/maturin-action@v1 + uses: PyO3/maturin-action@aef21716ff3dcae8a1c301d23ec3e4446972a6e3 # v1.49.1 with: command: upload args: --non-interactive --skip-existing * From 403a90de2c44162753634897259c0a33faf08f67 Mon Sep 17 00:00:00 2001 From: Finn Womack Date: Mon, 19 May 2025 12:49:47 -0700 Subject: [PATCH 230/241] fix indentation --- .github/workflows/CI.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index ae948ca..d7776b5 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -227,9 +227,9 @@ jobs: - name: Setup rust id: setup-rust run: | - Invoke-WebRequest https://static.rust-lang.org/rustup/dist/aarch64-pc-windows-msvc/rustup-init.exe -OutFile .\rustup-init.exe - .\rustup-init.exe -y - Add-Content $env:GITHUB_PATH "$env:USERPROFILE\.cargo\bin" + Invoke-WebRequest https://static.rust-lang.org/rustup/dist/aarch64-pc-windows-msvc/rustup-init.exe -OutFile .\rustup-init.exe + .\rustup-init.exe -y + Add-Content $env:GITHUB_PATH "$env:USERPROFILE\.cargo\bin" - name: Build wheels uses: PyO3/maturin-action@aef21716ff3dcae8a1c301d23ec3e4446972a6e3 # v1.49.1 with: @@ -334,7 +334,8 @@ jobs: path: dist release: - needs: [manylinux, musllinux, windows, windows-free-threaded, macos, windows-arm] + needs: + [manylinux, musllinux, windows, windows-arm, windows-free-threaded, macos] runs-on: ubuntu-latest if: "startsWith(github.ref, 'refs/tags/')" environment: From e4f09f10e40211984fc3c748956b5530f225f3cc Mon Sep 17 00:00:00 2001 From: Finn Womack Date: Mon, 19 May 2025 12:52:19 -0700 Subject: [PATCH 231/241] remove trailing whitespace --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index d7776b5..da3b869 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -334,7 +334,7 @@ jobs: path: dist release: - needs: + needs: [manylinux, musllinux, windows, windows-arm, windows-free-threaded, macos] runs-on: ubuntu-latest if: "startsWith(github.ref, 'refs/tags/')" From 996e50aec57a169d820671e1625c129a6e470709 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Wed, 21 May 2025 08:31:36 -0400 Subject: [PATCH 232/241] Properly pin hashes in workflows. --- .github/workflows/CI.yml | 6 +++--- .github/workflows/zizmor.yml | 16 ++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index da3b869..055b63b 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -23,7 +23,7 @@ jobs: - uses: actions/checkout@v4 with: persist-credentials: false - - uses: astral-sh/setup-uv@v5 + - uses: astral-sh/setup-uv@6b9c6063abd6010835644d4c2e1bef4cf5cd0fca with: enable-cache: ${{ github.ref_type != 'tag' }} # zizmor: ignore[cache-poisoning] - id: noxenvs-matrix @@ -66,7 +66,7 @@ jobs: pypy3.11 allow-prereleases: true - - uses: astral-sh/setup-uv@v5 + - uses: astral-sh/setup-uv@6b9c6063abd6010835644d4c2e1bef4cf5cd0fca with: enable-cache: ${{ github.ref_type != 'tag' }} # zizmor: ignore[cache-poisoning] - name: Run nox @@ -357,7 +357,7 @@ jobs: args: --non-interactive --skip-existing * - name: Create a GitHub Release if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') - uses: softprops/action-gh-release@v2 + uses: softprops/action-gh-release@da05d552573ad5aba039eaac05058a918a7bf631 with: files: | * diff --git a/.github/workflows/zizmor.yml b/.github/workflows/zizmor.yml index bdba878..973df06 100644 --- a/.github/workflows/zizmor.yml +++ b/.github/workflows/zizmor.yml @@ -6,6 +6,8 @@ on: pull_request: branches: ["**"] +permissions: {} + jobs: zizmor: runs-on: ubuntu-latest @@ -14,21 +16,19 @@ jobs: security-events: write steps: - - name: Checkout repository - uses: actions/checkout@v4 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: persist-credentials: false - - name: Setup Rust - uses: actions-rust-lang/setup-rust-toolchain@v1 - - name: Install zizmor - run: cargo install zizmor + + - uses: astral-sh/setup-uv@6b9c6063abd6010835644d4c2e1bef4cf5cd0fca # v6.0.1 - name: Run zizmor 🌈 - run: zizmor --format sarif . > results.sarif + run: uvx zizmor --format=sarif . > results.sarif + env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Upload SARIF file - uses: github/codeql-action/upload-sarif@v3 + uses: github/codeql-action/upload-sarif@ff0a06e83cb2de871e5a09832bc6a81e7276941f # v3.28.18 with: sarif_file: results.sarif category: zizmor From 125b4b194b824ed55bf81add8ae302490bc49192 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Wed, 21 May 2025 08:34:09 -0400 Subject: [PATCH 233/241] Release v0.25.1 for Windows ARM. --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2c51abc..df748ea 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -166,7 +166,7 @@ dependencies = [ [[package]] name = "rpds-py" -version = "0.25.0" +version = "0.25.1" dependencies = [ "archery", "pyo3", diff --git a/Cargo.toml b/Cargo.toml index c6b066d..54ab9f2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rpds-py" -version = "0.25.0" +version = "0.25.1" edition = "2021" [lib] From c93a0a5db9933d9cda2e92152f989e745311612b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 26 May 2025 18:55:50 +0000 Subject: [PATCH 234/241] Bump astral-sh/setup-uv from 6.0.1 to 6.1.0 Bumps [astral-sh/setup-uv](https://github.com/astral-sh/setup-uv) from 6.0.1 to 6.1.0. - [Release notes](https://github.com/astral-sh/setup-uv/releases) - [Commits](https://github.com/astral-sh/setup-uv/compare/6b9c6063abd6010835644d4c2e1bef4cf5cd0fca...f0ec1fc3b38f5e7cd731bb6ce540c5af426746bb) --- updated-dependencies: - dependency-name: astral-sh/setup-uv dependency-version: 6.1.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/CI.yml | 4 ++-- .github/workflows/zizmor.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 055b63b..8bd5a59 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -23,7 +23,7 @@ jobs: - uses: actions/checkout@v4 with: persist-credentials: false - - uses: astral-sh/setup-uv@6b9c6063abd6010835644d4c2e1bef4cf5cd0fca + - uses: astral-sh/setup-uv@f0ec1fc3b38f5e7cd731bb6ce540c5af426746bb with: enable-cache: ${{ github.ref_type != 'tag' }} # zizmor: ignore[cache-poisoning] - id: noxenvs-matrix @@ -66,7 +66,7 @@ jobs: pypy3.11 allow-prereleases: true - - uses: astral-sh/setup-uv@6b9c6063abd6010835644d4c2e1bef4cf5cd0fca + - uses: astral-sh/setup-uv@f0ec1fc3b38f5e7cd731bb6ce540c5af426746bb with: enable-cache: ${{ github.ref_type != 'tag' }} # zizmor: ignore[cache-poisoning] - name: Run nox diff --git a/.github/workflows/zizmor.yml b/.github/workflows/zizmor.yml index 973df06..a373a99 100644 --- a/.github/workflows/zizmor.yml +++ b/.github/workflows/zizmor.yml @@ -20,7 +20,7 @@ jobs: with: persist-credentials: false - - uses: astral-sh/setup-uv@6b9c6063abd6010835644d4c2e1bef4cf5cd0fca # v6.0.1 + - uses: astral-sh/setup-uv@f0ec1fc3b38f5e7cd731bb6ce540c5af426746bb # v6.1.0 - name: Run zizmor 🌈 run: uvx zizmor --format=sarif . > results.sarif From 0dce5bec441118bf7fa3cd89f742067d8b60d321 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edgar=20Ram=C3=ADrez=20Mondrag=C3=B3n?= Date: Wed, 14 May 2025 10:43:10 -0600 Subject: [PATCH 235/241] Build CPython 3.14 wheels --- .github/workflows/CI.yml | 31 ++++++++++++++++++++++++------- Cargo.lock | 8 ++++---- noxfile.py | 2 ++ pyproject.toml | 1 + 4 files changed, 31 insertions(+), 11 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 8bd5a59..0cc1dce 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -61,6 +61,8 @@ jobs: 3.12 3.13 3.13t + 3.14 + 3.14t pypy3.9 pypy3.10 pypy3.11 @@ -94,6 +96,8 @@ jobs: 3.12 3.13 3.13t + 3.14 + 3.14t pypy3.9 pypy3.10 pypy3.11 @@ -102,7 +106,7 @@ jobs: uses: PyO3/maturin-action@aef21716ff3dcae8a1c301d23ec3e4446972a6e3 # v1.49.1 with: target: ${{ matrix.target }} - args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13 3.13t pypy3.9 pypy3.10 pypy3.11' + args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13 3.13t 3.14 3.14t pypy3.9 pypy3.10 pypy3.11' sccache: ${{ github.ref_type != 'tag' }} # zizmor: ignore[cache-poisoning] manylinux: auto - name: Upload wheels @@ -136,6 +140,8 @@ jobs: 3.12 3.13 3.13t + 3.14 + 3.14t pypy3.9 pypy3.10 pypy3.11 @@ -144,7 +150,7 @@ jobs: uses: PyO3/maturin-action@aef21716ff3dcae8a1c301d23ec3e4446972a6e3 # v1.49.1 with: target: ${{ matrix.target }} - args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13 3.13t pypy3.9 pypy3.10 pypy3.11' + args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13 3.13t 3.14 3.14t pypy3.9 pypy3.10 pypy3.11' manylinux: musllinux_1_2 sccache: ${{ github.ref_type != 'tag' }} # zizmor: ignore[cache-poisoning] - name: Upload wheels @@ -174,6 +180,7 @@ jobs: 3.11 3.12 3.13 + 3.14 ${{ matrix.target == 'x64' && 'pypy3.9' || '' }} ${{ matrix.target == 'x64' && 'pypy3.10' || '' }} allow-prereleases: true @@ -182,7 +189,7 @@ jobs: uses: PyO3/maturin-action@aef21716ff3dcae8a1c301d23ec3e4446972a6e3 # v1.49.1 with: target: ${{ matrix.target }} - args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13' --interpreter ${{ matrix.target == 'x64' && 'pypy3.9 pypy3.10' || '' }} + args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13 3.14' --interpreter ${{ matrix.target == 'x64' && 'pypy3.9 pypy3.10' || '' }} sccache: ${{ github.ref_type != 'tag' }} # zizmor: ignore[cache-poisoning] - name: Upload wheels uses: actions/upload-artifact@v4 @@ -223,6 +230,12 @@ jobs: python-version: 3.13 allow-prereleases: true architecture: arm64 + - uses: actions/setup-python@v5 + id: cp314 + with: + python-version: 3.14 + allow-prereleases: true + architecture: arm64 # rust toolchain is not currently installed on windopws arm64 images: https://github.com/actions/partner-runner-images/issues/77 - name: Setup rust id: setup-rust @@ -234,7 +247,7 @@ jobs: uses: PyO3/maturin-action@aef21716ff3dcae8a1c301d23ec3e4446972a6e3 # v1.49.1 with: target: ${{ matrix.target }} - args: --release --out dist --interpreter ${{ steps.cp311.outputs.python-path }} ${{ steps.cp312.outputs.python-path }} ${{ steps.cp313.outputs.python-path }} + args: --release --out dist --interpreter ${{ steps.cp311.outputs.python-path }} ${{ steps.cp312.outputs.python-path }} ${{ steps.cp313.outputs.python-path }} ${{ steps.cp314.outputs.python-path }} sccache: ${{ github.ref_type != 'tag' }} # zizmor: ignore[cache-poisoning] - name: Upload wheels uses: actions/upload-artifact@v4 @@ -259,14 +272,16 @@ jobs: persist-credentials: false - uses: actions/setup-python@v5 with: - python-version: 3.13t + python-version: | + 3.13t + 3.14t allow-prereleases: true architecture: ${{ matrix.target }} - name: Build wheels uses: PyO3/maturin-action@aef21716ff3dcae8a1c301d23ec3e4446972a6e3 # v1.49.1 with: target: ${{ matrix.target }} - args: --release --out dist --interpreter '3.13t' + args: --release --out dist --interpreter '3.13t 3.14t' sccache: ${{ github.ref_type != 'tag' }} # zizmor: ignore[cache-poisoning] - name: Upload wheels uses: actions/upload-artifact@v4 @@ -296,6 +311,8 @@ jobs: 3.12 3.13 3.13t + 3.14 + 3.14t pypy3.9 pypy3.10 pypy3.11 @@ -304,7 +321,7 @@ jobs: uses: PyO3/maturin-action@aef21716ff3dcae8a1c301d23ec3e4446972a6e3 # v1.49.1 with: target: ${{ matrix.target }} - args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13 3.13t pypy3.9 pypy3.10 pypy3.11' + args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13 3.13t 3.14 3.14t pypy3.9 pypy3.10 pypy3.11' sccache: ${{ github.ref_type != 'tag' }} # zizmor: ignore[cache-poisoning] - name: Upload wheels uses: actions/upload-artifact@v4 diff --git a/Cargo.lock b/Cargo.lock index df748ea..a1842f2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -19,9 +19,9 @@ checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "cc" -version = "1.2.22" +version = "1.2.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32db95edf998450acc7881c932f94cd9b05c87b4b2599e8bab064753da4acfd1" +checksum = "d0fc897dc1e865cc67c0e05a836d9d3f1df3cbe442aa4a9473b18e12624a4951" dependencies = [ "shlex", ] @@ -139,9 +139,9 @@ dependencies = [ [[package]] name = "python3-dll-a" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49fe4227a288cf9493942ad0220ea3f185f4d1f2a14f197f7344d6d02f4ed4ed" +checksum = "d381ef313ae70b4da5f95f8a4de773c6aa5cd28f73adec4b4a31df70b66780d8" dependencies = [ "cc", ] diff --git a/noxfile.py b/noxfile.py index 6234959..8b9d55d 100644 --- a/noxfile.py +++ b/noxfile.py @@ -26,6 +26,8 @@ "3.12", "3.13", "3.13t", + "3.14", + "3.14t", ] LATEST = "3.13" diff --git a/pyproject.toml b/pyproject.toml index a995f55..bb66591 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,6 +23,7 @@ classifiers = [ "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3.14", "Programming Language :: Python :: 3", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", From 6b6da85eade9bd30660cf5abc772fea117a93d7e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 Jun 2025 19:02:05 +0000 Subject: [PATCH 236/241] Bump github/codeql-action from 3.28.18 to 3.28.19 Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.28.18 to 3.28.19. - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/github/codeql-action/compare/ff0a06e83cb2de871e5a09832bc6a81e7276941f...fca7ace96b7d713c7035871441bd52efbe39e27e) --- updated-dependencies: - dependency-name: github/codeql-action dependency-version: 3.28.19 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/zizmor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/zizmor.yml b/.github/workflows/zizmor.yml index a373a99..8488704 100644 --- a/.github/workflows/zizmor.yml +++ b/.github/workflows/zizmor.yml @@ -28,7 +28,7 @@ jobs: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Upload SARIF file - uses: github/codeql-action/upload-sarif@ff0a06e83cb2de871e5a09832bc6a81e7276941f # v3.28.18 + uses: github/codeql-action/upload-sarif@fca7ace96b7d713c7035871441bd52efbe39e27e # v3.28.19 with: sarif_file: results.sarif category: zizmor From 505669577b3ca81cca051f32bd6613f7b52893f9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Jun 2025 19:44:10 +0000 Subject: [PATCH 237/241] Bump pyo3 from 0.25.0 to 0.25.1 Bumps [pyo3](https://github.com/pyo3/pyo3) from 0.25.0 to 0.25.1. - [Release notes](https://github.com/pyo3/pyo3/releases) - [Changelog](https://github.com/PyO3/pyo3/blob/v0.25.1/CHANGELOG.md) - [Commits](https://github.com/pyo3/pyo3/compare/v0.25.0...v0.25.1) --- updated-dependencies: - dependency-name: pyo3 dependency-version: 0.25.1 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 20 ++++++++++---------- Cargo.toml | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a1842f2..ab98755 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -76,9 +76,9 @@ dependencies = [ [[package]] name = "pyo3" -version = "0.25.0" +version = "0.25.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f239d656363bcee73afef85277f1b281e8ac6212a1d42aa90e55b90ed43c47a4" +checksum = "8970a78afe0628a3e3430376fc5fd76b6b45c4d43360ffd6cdd40bdde72b682a" dependencies = [ "indoc", "libc", @@ -93,9 +93,9 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.25.0" +version = "0.25.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "755ea671a1c34044fa165247aaf6f419ca39caa6003aee791a0df2713d8f1b6d" +checksum = "458eb0c55e7ece017adeba38f2248ff3ac615e53660d7c71a238d7d2a01c7598" dependencies = [ "once_cell", "python3-dll-a", @@ -104,9 +104,9 @@ dependencies = [ [[package]] name = "pyo3-ffi" -version = "0.25.0" +version = "0.25.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc95a2e67091e44791d4ea300ff744be5293f394f1bafd9f78c080814d35956e" +checksum = "7114fe5457c61b276ab77c5055f206295b812608083644a5c5b2640c3102565c" dependencies = [ "libc", "pyo3-build-config", @@ -114,9 +114,9 @@ dependencies = [ [[package]] name = "pyo3-macros" -version = "0.25.0" +version = "0.25.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a179641d1b93920829a62f15e87c0ed791b6c8db2271ba0fd7c2686090510214" +checksum = "a8725c0a622b374d6cb051d11a0983786448f7785336139c3c94f5aa6bef7e50" dependencies = [ "proc-macro2", "pyo3-macros-backend", @@ -126,9 +126,9 @@ dependencies = [ [[package]] name = "pyo3-macros-backend" -version = "0.25.0" +version = "0.25.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dff85ebcaab8c441b0e3f7ae40a6963ecea8a9f5e74f647e33fcf5ec9a1e89e" +checksum = "4109984c22491085343c05b0dbc54ddc405c3cf7b4374fc533f5c3313a572ccc" dependencies = [ "heck", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index 54ab9f2..d797d4c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ rpds = "1.1.1" archery = "1.2.1" [dependencies.pyo3] -version = "0.25.0" +version = "0.25.1" # To build extension for PyPy on Windows, "generate-import-lib" is needed: # https://github.com/PyO3/maturin-action/issues/267#issuecomment-2106844429 features = ["extension-module", "generate-import-lib"] From 81d0f179140582ced6f8ab355aeec62062991bac Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Jun 2025 19:52:13 +0000 Subject: [PATCH 238/241] Bump softprops/action-gh-release from 2.2.2 to 2.3.2 Bumps [softprops/action-gh-release](https://github.com/softprops/action-gh-release) from 2.2.2 to 2.3.2. - [Release notes](https://github.com/softprops/action-gh-release/releases) - [Changelog](https://github.com/softprops/action-gh-release/blob/master/CHANGELOG.md) - [Commits](https://github.com/softprops/action-gh-release/compare/da05d552573ad5aba039eaac05058a918a7bf631...72f2c25fcb47643c292f7107632f7a47c1df5cd8) --- updated-dependencies: - dependency-name: softprops/action-gh-release dependency-version: 2.3.2 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 0cc1dce..e137e83 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -374,7 +374,7 @@ jobs: args: --non-interactive --skip-existing * - name: Create a GitHub Release if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') - uses: softprops/action-gh-release@da05d552573ad5aba039eaac05058a918a7bf631 + uses: softprops/action-gh-release@72f2c25fcb47643c292f7107632f7a47c1df5cd8 with: files: | * From ddb0e86b2d4929edd97e03a1c742c86387cab95b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Jun 2025 20:05:55 +0000 Subject: [PATCH 239/241] Bump github/codeql-action from 3.28.19 to 3.29.0 Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.28.19 to 3.29.0. - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/github/codeql-action/compare/fca7ace96b7d713c7035871441bd52efbe39e27e...ce28f5bb42b7a9f2c824e633a3f6ee835bab6858) --- updated-dependencies: - dependency-name: github/codeql-action dependency-version: 3.29.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/zizmor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/zizmor.yml b/.github/workflows/zizmor.yml index 8488704..70b348b 100644 --- a/.github/workflows/zizmor.yml +++ b/.github/workflows/zizmor.yml @@ -28,7 +28,7 @@ jobs: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Upload SARIF file - uses: github/codeql-action/upload-sarif@fca7ace96b7d713c7035871441bd52efbe39e27e # v3.28.19 + uses: github/codeql-action/upload-sarif@ce28f5bb42b7a9f2c824e633a3f6ee835bab6858 # v3.29.0 with: sarif_file: results.sarif category: zizmor From 79a85b69dfa9389356c755a0f3d6263b7ff69fc2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 23 Jun 2025 20:40:41 +0000 Subject: [PATCH 240/241] Bump astral-sh/setup-uv from 6.1.0 to 6.3.0 Bumps [astral-sh/setup-uv](https://github.com/astral-sh/setup-uv) from 6.1.0 to 6.3.0. - [Release notes](https://github.com/astral-sh/setup-uv/releases) - [Commits](https://github.com/astral-sh/setup-uv/compare/f0ec1fc3b38f5e7cd731bb6ce540c5af426746bb...445689ea25e0de0a23313031f5fe577c74ae45a1) --- updated-dependencies: - dependency-name: astral-sh/setup-uv dependency-version: 6.3.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/CI.yml | 4 ++-- .github/workflows/zizmor.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index e137e83..eaa7286 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -23,7 +23,7 @@ jobs: - uses: actions/checkout@v4 with: persist-credentials: false - - uses: astral-sh/setup-uv@f0ec1fc3b38f5e7cd731bb6ce540c5af426746bb + - uses: astral-sh/setup-uv@445689ea25e0de0a23313031f5fe577c74ae45a1 with: enable-cache: ${{ github.ref_type != 'tag' }} # zizmor: ignore[cache-poisoning] - id: noxenvs-matrix @@ -68,7 +68,7 @@ jobs: pypy3.11 allow-prereleases: true - - uses: astral-sh/setup-uv@f0ec1fc3b38f5e7cd731bb6ce540c5af426746bb + - uses: astral-sh/setup-uv@445689ea25e0de0a23313031f5fe577c74ae45a1 with: enable-cache: ${{ github.ref_type != 'tag' }} # zizmor: ignore[cache-poisoning] - name: Run nox diff --git a/.github/workflows/zizmor.yml b/.github/workflows/zizmor.yml index 70b348b..e5bb522 100644 --- a/.github/workflows/zizmor.yml +++ b/.github/workflows/zizmor.yml @@ -20,7 +20,7 @@ jobs: with: persist-credentials: false - - uses: astral-sh/setup-uv@f0ec1fc3b38f5e7cd731bb6ce540c5af426746bb # v6.1.0 + - uses: astral-sh/setup-uv@445689ea25e0de0a23313031f5fe577c74ae45a1 # v6.3.0 - name: Run zizmor 🌈 run: uvx zizmor --format=sarif . > results.sarif From 9834af08bcb94e1532ff7dab80779d3036e8b7a4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 23 Jun 2025 20:49:18 +0000 Subject: [PATCH 241/241] Bump PyO3/maturin-action from 1.49.1 to 1.49.3 Bumps [PyO3/maturin-action](https://github.com/pyo3/maturin-action) from 1.49.1 to 1.49.3. - [Release notes](https://github.com/pyo3/maturin-action/releases) - [Commits](https://github.com/pyo3/maturin-action/compare/aef21716ff3dcae8a1c301d23ec3e4446972a6e3...e10f6c464b90acceb5f640d31beda6d586ba7b4a) --- updated-dependencies: - dependency-name: PyO3/maturin-action dependency-version: 1.49.3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/CI.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index e137e83..b6028ea 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -103,7 +103,7 @@ jobs: pypy3.11 allow-prereleases: true - name: Build wheels - uses: PyO3/maturin-action@aef21716ff3dcae8a1c301d23ec3e4446972a6e3 # v1.49.1 + uses: PyO3/maturin-action@e10f6c464b90acceb5f640d31beda6d586ba7b4a # v1.49.3 with: target: ${{ matrix.target }} args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13 3.13t 3.14 3.14t pypy3.9 pypy3.10 pypy3.11' @@ -147,7 +147,7 @@ jobs: pypy3.11 allow-prereleases: true - name: Build wheels - uses: PyO3/maturin-action@aef21716ff3dcae8a1c301d23ec3e4446972a6e3 # v1.49.1 + uses: PyO3/maturin-action@e10f6c464b90acceb5f640d31beda6d586ba7b4a # v1.49.3 with: target: ${{ matrix.target }} args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13 3.13t 3.14 3.14t pypy3.9 pypy3.10 pypy3.11' @@ -186,7 +186,7 @@ jobs: allow-prereleases: true architecture: ${{ matrix.target }} - name: Build wheels - uses: PyO3/maturin-action@aef21716ff3dcae8a1c301d23ec3e4446972a6e3 # v1.49.1 + uses: PyO3/maturin-action@e10f6c464b90acceb5f640d31beda6d586ba7b4a # v1.49.3 with: target: ${{ matrix.target }} args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13 3.14' --interpreter ${{ matrix.target == 'x64' && 'pypy3.9 pypy3.10' || '' }} @@ -244,7 +244,7 @@ jobs: .\rustup-init.exe -y Add-Content $env:GITHUB_PATH "$env:USERPROFILE\.cargo\bin" - name: Build wheels - uses: PyO3/maturin-action@aef21716ff3dcae8a1c301d23ec3e4446972a6e3 # v1.49.1 + uses: PyO3/maturin-action@e10f6c464b90acceb5f640d31beda6d586ba7b4a # v1.49.3 with: target: ${{ matrix.target }} args: --release --out dist --interpreter ${{ steps.cp311.outputs.python-path }} ${{ steps.cp312.outputs.python-path }} ${{ steps.cp313.outputs.python-path }} ${{ steps.cp314.outputs.python-path }} @@ -278,7 +278,7 @@ jobs: allow-prereleases: true architecture: ${{ matrix.target }} - name: Build wheels - uses: PyO3/maturin-action@aef21716ff3dcae8a1c301d23ec3e4446972a6e3 # v1.49.1 + uses: PyO3/maturin-action@e10f6c464b90acceb5f640d31beda6d586ba7b4a # v1.49.3 with: target: ${{ matrix.target }} args: --release --out dist --interpreter '3.13t 3.14t' @@ -318,7 +318,7 @@ jobs: pypy3.11 allow-prereleases: true - name: Build wheels - uses: PyO3/maturin-action@aef21716ff3dcae8a1c301d23ec3e4446972a6e3 # v1.49.1 + uses: PyO3/maturin-action@e10f6c464b90acceb5f640d31beda6d586ba7b4a # v1.49.3 with: target: ${{ matrix.target }} args: --release --out dist --interpreter '3.9 3.10 3.11 3.12 3.13 3.13t 3.14 3.14t pypy3.9 pypy3.10 pypy3.11' @@ -340,7 +340,7 @@ jobs: with: python-version: 3.13 - name: Build an sdist - uses: PyO3/maturin-action@aef21716ff3dcae8a1c301d23ec3e4446972a6e3 # v1.49.1 + uses: PyO3/maturin-action@e10f6c464b90acceb5f640d31beda6d586ba7b4a # v1.49.3 with: command: sdist args: --out dist @@ -368,7 +368,7 @@ jobs: pattern: dist-* merge-multiple: true - name: Publish to PyPI - uses: PyO3/maturin-action@aef21716ff3dcae8a1c301d23ec3e4446972a6e3 # v1.49.1 + uses: PyO3/maturin-action@e10f6c464b90acceb5f640d31beda6d586ba7b4a # v1.49.3 with: command: upload args: --non-interactive --skip-existing *