Skip to content

Commit

Permalink
added type hints, docstring changes
Browse files Browse the repository at this point in the history
  • Loading branch information
znarfm committed Nov 19, 2024
1 parent 628fbab commit b520cbb
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion bing_rewards/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,19 @@
import bing_rewards.options as app_options


def word_generator() -> Generator[str]:
def word_generator() -> Generator[str, None, None]:
"""Infinitely generate terms from the word file.
Starts reading from a random position in the file.
If end of file is reached, close and restart.
Handles file operations safely and ensures uniform random distribution.
Yields:
str: A random keyword from the file, stripped of whitespace.
Raises:
FileNotFoundError: If the keywords file cannot be found.
IOError: If there are issues reading the file.
"""
word_data = resources.files('bing_rewards').joinpath('data', 'keywords.txt')
while True:
Expand Down

0 comments on commit b520cbb

Please sign in to comment.