Skip to content

Commit cd93c19

Browse files
kushalbakshiclaude
andcommitted
style: fix ruff E402 and ruff-format violations
Move imports to top of file and apply ruff-format to satisfy CI. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 53b5002 commit cd93c19

File tree

3 files changed

+19
-26
lines changed

3 files changed

+19
-26
lines changed

src/datajoint/storage.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -372,9 +372,7 @@ def _create_filesystem(self) -> fsspec.AbstractFileSystem:
372372

373373
adapter = get_storage_adapter(self.protocol)
374374
if adapter is None:
375-
raise errors.DataJointError(
376-
f"Unsupported storage protocol: {self.protocol}"
377-
)
375+
raise errors.DataJointError(f"Unsupported storage protocol: {self.protocol}")
378376
return adapter.create_filesystem(self.spec)
379377

380378
def _full_path(self, path: str | PurePosixPath) -> str:

src/datajoint/storage_adapter.py

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,11 @@ def validate_spec(self, spec: dict[str, Any]) -> None:
4141
"""Validate protocol-specific config fields."""
4242
missing = [k for k in self.required_keys if k not in spec]
4343
if missing:
44-
raise errors.DataJointError(
45-
f'{self.protocol} store is missing: {", ".join(missing)}'
46-
)
44+
raise errors.DataJointError(f'{self.protocol} store is missing: {", ".join(missing)}')
4745
all_allowed = set(self.allowed_keys) | _COMMON_STORE_KEYS
4846
invalid = [k for k in spec if k not in all_allowed]
4947
if invalid:
50-
raise errors.DataJointError(
51-
f'Invalid key(s) for {self.protocol}: {", ".join(invalid)}'
52-
)
48+
raise errors.DataJointError(f'Invalid key(s) for {self.protocol}: {", ".join(invalid)}')
5349

5450
def full_path(self, spec: dict[str, Any], relpath: str) -> str:
5551
"""Construct storage path from a relative path."""
@@ -61,17 +57,19 @@ def get_url(self, spec: dict[str, Any], path: str) -> str:
6157
return f"{self.protocol}://{path}"
6258

6359

64-
_COMMON_STORE_KEYS = frozenset({
65-
"protocol",
66-
"location",
67-
"subfolding",
68-
"partition_pattern",
69-
"token_length",
70-
"hash_prefix",
71-
"schema_prefix",
72-
"filepath_prefix",
73-
"stage",
74-
})
60+
_COMMON_STORE_KEYS = frozenset(
61+
{
62+
"protocol",
63+
"location",
64+
"subfolding",
65+
"partition_pattern",
66+
"token_length",
67+
"hash_prefix",
68+
"schema_prefix",
69+
"filepath_prefix",
70+
"stage",
71+
}
72+
)
7573

7674
_adapter_registry: dict[str, StorageAdapter] = {}
7775
_adapters_loaded: bool = False

tests/unit/test_storage_adapter.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
import pytest
44

5+
import datajoint as dj
56
from datajoint.errors import DataJointError
7+
from datajoint.storage import StorageBackend
68
from datajoint.storage_adapter import (
79
StorageAdapter,
810
_adapter_registry,
@@ -105,11 +107,9 @@ def test_default_url_format(self):
105107
assert self.adapter.get_url({}, "data/file.dat") == "dummy://data/file.dat"
106108

107109

108-
from datajoint.storage import StorageBackend
109-
110-
111110
class _FakeFS:
112111
"""Minimal fake fsspec filesystem for testing."""
112+
113113
protocol = "dummy"
114114

115115

@@ -178,9 +178,6 @@ def test_unsupported_protocol_error(self):
178178
backend._create_filesystem()
179179

180180

181-
import datajoint as dj
182-
183-
184181
class TestGetStoreSpecPluginDelegation:
185182
"""Tests for plugin protocol handling in Config.get_store_spec()."""
186183

0 commit comments

Comments
 (0)