Add mypy to check, code cleanup
This commit is contained in:
@@ -81,9 +81,7 @@ g2p: $(G2P_MODELS)
|
||||
# Testing
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
mypy:
|
||||
mypy app.py rhasspy
|
||||
|
||||
check:
|
||||
flake8 --exclude=lexconvert.py app.py test.py rhasspy/*.py
|
||||
pylint --ignore=lexconvert.py app.py test.py rhasspy/*.py
|
||||
mypy app.py test.py rhasspy/*.py
|
||||
|
||||
@@ -72,6 +72,9 @@ ignore_missing_imports = True
|
||||
[mypy-json5.*]
|
||||
ignore_missing_imports = True
|
||||
|
||||
[mypy-quart.*]
|
||||
ignore_missing_imports = True
|
||||
|
||||
[mypy-quart_cors.*]
|
||||
ignore_missing_imports = True
|
||||
|
||||
|
||||
+1
-1
@@ -768,7 +768,7 @@ class DialogueManager(RhasspyActor):
|
||||
chunk_size = int(self.profile.get(test_path, 1024))
|
||||
|
||||
assert recorder_class is not None
|
||||
test_mics = recorder_class.test_microphones(chunk_size)
|
||||
test_mics = recorder_class.test_microphones(chunk_size) # type: ignore
|
||||
self.send(sender, test_mics)
|
||||
elif isinstance(message, GetSpeakers):
|
||||
# Get all speakers
|
||||
|
||||
@@ -517,6 +517,7 @@ class AdaptIntentRecognizer(RhasspyActor):
|
||||
def load_engine(self) -> None:
|
||||
"""Configure Adapt engine if not already cached."""
|
||||
if self.engine is None:
|
||||
# pylint: disable=E0401
|
||||
from adapt.intent import IntentBuilder
|
||||
from adapt.engine import IntentDeterminationEngine
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
# and on Bitbucket https://bitbucket.org/ssb22/lexconvert
|
||||
# although some early ones are missing.
|
||||
|
||||
# type: ignore
|
||||
|
||||
def Phonemes():
|
||||
"""Create phonemes by calling vowel(), consonant(),
|
||||
@@ -305,9 +306,9 @@ def LexFormats():
|
||||
lex_header=";; -*- mode: lisp -*-\n(eval (list voice_default))\n",
|
||||
lex_read_function=lambda *args: eval(
|
||||
"["
|
||||
+ commands.getoutput(
|
||||
"grep -vi parameter.set < ~/.festivalrc | grep -v '(eval' | sed -e 's/;.*//' -e 's/.lex.add.entry//' -e s/\"'\"'[(] *\"/[\"/' -e 's/\" [^ ]* /\",(\"/' -e 's/\".*$/&\"],/' -e 's/[()]/ /g' -e 's/ */ /g'"
|
||||
)
|
||||
# + commands.getoutput(
|
||||
# "grep -vi parameter.set < ~/.festivalrc | grep -v '(eval' | sed -e 's/;.*//' -e 's/.lex.add.entry//' -e s/\"'\"'[(] *\"/[\"/' -e 's/\" [^ ]* /\",(\"/' -e 's/\".*$/&\"],/' -e 's/[()]/ /g' -e 's/ */ /g'"
|
||||
# )
|
||||
+ "]"
|
||||
),
|
||||
safe_to_drop_characters=True, # TODO: really? (could instead give a string of known-safe characters)
|
||||
@@ -3317,7 +3318,7 @@ def make_dictionary(sourceName, destName):
|
||||
return d
|
||||
|
||||
|
||||
warnedAlready = set()
|
||||
warnedAlready = set() # type: ignore
|
||||
|
||||
|
||||
def convert(pronunc, source, dest):
|
||||
@@ -4569,7 +4570,7 @@ class MacBritish_System_Lexicon(object):
|
||||
so you can substitute these into your texts.
|
||||
Restores the lexicon on close()."""
|
||||
|
||||
instances = {}
|
||||
instances = {} # type: ignore
|
||||
|
||||
def __init__(self, text="", voice="Daniel"):
|
||||
"""text is the text you want to speak (so that any
|
||||
|
||||
+1
-1
@@ -565,7 +565,7 @@ class HomeAssistantSTTIntegration(RhasspyActor):
|
||||
audio_data = audio_data[self.chunk_size :]
|
||||
|
||||
# POST WAV data to STT
|
||||
response = requests.post(stt_url, data=generate_chunks(), **kwargs)
|
||||
response = requests.post(stt_url, data=generate_chunks(), **kwargs) # type: ignore
|
||||
response.raise_for_status()
|
||||
|
||||
response_json = response.json()
|
||||
|
||||
@@ -459,7 +459,7 @@ def train_profile(profile_dir: Path, profile: Profile) -> Tuple[int, List[str]]:
|
||||
# This better thing to do would be to create a custom TaskLoader.
|
||||
import inspect
|
||||
|
||||
inspect.getsourcelines = lambda obj: [0, 0]
|
||||
inspect.getsourcelines = lambda obj: [0, 0] # type: ignore
|
||||
|
||||
# Run doit main
|
||||
result = DoitMain(ModuleTaskLoader(locals())).run(sys.argv[1:])
|
||||
|
||||
@@ -717,6 +717,7 @@ class GoogleWaveNetSentenceSpeaker(RhasspyActor):
|
||||
self.sample_rate,
|
||||
)
|
||||
|
||||
# pylint: disable=E0401
|
||||
from google.cloud import texttospeech
|
||||
|
||||
client = texttospeech.TextToSpeechClient()
|
||||
|
||||
Reference in New Issue
Block a user