Skip to content

Commit

Permalink
Set return type to None from NoReturn
Browse files Browse the repository at this point in the history
Use gitverse for generating release notes
Upgrade to latest flake8 and isort
Release v2.1
  • Loading branch information
dormant-user committed Aug 31, 2023
1 parent 4774c82 commit 1c71a9b
Show file tree
Hide file tree
Showing 19 changed files with 82 additions and 387 deletions.
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
repos:
-
repo: https://github.com/pycqa/flake8
rev: '3.9.2'
repo: https://github.com/PyCQA/flake8
rev: '6.1.0'
hooks:
-
id: flake8
additional_dependencies:
- flake8-docstrings
- flake8-sfs
args: [--max-line-length=120, --extend-ignore=SFS3 D107 SFS301 D100 D104 D401 E731]
args: [--max-line-length=120, --extend-ignore=SFS3 D107 SFS301 D100 D104 D401 SFS101 SFS201]

-
repo: https://github.com/pre-commit/mirrors-isort
rev: 'v5.8.0'
repo: https://github.com/PyCQA/isort
rev: '5.12.0'
hooks:
-
id: isort
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ Clean code with pre-commit hooks: [`flake8`](https://flake8.pycqa.org/en/latest/
### [Release Notes](https://github.com/thevickypedia/Jarvis_UI/blob/main/release_notes.rst)
**Requirement**
```shell
python -m pip install changelog-generator
python -m pip install gitverse
```

**Usage**
```shell
changelog reverse -f release_notes.rst -t 'Release Notes'
gitverse-release reverse -f release_notes.rst -t 'Release Notes'
```

### Linting
Expand Down
4 changes: 2 additions & 2 deletions docs/README.html
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,11 @@ <h2>Coding Standards<a class="headerlink" href="#coding-standards" title="Permal
<section id="release-notes">
<h2><a class="reference external" href="https://github.com/thevickypedia/Jarvis_UI/blob/main/release_notes.rst">Release Notes</a><a class="headerlink" href="#release-notes" title="Permalink to this heading"></a></h2>
<p><strong>Requirement</strong></p>
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>python<span class="w"> </span>-m<span class="w"> </span>pip<span class="w"> </span>install<span class="w"> </span>changelog-generator
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>python<span class="w"> </span>-m<span class="w"> </span>pip<span class="w"> </span>install<span class="w"> </span>gitverse
</pre></div>
</div>
<p><strong>Usage</strong></p>
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>changelog<span class="w"> </span>reverse<span class="w"> </span>-f<span class="w"> </span>release_notes.rst<span class="w"> </span>-t<span class="w"> </span><span class="s1">&#39;Release Notes&#39;</span>
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></span>gitverse-release<span class="w"> </span>reverse<span class="w"> </span>-f<span class="w"> </span>release_notes.rst<span class="w"> </span>-t<span class="w"> </span><span class="s1">&#39;Release Notes&#39;</span>
</pre></div>
</div>
</section>
Expand Down
4 changes: 2 additions & 2 deletions docs/_sources/README.md.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ Clean code with pre-commit hooks: [`flake8`](https://flake8.pycqa.org/en/latest/
### [Release Notes](https://github.com/thevickypedia/Jarvis_UI/blob/main/release_notes.rst)
**Requirement**
```shell
python -m pip install changelog-generator
python -m pip install gitverse
```

**Usage**
```shell
changelog reverse -f release_notes.rst -t 'Release Notes'
gitverse-release reverse -f release_notes.rst -t 'Release Notes'
```

### Linting
Expand Down
1 change: 1 addition & 0 deletions docs/_static/pygments.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ span.linenos.special { color: #000000; background-color: #ffffc0; padding-left:
.highlight .cs { color: #408090; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #A00000 } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */
.highlight .gr { color: #FF0000 } /* Generic.Error */
.highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */
.highlight .gi { color: #00A000 } /* Generic.Inserted */
Expand Down
2 changes: 2 additions & 0 deletions docs/genindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ <h2 id="A">A</h2>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="index.html#jarvis_ui.executables.starter.Activator">Activator (class in jarvis_ui.executables.starter)</a>
</li>
<li><a href="index.html#jarvis_ui.executables.starter.Activator.at_exit">at_exit() (jarvis_ui.executables.starter.Activator method)</a>
</li>
</ul></td>
</tr></table>
Expand Down
38 changes: 26 additions & 12 deletions docs/index.html

Large diffs are not rendered by default.

Binary file modified docs/objects.inv
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/searchindex.js

Large diffs are not rendered by default.

11 changes: 1 addition & 10 deletions gen_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,7 @@
# 'set -e' stops the execution of a script if a command or pipeline has an error.
# This is the opposite of the default shell behaviour, which is to ignore errors in scripts.
set -e

branch="$(git rev-parse --abbrev-ref HEAD)"
checker=$(git diff --name-only `git merge-base $branch HEAD`)
if [[ ! $checker =~ "release_notes.rst" ]]; then
echo -e "\n********************************************************************ERROR**********************************************************"
echo "Docs generation was ABORTED since release notes was not updated!! Changelog generator requires the release notes to be in sync."
echo -e "***********************************************************************************************************************************\n"
exit 255
fi

gitverse-release reverse -f release_notes.rst -t 'Release Notes'
rm -rf docs
mkdir docs
mkdir -p doc_generator/_static # creates a _static folder if unavailable
Expand Down
6 changes: 3 additions & 3 deletions jarvis_ui/executables/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

import os
import sys
from typing import Any, NoReturn
from typing import Any

from jarvis_ui.modules import models


def write_screen(text: Any) -> NoReturn:
def write_screen(text: Any) -> None:
"""Write text to a screen that can be cleared later.
Args:
Expand All @@ -22,7 +22,7 @@ def write_screen(text: Any) -> NoReturn:
sys.stdout.write(f"\r{text}")


def flush_screen() -> NoReturn:
def flush_screen() -> None:
"""Flushes the screen output.
See Also:
Expand Down
5 changes: 2 additions & 3 deletions jarvis_ui/executables/helper.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import os
import sys
from multiprocessing.managers import DictProxy # noqa
from typing import NoReturn

import requests

Expand All @@ -11,7 +10,7 @@
FAILED_HEALTH_CHECK = {'count': 0}


def linux_restart() -> NoReturn:
def linux_restart() -> None:
"""Restarts the base script on Linux OS.
See Also:
Expand All @@ -26,7 +25,7 @@ def linux_restart() -> NoReturn:
raise KeyboardInterrupt


def heart_beat(status_manager: DictProxy = None) -> NoReturn:
def heart_beat(status_manager: DictProxy = None) -> None:
"""Initiate health check with the server.
Args:
Expand Down
4 changes: 1 addition & 3 deletions jarvis_ui/executables/speaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@
"""

from typing import NoReturn

from jarvis_ui.modules.models import audio_driver


def speak(text: str) -> NoReturn:
def speak(text: str) -> None:
"""Speak the received text using audio driver.
Args:
Expand Down
8 changes: 4 additions & 4 deletions jarvis_ui/executables/starter.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def process_request(phrase: str) -> Union[str, NoReturn]:
return "RESTART"


def process_response(response: Union[dict, bool]) -> NoReturn:
def process_response(response: Union[dict, bool]) -> None:
"""Processes response from the server.
Args:
Expand Down Expand Up @@ -98,7 +98,7 @@ def process_response(response: Union[dict, bool]) -> NoReturn:
speaker.speak(text=response)


def processor(phrase: str = None, status_manager: DictProxy = None) -> NoReturn:
def processor(phrase: str = None, status_manager: DictProxy = None) -> None:
"""Handles request and response.
Args:
Expand Down Expand Up @@ -158,7 +158,7 @@ def __init__(self):
zip(env.wake_words, env.sensitivity)])
self.label = f"Awaiting: [{label}]"

def __del__(self) -> NoReturn:
def at_exit(self) -> None:
"""Invoked when the run loop is exited or manual interrupt.
See Also:
Expand Down Expand Up @@ -206,7 +206,7 @@ def executor(self, status_manager: DictProxy = None):
self.audio_stream = self.open_stream()
display.write_screen(self.label)

def start(self, status_manager: DictProxy = None) -> NoReturn:
def start(self, status_manager: DictProxy = None) -> None:
"""Runs ``audio_stream`` in a forever loop and calls ``initiator`` when the phrase ``Jarvis`` is heard."""
logger.info("Starting wake word detector with sensitivity: %s", env.sensitivity)
if os.path.isfile("failed_command"):
Expand Down
13 changes: 7 additions & 6 deletions jarvis_ui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
import time
from multiprocessing import Manager, Process
from multiprocessing.managers import DictProxy # noqa
from typing import NoReturn

from jarvis_ui.modules.logger import logger


def initiator(status_manager: DictProxy = None) -> NoReturn:
def initiator(status_manager: DictProxy = None) -> None:
"""Starts main process to activate Jarvis and process requests via API calls."""
from jarvis_ui.executables.helper import heart_beat
from jarvis_ui.executables.starter import Activator
Expand All @@ -19,17 +18,19 @@ def initiator(status_manager: DictProxy = None) -> NoReturn:
timer.start()
else:
timer = None
activator = Activator()
try:
if status_manager:
status_manager["LOCKED"] = False
Activator().start(status_manager=status_manager)
activator.start(status_manager=status_manager)
except KeyboardInterrupt:
if timer:
timer.stop()
return
finally:
activator.at_exit()


def terminator(process: Process) -> NoReturn:
def terminator(process: Process) -> None:
"""Terminates the process.
Args:
Expand All @@ -49,7 +50,7 @@ def terminator(process: Process) -> NoReturn:
logger.error(error)


def start() -> NoReturn:
def start() -> None:
"""Initiates Jarvis as a child process."""
# Import within a function to be called repeatedly
from jarvis_ui.modules.models import env, settings # noqa: F401
Expand Down
4 changes: 2 additions & 2 deletions jarvis_ui/modules/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import platform
import warnings
from multiprocessing import current_process
from typing import Callable, List, NoReturn
from typing import Callable, List

import pvporcupine
from pydantic import BaseConfig, PositiveInt
Expand All @@ -21,7 +21,7 @@
add_ss_extn: Callable = lambda filepath: os.path.splitext(filepath)[0] + "_ss" + os.path.splitext(filepath)[1]


def swapper() -> NoReturn:
def swapper() -> None:
"""Swaps any request URL with the public URL if returned by Jarvis.
Notes:
Expand Down
4 changes: 2 additions & 2 deletions jarvis_ui/modules/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import ctypes
from contextlib import contextmanager
from typing import ByteString, Iterable, NoReturn
from typing import ByteString, Iterable

ALSA_ERROR_HANDLER = ctypes.CFUNCTYPE(None,
ctypes.c_char_p,
Expand All @@ -11,7 +11,7 @@


# noinspection PyUnusedLocal
def py_error_handler(filename: ByteString, line: int, function: ByteString, err: int, fmt: ByteString) -> NoReturn:
def py_error_handler(filename: ByteString, line: int, function: ByteString, err: int, fmt: ByteString) -> None:
"""Handles errors from pyaudio module especially for Linux based operating systems."""
pass

Expand Down
4 changes: 2 additions & 2 deletions jarvis_ui/modules/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from enum import Enum
from multiprocessing import current_process
from threading import Thread
from typing import Dict, List, NoReturn, Union
from typing import Dict, List, Union

import pyttsx3
from packaging.version import parse as parser
Expand Down Expand Up @@ -63,7 +63,7 @@ class Settings(BaseSettings):
settings.operating_system = "Windows"


def import_module() -> NoReturn:
def import_module() -> None:
"""Instantiates pyttsx3 after importing ``nsss`` drivers beforehand."""
if settings.operating_system == "Darwin":
importlib.import_module("pyttsx3.drivers.nsss")
Expand Down
Loading

0 comments on commit 1c71a9b

Please sign in to comment.