3232datajoint.gc : Garbage collection for orphaned storage items.
3333"""
3434
35+ from __future__ import annotations
36+
3537import base64
3638import hashlib
3739import logging
38- from typing import Any
40+ from typing import TYPE_CHECKING , Any
3941
4042from .errors import DataJointError
4143from .storage import StorageBackend
4244
45+ if TYPE_CHECKING :
46+ from .settings import Config
47+
4348logger = logging .getLogger (__name__ .split ("." )[0 ])
4449
4550
@@ -130,7 +135,7 @@ def build_hash_path(
130135 return f"_hash/{ schema_name } /{ content_hash } "
131136
132137
133- def get_store_backend (store_name : str | None = None , config = None ) -> StorageBackend :
138+ def get_store_backend (store_name : str | None = None , config : Config | None = None ) -> StorageBackend :
134139 """
135140 Get a StorageBackend for hash-addressed storage.
136141
@@ -147,13 +152,14 @@ def get_store_backend(store_name: str | None = None, config=None) -> StorageBack
147152 StorageBackend instance.
148153 """
149154 if config is None :
150- from .settings import config
155+ from .settings import config # type: ignore[assignment]
156+ assert config is not None
151157 # get_store_spec handles None by using stores.default
152158 spec = config .get_store_spec (store_name )
153159 return StorageBackend (spec )
154160
155161
156- def get_store_subfolding (store_name : str | None = None , config = None ) -> tuple [int , ...] | None :
162+ def get_store_subfolding (store_name : str | None = None , config : Config | None = None ) -> tuple [int , ...] | None :
157163 """
158164 Get the subfolding configuration for a store.
159165
@@ -170,7 +176,8 @@ def get_store_subfolding(store_name: str | None = None, config=None) -> tuple[in
170176 Subfolding pattern (e.g., (2, 2)) or None for flat storage.
171177 """
172178 if config is None :
173- from .settings import config
179+ from .settings import config # type: ignore[assignment]
180+ assert config is not None
174181 spec = config .get_store_spec (store_name )
175182 subfolding = spec .get ("subfolding" )
176183 if subfolding is not None :
@@ -182,7 +189,7 @@ def put_hash(
182189 data : bytes ,
183190 schema_name : str ,
184191 store_name : str | None = None ,
185- config = None ,
192+ config : Config | None = None ,
186193) -> dict [str , Any ]:
187194 """
188195 Store content using hash-addressed storage.
@@ -231,7 +238,7 @@ def put_hash(
231238 }
232239
233240
234- def get_hash (metadata : dict [str , Any ], config = None ) -> bytes :
241+ def get_hash (metadata : dict [str , Any ], config : Config | None = None ) -> bytes :
235242 """
236243 Retrieve content using stored metadata.
237244
@@ -275,7 +282,7 @@ def get_hash(metadata: dict[str, Any], config=None) -> bytes:
275282def delete_path (
276283 path : str ,
277284 store_name : str | None = None ,
278- config = None ,
285+ config : Config | None = None ,
279286) -> bool :
280287 """
281288 Delete content at the specified path from storage.
0 commit comments