Skip to content

Commit

Permalink
Fix type errors using pyright typeCheckingMode strict. (#161)
Browse files Browse the repository at this point in the history
* Fix type errors using pyright typeCheckingMode strict.

* Add missing arg types.
  • Loading branch information
Menziess authored Dec 2, 2024
1 parent b3e35cb commit 22998b7
Showing 1 changed file with 76 additions and 72 deletions.
148 changes: 76 additions & 72 deletions python/rocksdict/rocksdict.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from typing import Any, Union, List, Iterator, Tuple, Dict, overload, Callable
from __future__ import annotations

from types import TracebackType
from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Type, Union

__all__ = ["Rdict",
"RdictIter",
Expand Down Expand Up @@ -176,7 +179,7 @@ class Options:
def create_if_missing(self, create_if_missing: bool) -> None: ...
def create_missing_column_families(self, create_missing_cfs: bool) -> None: ...
def enable_statistics(self) -> None: ...
def get_statistics(self) -> Union[str, None]: ...
def get_statistics(self) -> Optional[str]: ...
def increase_parallelism(self, parallelism: int) -> None: ...
def optimize_for_point_lookup(self, cache_size: int) -> None: ...
def optimize_level_style_compaction(self, memtable_memory_budget: int) -> None: ...
Expand All @@ -194,11 +197,11 @@ class Options:
def set_compaction_readahead_size(self, compaction_readahead_size: int) -> None: ...
def set_compaction_style(self, style: DBCompactionStyle) -> None: ...
def set_compression_options(self, w_bits: int, level: int, strategy: int, max_dict_bytes: int) -> None: ...
def set_compression_per_level(self,level_types: list) -> None: ...
def set_compression_per_level(self, level_types: List[DBCompressionType]) -> None: ...
def set_compression_type(self, t: DBCompressionType) -> None: ...
def set_cuckoo_table_factory(self, factory: CuckooTableOptions) -> None: ...
def set_db_log_dir(self, path: str) -> None: ...
def set_db_paths(self, paths: list) -> None: ...
def set_db_paths(self, paths: List[DBPath]) -> None: ...
def set_db_write_buffer_size(self, size: int) -> None: ...
def set_delete_obsolete_files_period_micros(self, micros: int) -> None: ...
def set_disable_auto_compactions(self, disable: bool) -> None: ...
Expand All @@ -215,14 +218,14 @@ class Options:
def set_keep_log_file_num(self, nfiles: int) -> None: ...
def set_level_compaction_dynamic_level_bytes(self, v: bool) -> None: ...
def set_level_zero_file_num_compaction_trigger(self, n: int) -> None: ...
def set_level_zero_slowdown_writes_trigger(self, n_int) -> None: ...
def set_level_zero_slowdown_writes_trigger(self, n_int: int) -> None: ...
def set_level_zero_stop_writes_trigger(self, n: int) -> None: ...
def set_log_file_time_to_roll(self, secs: int) -> None: ...
def set_manifest_preallocation_size(self, size: int) -> None: ...
def set_max_background_jobs(self, jobs: int) -> None: ...
def set_max_bytes_for_level_base(self, size: int) -> None: ...
def set_max_bytes_for_level_multiplier(self, mul: float) -> None: ...
def set_max_bytes_for_level_multiplier_additional(self, level_values: list) -> None: ...
def set_max_bytes_for_level_multiplier_additional(self, level_values: List[int]) -> None: ...
def set_max_compaction_bytes(self, nbytes: int) -> None: ...
def set_max_file_opening_threads(self, nthreads: int) -> None: ...
def set_max_log_file_size(self, size: int) -> None: ...
Expand Down Expand Up @@ -358,9 +361,9 @@ class UniversalCompactOptions:

class UniversalCompactionStopStyle:
@classmethod
def __init__(cls, *args, **kwargs) -> None: ...
def similar(self, *args, **kwargs) -> None: ...
def total(self, *args, **kwargs) -> None: ...
def __init__(cls, *args: Any, **kwargs: Dict[Any, Any]) -> None: ...
def similar(self, *args: Any, **kwargs: Dict[Any, Any]) -> None: ...
def total(self, *args: Any, **kwargs: Dict[Any, Any]) -> None: ...

class WriteOptions:
@property
Expand All @@ -386,10 +389,47 @@ class WriteOptions:
def __init__(self) -> None: ...
def disable_wal(self, disable: bool) -> None: ...

class IngestExternalFileOptions:
def __init__(self) -> None: ...
def set_move_files(self, v: bool) -> None: ...
def set_snapshot_consistency(self, v: bool) -> None: ...
def set_allow_global_seqno(self, v: bool) -> None: ...
def set_allow_blocking_flush(self, v: bool) -> None: ...
def set_ingest_behind(self, v: bool) -> None: ...

class ColumnFamily: ...

class AccessType:
@staticmethod
def read_write() -> AccessType: ...
@staticmethod
def read_only(error_if_log_file_exist: bool = True) -> AccessType: ...
@staticmethod
def secondary(secondary_path: str) -> AccessType: ...
@staticmethod
def with_ttl(duration: int) -> AccessType: ...

class BottommostLevelCompaction:
@staticmethod
def skip() -> BottommostLevelCompaction: ...
@staticmethod
def if_have_compaction_filter() -> BottommostLevelCompaction: ...
@staticmethod
def force() -> BottommostLevelCompaction: ...
@staticmethod
def force_optimized() -> BottommostLevelCompaction: ...

class CompactOptions:
def __init__(self) -> None: ...
def set_exclusive_manual_compaction(self, v: bool) -> None: ...
def set_bottommost_level_compaction(self, lvl: BottommostLevelCompaction) -> None: ...
def set_change_level(self, v: bool) -> None: ...
def set_target_level(self, lvl: int) -> None: ...

class Rdict:
def __init__(self, path: str,
options: Union[Options, None] = None,
column_families: Union[Dict[str, Options], None] = None,
options: Optional[Options] = None,
column_families: Optional[Dict[str, Options]] = None,
access_type: AccessType = AccessType.read_write()) -> None: ...
def __enter__(self) -> Rdict: ...
def set_dumps(self, dumps: Callable[[Any], bytes]) -> None: ...
Expand All @@ -403,56 +443,56 @@ class Rdict:
def get(self,
key: Union[str, int, float, bytes, bool, List[Union[str, int, float, bytes, bool]]],
default: Any = None,
read_opt: Union[ReadOptions, None] = None) -> Any | None: ...
read_opt: Optional[ReadOptions] = None) -> Any | None: ...
def get_entity(self,
key: Union[str, int, float, bytes, bool, List[Union[str, int, float, bytes, bool]]],
default: Any = None,
read_opt: Union[ReadOptions, None] = None) -> List[Tuple[Any, Any]] | None: ...
read_opt: Optional[ReadOptions] = None) -> List[Tuple[Any, Any]] | None: ...
def put(self,
key: Union[str, int, float, bytes, bool],
value: Any,
write_opt: Union[WriteOptions, None] = None) -> None: ...
write_opt: Optional[WriteOptions] = None) -> None: ...
def put_entity(self,
key: Union[str, int, float, bytes, bool],
names: List[Any],
values: List[Any],
write_opt: Union[WriteOptions, None] = None) -> None: ...
def delete(self, key: Union[str, int, float, bytes, bool], write_opt: Union[WriteOptions, None] = None) -> None: ...
write_opt: Optional[WriteOptions] = None) -> None: ...
def delete(self, key: Union[str, int, float, bytes, bool], write_opt: Optional[WriteOptions] = None) -> None: ...
def key_may_exist(self,
key: Union[str, int, float, bytes, bool],
fetch: bool = False,
read_opt = None) -> Union[bool, Tuple[bool, Any]]: ...
def iter(self, read_opt: Union[ReadOptions, None] = None) -> RdictIter: ...
read_opt: Optional[ReadOptions] = None) -> Union[bool, Tuple[bool, Any]]: ...
def iter(self, read_opt: Optional[ReadOptions] = None) -> RdictIter: ...
def items(self, backwards: bool = False,
from_key: Union[str, int, float, bytes, bool, None] = None,
read_opt: Union[ReadOptions, None] = None) -> RdictItems: ...
read_opt: Optional[ReadOptions] = None) -> RdictItems: ...
def keys(self, backwards: bool = False,
from_key: Union[str, int, float, bytes, bool, None] = None,
read_opt: Union[ReadOptions, None] = None) -> RdictKeys: ...
read_opt: Optional[ReadOptions] = None) -> RdictKeys: ...
def values(self, backwards: bool = False,
from_key: Union[str, int, float, bytes, bool, None] = None,
read_opt: Union[ReadOptions, None] = None) -> RdictValues: ...
read_opt: Optional[ReadOptions] = None) -> RdictValues: ...
def columns(self, backwards: bool = False,
from_key: Union[str, int, float, bytes, bool, None] = None,
read_opt: Union[ReadOptions, None] = None) -> RdictColumns: ...
read_opt: Optional[ReadOptions] = None) -> RdictColumns: ...
def entities(self, backwards: bool = False,
from_key: Union[str, int, float, bytes, bool, None] = None,
read_opt: Union[ReadOptions, None] = None) -> RdictEntities: ...
read_opt: Optional[ReadOptions] = None) -> RdictEntities: ...
def ingest_external_file(self, paths: List[str], opts: IngestExternalFileOptions = IngestExternalFileOptions()) -> None: ...
def get_column_family(self, name: str) -> Rdict: ...
def get_column_family_handle(self, name: str) -> ColumnFamily: ...
def drop_column_family(self, name: str) -> None: ...
def create_column_family(self, name: str, options: Options = Options()) -> Rdict: ...
def write(self, write_batch: WriteBatch, write_opt: Union[WriteOptions, None] = None) -> None: ...
def write(self, write_batch: WriteBatch, write_opt: Optional[WriteOptions] = None) -> None: ...
def delete_range(self,
begin: Union[str, int, float, bytes, bool],
end: Union[str, int, float, bytes, bool],
write_opt: Union[WriteOptions, None] = None) -> None: ...
write_opt: Optional[WriteOptions] = None) -> None: ...
def snapshot(self) -> Snapshot: ...
def path(self) -> str: ...
def set_options(self, options: Dict[str, str]) -> None: ...
def property_value(self, name: str) -> Union[str, None]: ...
def property_int_value(self, name: str) -> Union[int, None]: ...
def property_value(self, name: str) -> Optional[str]: ...
def property_int_value(self, name: str) -> Optional[int]: ...
def latest_sequence_number(self) -> int: ...
def live_files(self) -> List[Dict[str, Any]]: ...
def compact_range(self, begin: Union[str, int, float, bytes, bool, None],
Expand All @@ -461,7 +501,7 @@ class Rdict:
def try_catch_up_with_primary(self) -> None: ...
def cancel_all_background(self, wait: bool) -> None: ...
def close(self) -> None: ...
def __exit__(self, exc_type, exc_val, exc_tb) -> None: ...
def __exit__(self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]) -> None: ...
def flush(self, wait: bool = True) -> None: ...
def flush_wal(self, sync: bool = True) -> None: ...
@staticmethod
Expand Down Expand Up @@ -504,14 +544,6 @@ class RdictIter:
def value(self) -> Any: ...
def columns(self) -> List[Tuple[Any, Any]]: ...

