Skip to content

Commit

Permalink
Merge pull request #99 from johanols/changing-iterator-typing
Browse files Browse the repository at this point in the history
Changing return type of `__iter__` to `Iterator`.
  • Loading branch information
xhochy authored Nov 22, 2023
2 parents 38ab60f + 104ad9f commit 908efad
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
4 changes: 4 additions & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Changelog
*********

1.8.3
=====
* Changed `__iter__` return type to `Iterator`.

1.8.2
=====
* Include Python 3.12 in CI
Expand Down
4 changes: 2 additions & 2 deletions minimalkv/_key_value_store.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from io import BytesIO
from types import TracebackType
from typing import IO, Dict, Iterable, Iterator, List, Optional, Type, Union
from typing import IO, Dict, Iterator, List, Optional, Type, Union

from uritools import SplitResult

Expand Down Expand Up @@ -37,7 +37,7 @@ def __contains__(self, key: str) -> bool:
self._check_valid_key(key)
return self._has_key(key)

def __iter__(self) -> Iterable[str]:
def __iter__(self) -> Iterator[str]:
"""Iterate over all keys in the store.
Raises
Expand Down
8 changes: 4 additions & 4 deletions minimalkv/decorator.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from types import TracebackType
from typing import Iterable, Optional, Type
from typing import Iterable, Iterator, Optional, Type
from urllib.parse import quote_plus, unquote_plus

from minimalkv._key_value_store import KeyValueStore
Expand Down Expand Up @@ -36,7 +36,7 @@ def __getattr__(self, attr): # noqa D
def __contains__(self, key: str) -> bool: # noqa D
return self._dstore.__contains__(key)

def __iter__(self) -> Iterable[str]: # noqa D
def __iter__(self) -> Iterator[str]: # noqa D
return self._dstore.__iter__()

def close(self):
Expand Down Expand Up @@ -80,7 +80,7 @@ def _filter(self, key: str) -> bool:
def __contains__(self, key: str) -> bool: # noqa D
return self._map_key(key) in self._dstore

def __iter__(self) -> Iterable[str]: # noqa D
def __iter__(self) -> Iterator[str]: # noqa D
return self.iter_keys()

def delete(self, key: str): # noqa D
Expand All @@ -92,7 +92,7 @@ def get(self, key, *args, **kwargs): # noqa D
def get_file(self, key: str, *args, **kwargs): # noqa D
return self._dstore.get_file(self._map_key(key), *args, **kwargs)

def iter_keys(self, prefix: str = "") -> Iterable[str]: # noqa D
def iter_keys(self, prefix: str = "") -> Iterator[str]: # noqa D
return (
self._unmap_key(k)
for k in self._dstore.iter_keys(self._map_key_prefix(prefix))
Expand Down

0 comments on commit 908efad

Please sign in to comment.