Skip to content

Commit

Permalink
fix: fix __eq__ bug caused by a PyO3 bug
Browse files Browse the repository at this point in the history
  • Loading branch information
wyfo committed Apr 24, 2024
1 parent 12fa1f6 commit ef5ca38
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/encoding.rs
Expand Up @@ -33,8 +33,9 @@ impl Encoding {
self.0.to_string()
}

fn __eq__(&self, #[pyo3(from_py_with = "encoding")] other: Encoding) -> bool {
self.0 == other.0
// Cannot use `#[pyo3(from_py_with = "...")]`, see https://github.com/PyO3/pyo3/issues/4113
fn __eq__(&self, other: &Bound<PyAny>) -> PyResult<bool> {
Ok(self.0 == Self::from_py(other)?.0)
}

#[classattr]
Expand Down
5 changes: 3 additions & 2 deletions src/key_expr.rs
Expand Up @@ -70,8 +70,9 @@ impl KeyExpr {
// self.0.clone().with_owned_parameters(parameters).into()
// }

fn __eq__(&self, #[pyo3(from_py_with = "KeyExpr::from_py")] other: KeyExpr) -> PyResult<bool> {
Ok(self.0 == other.0)
// Cannot use `#[pyo3(from_py_with = "...")]`, see https://github.com/PyO3/pyo3/issues/4113
fn __eq__(&self, other: &Bound<PyAny>) -> PyResult<bool> {
Ok(self.0 == Self::from_py(other)?.0)
}

fn __repr__(&self) -> String {
Expand Down

0 comments on commit ef5ca38

Please sign in to comment.