Change return types from Iterable to Iterator

This commit is contained in:
Joakim Soderlund 2018-03-03 21:33:21 +01:00
parent 0587144a5d
commit 9d9c3e05e3
2 changed files with 6 additions and 6 deletions

View file

@ -25,7 +25,7 @@ Directory fetcher.
import json
from itertools import chain
from pathlib import Path
from typing import Any, Dict, Iterable, Optional, Set
from typing import Any, Dict, Iterable, Iterator, Optional, Set
from fimfarchive.exceptions import InvalidStoryError, StorySourceError
from fimfarchive.flavors import Flavor
@ -64,7 +64,7 @@ class DirectoryFetcher(Fetcher):
self.data_path = data_path
self.flavors = frozenset(flavors)
def iter_path_keys(self, path: Optional[Path]) -> Iterable[int]:
def iter_path_keys(self, path: Optional[Path]) -> Iterator[int]:
"""
Yields all story keys found in the specified directory.
@ -113,7 +113,7 @@ class DirectoryFetcher(Fetcher):
"""
return len(self.list_keys())
def __iter__(self) -> Iterable[Story]:
def __iter__(self) -> Iterator[Story]:
"""
Yields all stories in the directories, ordered by ID.
"""

View file

@ -23,7 +23,7 @@ Fimfarchive fetcher.
import json
from typing import cast, Any, Dict, IO, Iterable, Optional, Tuple, Union
from typing import cast, Any, Dict, IO, Iterator, Optional, Tuple, Union
from zipfile import ZipFile, BadZipFile
from boltons.cacheutils import LRU
@ -107,7 +107,7 @@ class FimfarchiveFetcher(Fetcher):
self.paths = LRU()
self.is_open = True
def load_index(self, source: IO[bytes]) -> Iterable[Tuple[int, str]]:
def load_index(self, source: IO[bytes]) -> Iterator[Tuple[int, str]]:
"""
Yields unparsed index items from a byte stream.
@ -147,7 +147,7 @@ class FimfarchiveFetcher(Fetcher):
"""
return len(self.index)
def __iter__(self) -> Iterable[Story]:
def __iter__(self) -> Iterator[Story]:
"""
Yields all stories in the archive, ordered by ID.
"""