Skip to content

Commit b04a926

Browse files
authored
feat: Add buffer and buffer_async aliases to GetResult (#489)
* test: Test against latest obspec 0.1 release * Add `buffer` and `buffer_async` aliases to `GetResult` * Use released obspec 0.1
1 parent 60146b7 commit b04a926

File tree

5 files changed

+28
-5
lines changed

5 files changed

+28
-5
lines changed

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ plugins:
165165
- https://azuresdkdocs.z19.web.core.windows.net/python/azure-identity/latest/objects.inv
166166
- https://boto3.amazonaws.com/v1/documentation/api/latest/objects.inv
167167
- https://botocore.amazonaws.com/v1/documentation/api/latest/objects.inv
168+
- https://developmentseed.org/obspec/latest/objects.inv
168169
- https://docs.aiohttp.org/en/stable/objects.inv
169170
- https://docs.pola.rs/api/python/stable/objects.inv
170171
- https://docs.python.org/3/objects.inv

obstore/python/obstore/_get.pyi

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,20 @@ class GetResult:
187187
memory by passing to [`bytes`][].
188188
"""
189189

190+
def buffer(self) -> Bytes:
191+
"""Collect the data into a `Bytes` object.
192+
193+
This is an alias of the [`bytes()`][obstore.GetResult.bytes] method to comply
194+
with the [`obspec.Get`][] protocol.
195+
"""
196+
197+
async def buffer_async(self) -> Bytes:
198+
"""Collect the data into a `Bytes` object.
199+
200+
This is an alias of the [`bytes_async()`][obstore.GetResult.bytes_async] method
201+
to comply with the [`obspec.GetAsync`][] protocol.
202+
"""
203+
190204
@property
191205
def meta(self) -> ObjectMeta:
192206
"""The ObjectMeta for this object."""

obstore/src/get.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,14 @@ impl PyGetResult {
177177
})
178178
}
179179

180+
fn buffer(&self, py: Python) -> PyObjectStoreResult<PyBytes> {
181+
self.bytes(py)
182+
}
183+
184+
fn buffer_async<'py>(&'py self, py: Python<'py>) -> PyResult<Bound<'py, PyAny>> {
185+
self.bytes_async(py)
186+
}
187+
180188
#[getter]
181189
fn attributes(&self) -> PyResult<PyAttributes> {
182190
Ok(PyAttributes::new(self.attributes.clone()))

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ dev-dependencies = [
2929
"mkdocstrings>=0.27.0",
3030
"moto[s3,server]>=5.1.1",
3131
"mypy>=1.15.0",
32-
"obspec>=0.1.0b6",
32+
"obspec>=0.1.0",
3333
"pip>=24.2",
3434
"polars>=1.30.0",
3535
"pyarrow>=17.0.0",

uv.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)