added typ hints for all functions in 'main.py', 'utils.py', 'storage.py' and 'api_client.py'

This commit is contained in:
2023-08-15 23:36:45 +02:00
parent ba41794f4e
commit 4303fb414f
4 changed files with 39 additions and 26 deletions
+6 -4
View File
@@ -1,14 +1,16 @@
import shutil
from pprint import PrettyPrinter
from typing import Any
ConfigType = dict[str, str | dict[str, str | int | float]]
ChatType = list[dict[str, str]]
def terminal_width() -> int:
return shutil.get_terminal_size().columns
def pp(*args, **kwargs) -> None:
def pp(*args: Any, **kwargs: Any) -> None:
return PrettyPrinter(width=terminal_width()).pprint(*args, **kwargs)
@@ -30,7 +32,7 @@ def print_tag_args(tags: list[str], extags: list[str], otags: list[str]) -> None
print()
def append_message(chat: list[dict[str, str]],
def append_message(chat: ChatType,
role: str,
content: str
) -> None:
@@ -38,7 +40,7 @@ def append_message(chat: list[dict[str, str]],
def message_to_chat(message: dict[str, str],
chat: list[dict[str, str]],
chat: ChatType,
with_tags: bool = False,
with_file: bool = False
) -> None:
@@ -61,7 +63,7 @@ def display_source_code(content: str) -> None:
pass
def print_chat_hist(chat, dump=False, source_code=False) -> None:
def print_chat_hist(chat: ChatType, dump: bool = False, source_code: bool = False) -> None:
if dump:
pp(chat)
return