Skip to content

Commit 3008615

Browse files
authored
update stubs (#107)
1 parent 19c3a47 commit 3008615

File tree

8 files changed

+16
-38
lines changed

8 files changed

+16
-38
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ openssl = { version = "0.10", features = ["vendored"] }
1818
numpy = "0.25.0"
1919
unsafe_cell_slice = "0.2.0"
2020
serde_json = "1.0.128"
21-
pyo3-stub-gen = "0.9.1"
21+
pyo3-stub-gen = "0.12.2"
2222
opendal = { version = "0.53.0", features = ["services-http"] }
2323
tokio = { version = "1.41.1", features = ["rt-multi-thread"] }
2424
zarrs_opendal = "0.7.2"

hatch.toml

Lines changed: 0 additions & 13 deletions
This file was deleted.

python/zarrs/_internal.pyi

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
import builtins
55
import typing
6-
from enum import Enum
76

87
import numpy.typing
8+
import zarr.abc.store
99

1010
class Basic:
1111
def __new__(cls, byte_interface: typing.Any, chunk_spec: typing.Any) -> Basic: ...
@@ -14,7 +14,7 @@ class CodecPipelineImpl:
1414
def __new__(
1515
cls,
1616
array_metadata: builtins.str,
17-
store_config: StoreConfig,
17+
store_config: zarr.abc.store.Store,
1818
*,
1919
validate_checksums: builtins.bool | None = None,
2020
chunk_concurrent_minimum: builtins.int | None = None,
@@ -33,12 +33,6 @@ class CodecPipelineImpl:
3333
write_empty_chunks: builtins.bool,
3434
) -> None: ...
3535

36-
class FilesystemStoreConfig:
37-
root: builtins.str
38-
39-
class HttpStoreConfig:
40-
endpoint: builtins.str
41-
4236
class WithSubset:
4337
def __new__(
4438
cls,
@@ -48,6 +42,6 @@ class WithSubset:
4842
shape: typing.Sequence[builtins.int],
4943
) -> WithSubset: ...
5044

51-
class StoreConfig(Enum):
52-
Filesystem = ...
53-
Http = ...
45+
def codec_metadata_v2_to_v3(
46+
filters: typing.Sequence[builtins.str] | None, compressor: builtins.str | None
47+
) -> builtins.list[builtins.str]: ...

python/zarrs/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def make_chunk_info_for_rust_with_indices(
158158
],
159159
drop_axes: tuple[int, ...],
160160
shape: tuple[int, ...],
161-
) -> list[WithSubset]:
161+
) -> RustChunkInfo:
162162
shape = shape if shape else (1,) # constant array
163163
chunk_info_with_indices: list[WithSubset] = []
164164
write_empty_chunks: bool = True

src/metadata_v2.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use zarrs::metadata::{
55
};
66

77
#[pyfunction]
8+
#[pyo3_stub_gen::derive::gen_stub_pyfunction]
89
#[pyo3(signature = (filters=None, compressor=None))]
910
pub fn codec_metadata_v2_to_v3(
1011
filters: Option<Vec<String>>,

src/store.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use pyo3::{
66
types::{PyAnyMethods, PyStringMethods, PyTypeMethods},
77
Bound, FromPyObject, PyAny, PyErr, PyResult,
88
};
9-
use pyo3_stub_gen::derive::gen_stub_pyclass_enum;
109
use zarrs::storage::{
1110
storage_adapter::async_to_sync::AsyncToSyncStorageAdapter, ReadableWritableListableStorage,
1211
};
@@ -20,7 +19,6 @@ pub use self::filesystem::FilesystemStoreConfig;
2019
pub use self::http::HttpStoreConfig;
2120

2221
#[derive(Debug, Clone)]
23-
#[gen_stub_pyclass_enum]
2422
pub enum StoreConfig {
2523
Filesystem(FilesystemStoreConfig),
2624
Http(HttpStoreConfig),
@@ -60,6 +58,12 @@ impl<'py> FromPyObject<'py> for StoreConfig {
6058
}
6159
}
6260

61+
impl pyo3_stub_gen::PyStubType for StoreConfig {
62+
fn type_output() -> pyo3_stub_gen::TypeInfo {
63+
pyo3_stub_gen::TypeInfo::with_module("zarr.abc.store.Store", "zarr.abc.store".into())
64+
}
65+
}
66+
6367
impl TryFrom<&StoreConfig> for ReadableWritableListableStorage {
6468
type Error = PyErr;
6569

src/store/filesystem.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
use std::sync::Arc;
22

3-
use pyo3::{exceptions::PyRuntimeError, pyclass, PyErr};
4-
use pyo3_stub_gen::derive::gen_stub_pyclass;
3+
use pyo3::{exceptions::PyRuntimeError, PyErr};
54
use zarrs::{filesystem::FilesystemStore, storage::ReadableWritableListableStorage};
65

76
use crate::utils::PyErrExt;
87

98
#[derive(Debug, Clone)]
10-
#[gen_stub_pyclass]
11-
#[pyclass]
129
pub struct FilesystemStoreConfig {
13-
#[pyo3(get, set)]
1410
pub root: String,
1511
}
1612

src/store/http.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
use std::collections::HashMap;
22

3-
use pyo3::{exceptions::PyValueError, pyclass, Bound, PyAny, PyErr, PyResult};
4-
use pyo3_stub_gen::derive::gen_stub_pyclass;
3+
use pyo3::{exceptions::PyValueError, Bound, PyAny, PyErr, PyResult};
54
use zarrs::storage::ReadableWritableListableStorage;
65

76
use super::opendal_builder_to_sync_store;
87

98
#[derive(Debug, Clone)]
10-
#[gen_stub_pyclass]
11-
#[pyclass]
129
pub struct HttpStoreConfig {
13-
#[pyo3(get, set)]
1410
pub endpoint: String,
1511
}
1612

0 commit comments

Comments
 (0)