class IngestExternalFileOptions:
def __init__(self) -> None: ...
def set_move_files(self, v: bool) -> None: ...
def set_snapshot_consistency(self, v: bool) -> None: ...
def set_allow_global_seqno(self, v: bool) -> None: ...
def set_allow_blocking_flush(self, v: bool) -> None: ...
def set_ingest_behind(self, v: bool) -> None: ...

class SstFileWriter:
def __init__(self, options: Options = Options()) -> None: ...
def set_dumps(self, dumps: Callable[[Any], bytes]) -> None: ...
Expand All @@ -527,64 +559,36 @@ class WriteBatch:
def __setitem__(self, key: Union[str, int, float, bytes, bool], value: Any) -> None: ...
def __delitem__(self, key: Union[str, int, float, bytes, bool]) -> None: ...
def set_dumps(self, dumps: Callable[[Any], bytes]) -> None: ...
def set_default_column_family(self, column_family: Union[ColumnFamily, None]) -> None: ...
def set_default_column_family(self, column_family: Optional[ColumnFamily]) -> None: ...
def len(self) -> int: ...
def size_in_bytes(self) -> int: ...
def is_empty(self) -> bool: ...
def put(self, key: Union[str, int, float, bytes, bool], value: Any,
column_family: Union[ColumnFamily, None] = None) -> None: ...
column_family: Optional[ColumnFamily] = None) -> None: ...
def put_entity(self,
key: Union[str, int, float, bytes, bool],
names: List[Any],
values: List[Any]) -> None: ...
def delete(self, key: Union[str, int, float, bytes, bool],
column_family: Union[ColumnFamily, None] = None) -> None: ...
column_family: Optional[ColumnFamily] = None) -> None: ...
def delete_range(self, begin: Union[str, int, float, bytes, bool],
end: Union[str, int, float, bytes, bool],
column_family: Union[ColumnFamily, None] = None) -> None: ...
column_family: Optional[ColumnFamily] = None) -> None: ...
def clear(self) -> None: ...

