Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions python/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions python/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ async-tiff = { path = "../" }
bytes = "1.10.1"
futures = "0.3.31"
object_store = "0.12"
pyo3 = { version = "0.26.0", features = ["macros"] }
pyo3-async-runtimes = "0.26"
pyo3-bytes = "0.4"
pyo3-object_store = "0.6.0"
pyo3 = { version = "0.27.0", features = ["macros"] }
pyo3-async-runtimes = "0.27"
pyo3-bytes = "0.5"
pyo3-object_store = "0.7.0"
rayon = "1.11.0"
tokio-rayon = "2.1.0"
thiserror = "1"
Expand Down
10 changes: 6 additions & 4 deletions python/src/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,16 @@ impl PyDecoder {
}
}

impl<'py> FromPyObject<'py> for PyDecoder {
fn extract_bound(ob: &Bound<'py, PyAny>) -> PyResult<Self> {
if !ob.hasattr(intern!(ob.py(), "__call__"))? {
impl<'py> FromPyObject<'_, 'py> for PyDecoder {
type Error = PyErr;

fn extract(obj: Borrowed<'_, 'py, PyAny>) -> Result<Self, Self::Error> {
if !obj.hasattr(intern!(obj.py(), "__call__"))? {
return Err(PyTypeError::new_err(
"Expected callable object for custom decoder.",
));
}
Ok(Self(ob.clone().unbind()))
Ok(Self(obj.as_unbound().clone_ref(obj.py())))
}
}

Expand Down
8 changes: 5 additions & 3 deletions python/src/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ impl From<PyCompressionMethod> for CompressionMethod {
}
}

impl<'py> FromPyObject<'py> for PyCompressionMethod {
fn extract_bound(ob: &Bound<'py, PyAny>) -> PyResult<Self> {
Ok(Self(CompressionMethod::from_u16_exhaustive(ob.extract()?)))
impl<'py> FromPyObject<'_, 'py> for PyCompressionMethod {
type Error = PyErr;

fn extract(obj: Borrowed<'_, 'py, PyAny>) -> Result<Self, Self::Error> {
Ok(Self(CompressionMethod::from_u16_exhaustive(obj.extract()?)))
}
}

Expand Down
14 changes: 8 additions & 6 deletions python/src/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,15 @@ impl ObspecBackend {
}
}

impl<'py> FromPyObject<'py> for ObspecBackend {
fn extract_bound(ob: &Bound<'py, PyAny>) -> PyResult<Self> {
let py = ob.py();
if ob.hasattr(intern!(py, "get_range_async"))?
&& ob.hasattr(intern!(py, "get_ranges_async"))?
impl<'py> FromPyObject<'_, 'py> for ObspecBackend {
type Error = PyErr;

fn extract(obj: Borrowed<'_, 'py, PyAny>) -> Result<Self, Self::Error> {
let py = obj.py();
if obj.hasattr(intern!(py, "get_range_async"))?
&& obj.hasattr(intern!(py, "get_ranges_async"))?
{
Ok(Self(ob.clone().unbind()))
Ok(Self(obj.as_unbound().clone_ref(py)))
} else {
Err(PyTypeError::new_err("Expected obspec-compatible class with `get_range_async` and `get_ranges_async` method."))
}
Expand Down