Myre mypy fixes.
authorScott <[email protected]>
Tue, 1 Feb 2022 05:38:46 +0000 (21:38 -0800)
committerScott <[email protected]>
Tue, 1 Feb 2022 05:38:46 +0000 (21:38 -0800)
config.py
google_assistant.py
string_utils.py

index f543b0aab2ed1c2a72760b934c813426426df3a8..588b7e072006d6d27cbf115e7220f9e40b6cc706 100644 (file)
--- a/config.py
+++ b/config.py
@@ -80,8 +80,8 @@ from typing import Any, Dict, List, Optional
 saved_messages: List[str] = []
 
 # Make a copy of the original program arguments.
-program_name = os.path.basename(sys.argv[0])
-original_argv = [arg for arg in sys.argv]
+program_name: str = os.path.basename(sys.argv[0])
+original_argv: List[str] = [arg for arg in sys.argv]
 
 
 # A global parser that we will collect arguments into.
@@ -101,7 +101,7 @@ config_parse_called = False
 # It is also this variable that modules use to access parsed arguments.
 # This is the data that is most interesting to our callers; it will hold
 # the configuration result.
-config = {}
+config: Dict[str, Any] = {}
 # It would be really nice if this shit worked from interactive python
 
 
@@ -154,11 +154,12 @@ def is_flag_already_in_argv(var: str):
 
 
 def reorder_arg_action_groups(entry_module: Optional[str]):
+    global program_name, args
     reordered_action_groups = []
     for group in args._action_groups:
-        if entry_module is not None and entry_module in group.title:
+        if entry_module is not None and entry_module in group.title:  # type: ignore
             reordered_action_groups.append(group)
-        elif program_name in group.title:
+        elif program_name in group.title:  # type: ignore
             reordered_action_groups.append(group)
         else:
             reordered_action_groups.insert(0, group)
index b92f443d6744882ddaa56418ed992b39b33c8568..0af4fa9271df3bf2e6de6f3571cfa6c2eb6d1f23 100644 (file)
@@ -1,8 +1,8 @@
 #!/usr/bin/env python3
 
 import logging
-from typing import NamedTuple
 import sys
+from typing import NamedTuple, Optional
 import warnings
 
 import requests
@@ -36,7 +36,7 @@ class GoogleResponse(NamedTuple):
     success: bool
     response: str
     audio_url: str
-    audio_transcription: str
+    audio_transcription: Optional[str]  # None if not available.
 
     def __repr__(self):
         return f"""
@@ -67,7 +67,7 @@ def ask_google(cmd: str, *, recognize_speech=True) -> GoogleResponse:
     success = False
     response = ""
     audio = ""
-    audio_transcription = ""
+    audio_transcription: Optional[str] = ""
     if r.status_code == 200:
         j = r.json()
         success = bool(j["success"])
index 991793d96ad1bf27e503ca2ae673b1b93211e25d..9a204660432693032c6dfef79722714d1e133a65 100644 (file)
@@ -1095,7 +1095,7 @@ def to_date(in_str: str) -> Optional[datetime.date]:
     """
     Parses a date string.  See DateParser docs for details.
     """
-    import dateparse.dateparse_utils as dp
+    import dateparse.dateparse_utils as dp  # type: ignore
 
     try:
         d = dp.DateParser()