Skip to content

Commit e4f3768

Browse files
authored
Add missing type hints to Library and fix append return type (#2574)
#### What does this implement or fix? Adds missing type hints for return types of public methods of `Library` class. Also fixes the return type of `append` (previously `Optional[VersionedItem]`, presumably copy-pasted from `NativeVersionStore`, but it is only `None` if data is being staged, which isn't possible in the V2 version of `append`)
1 parent 724dc79 commit e4f3768

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

python/arcticdb/version_store/library.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,7 @@ def __init__(self, arctic_instance_description: str, nvs: NativeVersionStore):
780780
self._nvs._normalizer.df.set_skip_df_consolidation()
781781
self._dev_tools = DevTools(nvs)
782782

783-
def __repr__(self):
783+
def __repr__(self) ->str:
784784
return "Library(%s, path=%s, storage=%s)" % (
785785
self.arctic_instance_desc,
786786
self._nvs._lib_cfg.lib_desc.name,
@@ -790,7 +790,7 @@ def __repr__(self):
790790
def __getitem__(self, symbol: str) -> VersionedItem:
791791
return self.read(symbol)
792792

793-
def __contains__(self, symbol: str):
793+
def __contains__(self, symbol: str) -> bool:
794794
return self.has_symbol(symbol)
795795

796796
def options(self) -> LibraryOptions:
@@ -818,7 +818,7 @@ def stage(
818818
validate_index=True,
819819
sort_on_index=False,
820820
sort_columns: List[str] = None,
821-
):
821+
) -> None:
822822
"""
823823
Write a staged data chunk to storage, that will not be visible until finalize_staged_data is called on
824824
the symbol. Equivalent to write() with staged=True.
@@ -1157,7 +1157,7 @@ def append(
11571157
metadata: Any = None,
11581158
prune_previous_versions: bool = False,
11591159
validate_index: bool = True,
1160-
) -> Optional[VersionedItem]:
1160+
) -> VersionedItem:
11611161
"""
11621162
Appends the given data to the existing, stored data. Append always appends along the index. A new version will
11631163
be created to reference the newly-appended data. Append only accepts data for which the index of the first
@@ -1477,7 +1477,7 @@ def update_batch(
14771477
)
14781478
return batch_update_result
14791479

1480-
def delete_staged_data(self, symbol: str):
1480+
def delete_staged_data(self, symbol: str) -> None:
14811481
"""
14821482
Removes staged data.
14831483
@@ -2311,7 +2311,7 @@ def snapshot(
23112311
self._nvs.version_store.verify_snapshot(snapshot_name)
23122312
self._nvs.snapshot(snap_name=snapshot_name, metadata=metadata, skip_symbols=skip_symbols, versions=versions)
23132313

2314-
def delete(self, symbol: str, versions: Optional[Union[int, Iterable[int]]] = None):
2314+
def delete(self, symbol: str, versions: Optional[Union[int, Iterable[int]]] = None) -> None:
23152315
"""
23162316
Delete all versions of the symbol from the library, unless ``version`` is specified, in which case only those
23172317
versions are deleted.
@@ -2379,7 +2379,7 @@ def delete_batch(self, delete_requests: List[Union[str, DeleteRequest]]) -> List
23792379

23802380
return self._nvs.version_store.batch_delete(symbols, versions)
23812381

2382-
def prune_previous_versions(self, symbol):
2382+
def prune_previous_versions(self, symbol) -> None:
23832383
"""Removes all (non-snapshotted) versions from the database for the given symbol, except the latest.
23842384
23852385
Parameters
@@ -2394,7 +2394,7 @@ def delete_data_in_range(
23942394
symbol: str,
23952395
date_range: Tuple[Optional[Timestamp], Optional[Timestamp]],
23962396
prune_previous_versions: bool = False,
2397-
):
2397+
) -> None:
23982398
"""Delete data within the given date range, creating a new version of ``symbol``.
23992399
24002400
The existing symbol version must be timeseries-indexed.
@@ -2781,7 +2781,7 @@ def get_description_batch(
27812781

27822782
return description_results
27832783

2784-
def reload_symbol_list(self):
2784+
def reload_symbol_list(self) -> None:
27852785
"""
27862786
Forces the symbol list cache to be reloaded.
27872787
@@ -2900,11 +2900,11 @@ def defragment_symbol_data(
29002900
return self._nvs.defragment_symbol_data(symbol, segment_size, prune_previous_versions)
29012901

29022902
@property
2903-
def name(self):
2903+
def name(self) -> str:
29042904
"""The name of this library."""
29052905
return self._nvs.name()
29062906

2907-
def admin_tools(self):
2907+
def admin_tools(self) -> AdminTools:
29082908
"""Administrative utilities that operate on this library."""
29092909
return AdminTools(self._nvs)
29102910

0 commit comments

Comments
 (0)