Skip to content

Commit

Permalink
fix type hint for all pargs and kwargs to -> Any (#139)
Browse files Browse the repository at this point in the history
  • Loading branch information
hemidactylus authored Feb 8, 2024
1 parent 7a76a05 commit e53cae3
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 21 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ for wider testing. Then, with a slower cadence (such as, when releasing),
We are still at `0.*`. Occasional breaking changes are to be expected,
but please think carefully. Later, a stronger versioning model will be adopted.

### Style
### Style and typing

Style is enforced through `black` and linting with `ruff`. We also take
type-checking seriously. The code should run through `make format` without
issues.
Style is enforced through `black`, linting with `ruff`,
and typechecking with `mypy`.
The code should run through `make format` without issues.

### Python version coverage

Expand Down
2 changes: 1 addition & 1 deletion src/cassio/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ def check_resolve_keyspace(arg_keyspace: Optional[str] = None) -> str:
return s


def _first_valid(*pargs: Optional[Any]) -> Union[Any, None]:
def _first_valid(*pargs: Any) -> Union[Any, None]:
for entry in pargs:
if entry is not None:
return entry
Expand Down
2 changes: 1 addition & 1 deletion src/cassio/db_reader/multi_table_cassandra_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def dictionary_based_call(self, args_dict: Dict[str, Any]) -> Dict[str, Any]:
"""
return self(**args_dict)

def __call__(self, **kwargs: Dict[str, Any]) -> Dict[str, Any]:
def __call__(self, **kwargs: Any) -> Dict[str, Any]:
"""
Given the union of all the primary key fields from all tables involved,
run the necessary lookups, extracts the requested columns (or values,
Expand Down
6 changes: 2 additions & 4 deletions src/cassio/history/stored_blob_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import uuid
from warnings import warn
from typing import Any, Dict, Iterable, Optional
from typing import Any, Iterable, Optional

from cassandra.cluster import Session # type: ignore

Expand All @@ -30,9 +30,7 @@ class StoredBlobHistory:
"will be deprecated in future versions of CassIO."
)

def __init__(
self, session: Session, keyspace: str, table_name: str, **kwargs: Dict[str, Any]
):
def __init__(self, session: Session, keyspace: str, table_name: str, **kwargs: Any):
#
warn(self.DEPRECATION_MESSAGE, DeprecationWarning, stacklevel=2)
# specifications are added such as the type of the row_id
Expand Down
16 changes: 6 additions & 10 deletions src/cassio/table/base_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,7 @@ def _normalize_row(self, raw_row: Any) -> Dict[str, Any]:
#
return dict_row

def _delete(
self, is_async: bool, **kwargs: Dict[str, Any]
) -> Union[None, ResponseFuture]:
def _delete(self, is_async: bool, **kwargs: Any) -> Union[None, ResponseFuture]:
n_kwargs = self._normalize_kwargs(kwargs)
(
rest_kwargs,
Expand All @@ -160,12 +158,12 @@ def _delete(
self.execute_cql(delete_cql, args=delete_cql_vals, op_type=CQLOpType.WRITE)
return None

def delete(self, **kwargs: Dict[str, Any]) -> None:
def delete(self, **kwargs: Any) -> None:
self._ensure_db_setup()
self._delete(is_async=False, **kwargs)
return None

def delete_async(self, **kwargs: Dict[str, Any]) -> ResponseFuture:
def delete_async(self, **kwargs: Any) -> ResponseFuture:
self._ensure_db_setup()
return self._delete(is_async=True, **kwargs)

Expand Down Expand Up @@ -197,7 +195,7 @@ async def aclear(self) -> None:
await call_wrapped_async(self.clear_async)

def _parse_select_core_params(
self, **kwargs: Dict[str, Any]
self, **kwargs: Any
) -> Tuple[str, str, Tuple[Any, ...]]:
n_kwargs = self._normalize_kwargs(kwargs)
# TODO: work on a columns: Optional[List[str]] = None
Expand Down Expand Up @@ -256,7 +254,7 @@ def get(self, **kwargs: Any) -> Optional[RowType]:
)
return self._normalize_result_set(result_set)

def get_async(self, **kwargs: Dict[str, Any]) -> ResponseFuture:
def get_async(self, **kwargs: Any) -> ResponseFuture:
raise NotImplementedError("Asynchronous reads are not supported.")

async def aget(self, **kwargs: Any) -> Optional[RowType]:
Expand All @@ -268,9 +266,7 @@ async def aget(self, **kwargs: Any) -> Optional[RowType]:
)
return self._normalize_result_set(result_set)

def _put(
self, is_async: bool, **kwargs: Dict[str, Any]
) -> Union[None, ResponseFuture]:
def _put(self, is_async: bool, **kwargs: Any) -> Union[None, ResponseFuture]:
n_kwargs = self._normalize_kwargs(kwargs)
primary_key = self._schema_primary_key()
assert set(col for col, _ in primary_key) - set(n_kwargs.keys()) == set()
Expand Down
2 changes: 1 addition & 1 deletion src/cassio/vector/vector_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class VectorTable:
"will be deprecated in future versions of CassIO."
)

def __init__(self, *pargs: Any, **kwargs: Dict[str, Any]):
def __init__(self, *pargs: Any, **kwargs: Any):
#
warn(self.DEPRECATION_MESSAGE, DeprecationWarning, stacklevel=2)
#
Expand Down

0 comments on commit e53cae3

Please sign in to comment.