Skip to content

Commit 1be410b

Browse files
authored
Don't import from tests (#1601)
* fix: move DummyStorageTransformer to zarr, and import it from tests instead of the other way around * test: tests use relative imports instead of importing from zarr.test * docs: release notes * docs: add new section for unreleased v3 work * docs: add heading to v3 release notes
1 parent 1a98886 commit 1be410b

14 files changed

+59
-34
lines changed

docs/release.rst

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,22 @@ Release notes
1313
# to document your changes. On releases it will be
1414
# re-indented so that it does not show up in the notes.
1515
16+
.. _unreleased(v3):
17+
18+
Unreleased (v3)
19+
---------------
20+
21+
Maintenance
22+
~~~~~~~~~~~
23+
24+
* Remedy a situation where ``zarr-python`` was importing ``DummyStorageTransformer`` from the test suite.
25+
The dependency relationship is now reversed: the test suite imports this class from ``zarr-python``.
26+
By :user:`Davis Bennett <d-v-b>` :issue:`1601`.
27+
1628
.. _unreleased:
1729

18-
Unreleased
19-
----------
30+
Unreleased (v2)
31+
---------------
2032

2133
Docs
2234
~~~~
@@ -61,7 +73,6 @@ Maintenance
6173
* Remove ``sphinx-rtd-theme`` dependency from ``pyproject.toml``.
6274
By :user:`Sanket Verma <MSanKeys963>` :issue:`1563`.
6375

64-
6576
.. _release_2.16.1:
6677

6778
2.16.1

zarr/_storage/v3_storage_transformers.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,22 @@ def create_empty(cls, store: "ShardingStorageTransformer"):
8181
)
8282

8383

84+
class DummyStorageTransfomer(StorageTransformer):
85+
"""For testing purposes. This class was previously defined in the test suite and imported
86+
into Zarr, but now it has been moved here and the test suite will import it like any other part
87+
of the Zarr library."""
88+
89+
TEST_CONSTANT = "test1234"
90+
91+
extension_uri = "https://purl.org/zarr/spec/storage_transformers/dummy/1.0"
92+
valid_types = ["dummy_type"]
93+
94+
def __init__(self, _type, test_value) -> None:
95+
super().__init__(_type)
96+
assert test_value == self.TEST_CONSTANT
97+
self.test_value = test_value
98+
99+
84100
class ShardingStorageTransformer(StorageTransformer): # lgtm[py/missing-equals]
85101
"""Implements sharding as a storage transformer, as described in the spec:
86102
https://zarr-specs.readthedocs.io/en/latest/extensions/storage-transformers/sharding/v1.0.html

zarr/meta.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,8 +459,10 @@ def _encode_storage_transformer_metadata(
459459

460460
@classmethod
461461
def _decode_storage_transformer_metadata(cls, meta: Mapping) -> "StorageTransformer":
462-
from zarr.tests.test_storage_v3 import DummyStorageTransfomer
463-
from zarr._storage.v3_storage_transformers import ShardingStorageTransformer
462+
from zarr._storage.v3_storage_transformers import (
463+
ShardingStorageTransformer,
464+
DummyStorageTransfomer,
465+
)
464466

465467
# This might be changed to a proper registry in the future
466468
KNOWN_STORAGE_TRANSFORMERS = [DummyStorageTransfomer, ShardingStorageTransformer]

zarr/tests/test_attrs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from zarr.attrs import Attributes
99
from zarr.storage import KVStore, DirectoryStore
1010
from zarr._storage.v3 import KVStoreV3
11-
from zarr.tests.util import CountingDict, CountingDictV3
11+
from .util import CountingDict, CountingDictV3
1212
from zarr.hierarchy import group
1313

1414

zarr/tests/test_convenience.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
MemoryStoreV3,
4444
SQLiteStoreV3,
4545
)
46-
from zarr.tests.util import have_fsspec
46+
from .util import have_fsspec
4747

4848
_VERSIONS = (2, 3) if v3_api_available else (2,)
4949

zarr/tests/test_core.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@
3535
BaseStore,
3636
v3_api_available,
3737
)
38-
from .._storage.v3_storage_transformers import ShardingStorageTransformer, v3_sharding_available
38+
from .._storage.v3_storage_transformers import (
39+
DummyStorageTransfomer,
40+
ShardingStorageTransformer,
41+
v3_sharding_available,
42+
)
3943
from zarr.core import Array
4044
from zarr.errors import ArrayNotFoundError, ContainsGroupError
4145
from zarr.meta import json_loads
@@ -70,9 +74,9 @@
7074
SQLiteStoreV3,
7175
StoreV3,
7276
)
73-
from zarr.tests.test_storage_v3 import DummyStorageTransfomer
77+
7478
from zarr.util import buffer_size
75-
from zarr.tests.util import abs_container, skip_test_env_var, have_fsspec, mktemp
79+
from .util import abs_container, skip_test_env_var, have_fsspec, mktemp
7680

7781
# noinspection PyMethodMayBeStatic
7882

zarr/tests/test_creation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from numpy.testing import assert_array_equal
99

1010
from zarr._storage.store import DEFAULT_ZARR_VERSION
11+
from zarr._storage.v3_storage_transformers import DummyStorageTransfomer
1112
from zarr.codecs import Zlib
1213
from zarr.core import Array
1314
from zarr.creation import (
@@ -30,8 +31,7 @@
3031
from zarr._storage.store import v3_api_available
3132
from zarr._storage.v3 import DirectoryStoreV3, KVStoreV3
3233
from zarr.sync import ThreadSynchronizer
33-
from zarr.tests.test_storage_v3 import DummyStorageTransfomer
34-
from zarr.tests.util import mktemp, have_fsspec
34+
from .util import mktemp, have_fsspec
3535

3636

3737
_VERSIONS = (None, 2, 3) if v3_api_available else (None, 2)

zarr/tests/test_dim_separator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import zarr
88
from zarr.core import Array
99
from zarr.storage import DirectoryStore, NestedDirectoryStore, FSStore
10-
from zarr.tests.util import have_fsspec
10+
from .util import have_fsspec
1111

1212

1313
needs_fsspec = pytest.mark.skipif(not have_fsspec, reason="needs fsspec")

zarr/tests/test_hierarchy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
LRUStoreCacheV3,
5858
)
5959
from zarr.util import InfoReporter, buffer_size
60-
from zarr.tests.util import skip_test_env_var, have_fsspec, abs_container, mktemp
60+
from .util import skip_test_env_var, have_fsspec, abs_container, mktemp
6161

6262

6363
_VERSIONS = (2, 3) if v3_api_available else (2,)

zarr/tests/test_indexing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
PartialChunkIterator,
1414
)
1515

16-
from zarr.tests.util import CountingDict
16+
from .util import CountingDict
1717

1818

1919
def test_normalize_integer_selection():

0 commit comments

Comments
 (0)