Skip to content

Commit 8043689

Browse files
committed
Fix typing errors
1 parent 14c6dcd commit 8043689

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

shelloracle/config/config.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import annotations
22

3-
from collections.abc import MutableMapping
3+
from collections.abc import MutableMapping, Iterator
44
from pathlib import Path
55
from typing import Any
66

@@ -43,7 +43,7 @@ def __delitem__(self, key: str) -> None:
4343
with self.filepath.open("w") as file:
4444
tomlkit.dump(config, file)
4545

46-
def __iter__(self) -> None:
46+
def __iter__(self) -> Iterator[str]:
4747
with self.filepath.open("r") as file:
4848
config = tomlkit.load(file)
4949
return iter(config)
@@ -62,7 +62,7 @@ def _ensure_config_exists(self) -> None:
6262
tomlkit.dump(config, file)
6363

6464
@property
65-
def provider(self) -> str | None:
65+
def provider(self) -> str:
6666
return self["shelloracle"]["provider"]
6767

6868

shelloracle/config/setting.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from . import config
66

77
if TYPE_CHECKING:
8-
from ..providers import Provider
8+
from ..provider import Provider
99

1010
T = TypeVar("T")
1111

shelloracle/provider.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class Provider(Protocol):
1616
name: str
1717

1818
@abstractmethod
19-
async def generate(self, prompt: str) -> AsyncIterator[str]:
19+
def generate(self, prompt: str) -> AsyncIterator[str]:
2020
"""
2121
This is an asynchronous generator method which defines the protocol that a provider implementation
2222
should adhere to. The method takes a prompt as an argument and produces an asynchronous stream
@@ -25,6 +25,8 @@ async def generate(self, prompt: str) -> AsyncIterator[str]:
2525
:param prompt: A string value which serves as input to the provider's process of generating results.
2626
:return: An asynchronous generator yielding string results.
2727
"""
28+
# If you are wondering why the 'generate' signature doesn't include 'async', see
29+
# https://mypy.readthedocs.io/en/stable/more_types.html#asynchronous-iterators
2830

2931

3032
def get_provider(name: str) -> type[Provider]:

shelloracle/shelloracle.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
async def prompt_user(default_prompt: str | None = None) -> str:
1717
with create_app_session_from_tty():
1818
history_file = Path.home() / ".shelloracle_history"
19-
prompt_session = PromptSession(history=FileHistory(str(history_file)))
19+
prompt_session: PromptSession = PromptSession(history=FileHistory(str(history_file)))
2020
# Can I do this with one of the builtin methods?
2121
# I tried a few (including cursor_down) with limited success
2222
prompt_session.output.write_raw("\033[E")

0 commit comments

Comments
 (0)