Skip to content

Commit

Permalink
review: Icxolu
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhewitt committed Mar 20, 2024
1 parent ac5af70 commit ae74999
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 20 deletions.
35 changes: 20 additions & 15 deletions pytests/src/pyclasses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,27 @@ impl AssertingBaseClass {
}
}

#[pyclass(subclass)]
#[derive(Clone, Debug)]
struct AssertingBaseClassGilRef;
#[allow(deprecated)]
mod deprecated {
use super::*;

#[pymethods]
impl AssertingBaseClassGilRef {
#[new]
#[classmethod]
fn new(cls: &PyType, expected_type: &Bound<'_, PyType>) -> PyResult<Self> {
if !cls.is(expected_type) {
return Err(PyValueError::new_err(format!(
"{:?} != {:?}",
cls, expected_type
)));
#[pyclass(subclass)]
#[derive(Clone, Debug)]
pub struct AssertingBaseClassGilRef;

#[pymethods]
impl AssertingBaseClassGilRef {
#[new]
#[classmethod]
fn new(cls: &PyType, expected_type: &PyType) -> PyResult<Self> {
if !cls.is(expected_type) {
return Err(PyValueError::new_err(format!(
"{:?} != {:?}",
cls, expected_type
)));
}
Ok(Self)
}
Ok(Self)
}
}

Expand All @@ -84,7 +89,7 @@ pub fn pyclasses(m: &Bound<'_, PyModule>) -> PyResult<()> {
m.add_class::<EmptyClass>()?;
m.add_class::<PyClassIter>()?;
m.add_class::<AssertingBaseClass>()?;
m.add_class::<AssertingBaseClassGilRef>()?;
m.add_class::<deprecated::AssertingBaseClassGilRef>()?;
m.add_class::<ClassWithoutConstructor>()?;
Ok(())
}
6 changes: 1 addition & 5 deletions tests/test_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,7 @@ struct ClassMethodWithArgs {}
impl ClassMethodWithArgs {
#[classmethod]
fn method(cls: &Bound<'_, PyType>, input: &Bound<'_, PyString>) -> PyResult<String> {
Ok(format!(
"{}.method({})",
cls.as_gil_ref().qualname()?,
input
))
Ok(format!("{}.method({})", cls.qualname()?, input))
}
}

Expand Down

0 comments on commit ae74999

Please sign in to comment.