1111from __future__ import annotations
1212
1313import abc
14- from typing import TYPE_CHECKING , Any , ContextManager , List , Optional , Sequence , TypeVar , Union
14+ from collections .abc import Iterable
15+ from typing import TYPE_CHECKING , Any , ContextManager , List , Optional , TypeVar , Union
1516
1617if TYPE_CHECKING :
18+ from disk_objectstore .backup_utils import BackupManager
19+
1720 from aiida .manage .configuration .profile import Profile
1821 from aiida .orm .autogroup import AutogroupManager
1922 from aiida .orm .entities import EntityTypes
@@ -129,7 +132,7 @@ def version(self) -> str:
129132 return version
130133
131134 @abc .abstractmethod
132- def close (self ):
135+ def close (self ) -> None :
133136 """Close the storage access."""
134137
135138 @property
@@ -253,12 +256,12 @@ def delete(self) -> None:
253256 raise NotImplementedError ()
254257
255258 @abc .abstractmethod
256- def delete_nodes_and_connections (self , pks_to_delete : Sequence [int ]):
259+ def delete_nodes_and_connections (self , pks_to_delete : Iterable [int ]) -> None :
257260 """Delete all nodes corresponding to pks in the input and any links to/from them.
258261
259262 This method is intended to be used within a transaction context.
260263
261- :param pks_to_delete: a sequence of node pks to delete
264+ :param pks_to_delete: an iterable of node pks to delete
262265
263266 :raises: ``AssertionError`` if a transaction is not active
264267 """
@@ -269,7 +272,7 @@ def get_repository(self) -> 'AbstractRepositoryBackend':
269272
270273 @abc .abstractmethod
271274 def set_global_variable (
272- self , key : str , value : Union [None , str , int , float ], description : Optional [str ] = None , overwrite = True
275+ self , key : str , value : Union [None , str , int , float ], description : Optional [str ] = None , overwrite : bool = True
273276 ) -> None :
274277 """Set a global variable in the storage.
275278
@@ -291,7 +294,7 @@ def get_global_variable(self, key: str) -> Union[None, str, int, float]:
291294 """
292295
293296 @abc .abstractmethod
294- def maintain (self , full : bool = False , dry_run : bool = False , ** kwargs ) -> None :
297+ def maintain (self , full : bool = False , dry_run : bool = False , ** kwargs : Any ) -> None :
295298 """Perform maintenance tasks on the storage.
296299
297300 If `full == True`, then this method may attempt to block the profile associated with the
@@ -309,10 +312,10 @@ def _backup(
309312 self ,
310313 dest : str ,
311314 keep : Optional [int ] = None ,
312- ):
315+ ) -> None :
313316 raise NotImplementedError
314317
315- def _write_backup_config (self , backup_manager ) :
318+ def _write_backup_config (self , backup_manager : BackupManager ) -> None :
316319 import pathlib
317320 import tempfile
318321
@@ -338,7 +341,7 @@ def _write_backup_config(self, backup_manager):
338341 except (exceptions .MissingConfigurationError , exceptions .ConfigurationError ) as exc :
339342 raise exceptions .StorageBackupError ('AiiDA config.json not found!' ) from exc
340343
341- def _validate_or_init_backup_folder (self , dest , keep ) :
344+ def _validate_or_init_backup_folder (self , dest : str , keep : int | None ) -> BackupManager :
342345 import json
343346 import tempfile
344347
@@ -396,7 +399,7 @@ def backup(
396399 self ,
397400 dest : str ,
398401 keep : Optional [int ] = None ,
399- ):
402+ ) -> None :
400403 """Create a backup of the storage contents.
401404
402405 :param dest: The path to the destination folder.
@@ -440,15 +443,15 @@ def backup(
440443 STORAGE_LOGGER .report (f'Overwriting the `{ DEFAULT_CONFIG_FILE_NAME } file.' )
441444 self ._write_backup_config (backup_manager )
442445
443- def get_info (self , detailed : bool = False ) -> dict :
446+ def get_info (self , detailed : bool = False ) -> dict [ str , Any ] :
444447 """Return general information on the storage.
445448
446449 :param detailed: flag to request more detailed information about the content of the storage.
447450 :returns: a nested dict with the relevant information.
448451 """
449452 return {'entities' : self .get_orm_entities (detailed = detailed )}
450453
451- def get_orm_entities (self , detailed : bool = False ) -> dict :
454+ def get_orm_entities (self , detailed : bool = False ) -> dict [ str , Any ] :
452455 """Return a mapping with an overview of the storage contents regarding ORM entities.
453456
454457 :param detailed: flag to request more detailed information about the content of the storage.
0 commit comments