class ColumnFamily: ...

class AccessType:
@staticmethod
def read_write() -> AccessType: ...
@staticmethod
def read_only(error_if_log_file_exist: bool = True) -> AccessType: ...
@staticmethod
def secondary(secondary_path: str) -> AccessType: ...
@staticmethod
def with_ttl(duration: int) -> AccessType: ...

class Snapshot:
def __getitem__(self, key: Union[str, int, float, bytes, bool]) -> Any: ...
def iter(self, read_opt: Union[ReadOptions, None] = None) -> RdictIter: ...
def iter(self, read_opt: Optional[ReadOptions] = None) -> RdictIter: ...
def items(self, backwards: bool = False,
from_key: Union[str, int, float, bytes, bool, None] = None,
read_opt: Union[ReadOptions, None] = None) -> RdictItems: ...
read_opt: Optional[ReadOptions] = None) -> RdictItems: ...
def keys(self, backwards: bool = False,
from_key: Union[str, int, float, bytes, bool, None] = None,
read_opt: Union[ReadOptions, None] = None) -> RdictKeys: ...
read_opt: Optional[ReadOptions] = None) -> RdictKeys: ...
def values(self, backwards: bool = False,
from_key: Union[str, int, float, bytes, bool, None] = None,
read_opt: Union[ReadOptions, None] = None) -> RdictValues: ...

class BottommostLevelCompaction:
@staticmethod
def skip() -> BottommostLevelCompaction: ...
@staticmethod
def if_have_compaction_filter() -> BottommostLevelCompaction: ...
@staticmethod
def force() -> BottommostLevelCompaction: ...
@staticmethod
def force_optimized() -> BottommostLevelCompaction: ...

class CompactOptions:
def __init__(self) -> None: ...
def set_exclusive_manual_compaction(self, v: bool) -> None: ...
def set_bottommost_level_compaction(self, lvl: BottommostLevelCompaction) -> None: ...
def set_change_level(self, v: bool) -> None: ...
def set_target_level(self, lvl: int) -> None: ...
read_opt: Optional[ReadOptions] = None) -> RdictValues: ...

class WriteBufferManager:
def __init__(self, buffer_size: int, allow_stall: bool) -> None: ...
Expand Down

0 comments on commit 22998b7

Please sign in to comment.