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
Bump version
  • Loading branch information
dormant-user committed Aug 31, 2023
1 parent fd2de73 commit 2f60c68
Show file tree
Hide file tree
Showing 14 changed files with 89 additions and 286 deletions.
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
repos:
-
repo: https://gitlab.com/pycqa/flake8
rev: '3.9.2'
repo: https://github.com/PyCQA/flake8
rev: '6.1.0'
hooks:
-
id: flake8
Expand All @@ -11,8 +11,8 @@ repos:
args: [--max-line-length=120, --extend-ignore=SFS3 D107 SFS301 D100 D104 D401 SFS101]

-
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
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,15 +182,15 @@ pip install sphinx==5.1.1 pre-commit==2.20.0 recommonmark==0.7.1
pre-commit run --all-files
```

### Change Log
### [Release Notes](https://github.com/thevickypedia/gmail-connector/blob/master/release_notes.rst)
**Requirement**
```shell
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'
```

### Pypi Module
Expand Down
10 changes: 5 additions & 5 deletions docs/README.html
Original file line number Diff line number Diff line change
Expand Up @@ -226,14 +226,14 @@ <h3>Linting<a class="headerlink" href="#linting" title="Permalink to this headin
</pre></div>
</div>
</section>
<section id="change-log">
<h3>Change Log<a class="headerlink" href="#change-log" title="Permalink to this heading"></a></h3>
<section id="release-notes">
<h3><a class="reference external" href="https://github.com/thevickypedia/gmail-connector/blob/master/release_notes.rst">Release Notes</a><a class="headerlink" href="#release-notes" title="Permalink to this heading"></a></h3>
<p><strong>Requirement</strong></p>
<div class="highlight-shell notranslate"><div class="highlight"><pre><span></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 Expand Up @@ -281,7 +281,7 @@ <h3><a href="index.html">Table of Contents</a></h3>
</li>
<li><a class="reference internal" href="#read-email">Read Email</a></li>
<li><a class="reference internal" href="#linting">Linting</a></li>
<li><a class="reference internal" href="#change-log">Change Log</a></li>
<li><a class="reference internal" href="#release-notes">Release Notes</a></li>
<li><a class="reference internal" href="#pypi-module">Pypi Module</a></li>
<li><a class="reference internal" href="#runbook">Runbook</a></li>
<li><a class="reference internal" href="#repository">Repository</a></li>
Expand Down
6 changes: 3 additions & 3 deletions docs/_sources/README.md.txt
Original file line number Diff line number Diff line change
Expand Up @@ -182,15 +182,15 @@ pip install sphinx==5.1.1 pre-commit==2.20.0 recommonmark==0.7.1
pre-commit run --all-files
```

### Change Log
### [Release Notes](https://github.com/thevickypedia/gmail-connector/blob/master/release_notes.rst)
**Requirement**
```shell
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'
```

### Pypi Module
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
28 changes: 14 additions & 14 deletions docs/index.html

Large diffs are not rendered by default.

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 gmailconnector/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Place holder for package."""

import os
from typing import NoReturn, Union
from typing import Union

import dotenv

Expand All @@ -15,10 +15,10 @@
from .validator.address import EmailAddress # noqa: F401
from .validator.validate_email import validate_email # noqa: F401

version = "0.9"
version = "0.9.1"


def load_env(filename: Union[str, os.PathLike] = ".env", scan: bool = False) -> NoReturn:
def load_env(filename: Union[str, os.PathLike] = ".env", scan: bool = False) -> None:
"""Load .env files."""
if scan:
for file in os.listdir():
Expand Down
4 changes: 2 additions & 2 deletions gmailconnector/read_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from collections.abc import Generator
from datetime import datetime, timedelta, timezone
from email.header import decode_header, make_header
from typing import Iterable, NoReturn, Union
from typing import Iterable, Union

import pytz

Expand Down Expand Up @@ -49,7 +49,7 @@ def __init__(self, gmail_user: str = None, gmail_pass: str = None, folder: Folde
self._authenticated = False
self.create_ssl_connection(gmail_host=gmail_host, timeout=timeout)

def create_ssl_connection(self, gmail_host: str, timeout: Union[int, float]) -> NoReturn:
def create_ssl_connection(self, gmail_host: str, timeout: Union[int, float]) -> None:
"""Creates an SSL connection to gmail's SSL server."""
try:
self.mail = imaplib.IMAP4_SSL(host=gmail_host, port=993, timeout=timeout)
Expand Down
6 changes: 3 additions & 3 deletions gmailconnector/send_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from email.mime.application import MIMEApplication
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from typing import Dict, NoReturn, Union
from typing import Dict, Union

from .models.config import Encryption
from .models.responder import Response
Expand Down Expand Up @@ -58,14 +58,14 @@ def __init__(self, gmail_user: str = None, gmail_pass: str = None, timeout: Unio
else:
self.create_ssl_connection(host=gmail_host, timeout=timeout)

def create_ssl_connection(self, host: str, timeout: Union[int, float]) -> NoReturn:
def create_ssl_connection(self, host: str, timeout: Union[int, float]) -> None:
"""Create a connection using SSL encryption."""
try:
self.server = smtplib.SMTP_SSL(host=host, port=465, timeout=timeout)
except (smtplib.SMTPException, socket.error) as error:
self.error = error.__str__()

def create_tls_connection(self, host: str, timeout: Union[int, float]) -> NoReturn:
def create_tls_connection(self, host: str, timeout: Union[int, float]) -> None:
"""Create a connection using TLS encryption."""
try:
self.server = smtplib.SMTP(host=host, port=587, timeout=timeout)
Expand Down
8 changes: 4 additions & 4 deletions gmailconnector/send_sms.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import smtplib
import socket
from typing import NoReturn, Union
from typing import Union

from .models.config import Encryption, SMSGateway
from .models.responder import Response
Expand Down Expand Up @@ -46,14 +46,14 @@ def __init__(self, gmail_user: str = None, gmail_pass: str = None, timeout: Unio
else:
self.create_ssl_connection(host=gmail_host, timeout=timeout)

def create_ssl_connection(self, host: str, timeout: Union[int, float]) -> NoReturn:
def create_ssl_connection(self, host: str, timeout: Union[int, float]) -> None:
"""Create a connection using SSL encryption."""
try:
self.server = smtplib.SMTP_SSL(host=host, port=465, timeout=timeout)
except (smtplib.SMTPException, socket.error) as error:
self.error = error.__str__()

def create_tls_connection(self, host: str, timeout: Union[int, float]) -> NoReturn:
def create_tls_connection(self, host: str, timeout: Union[int, float]) -> None:
"""Create a connection using TLS encryption."""
try:
self.server = smtplib.SMTP(host=host, port=587, timeout=timeout)
Expand Down Expand Up @@ -102,7 +102,7 @@ def __del__(self):
self.server.close()

@staticmethod
def validate_phone(phone: str) -> NoReturn:
def validate_phone(phone: str) -> None:
"""Validates all the arguments passed during object initialization.
Args:
Expand Down
4 changes: 2 additions & 2 deletions gmailconnector/sms_deleter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import imaplib
from concurrent.futures import ThreadPoolExecutor
from email.header import decode_header, make_header
from typing import Dict, NoReturn, Union
from typing import Dict, Union


class DeleteSent:
Expand All @@ -23,7 +23,7 @@ def __init__(self, **kwargs):
self.error = None
self.create_ssl_connection()

def create_ssl_connection(self) -> NoReturn:
def create_ssl_connection(self) -> None:
"""Create a connection using SSL encryption."""
try:
self.mail = imaplib.IMAP4_SSL('imap.gmail.com')
Expand Down
Loading

0 comments on commit 2f60c68

Please sign in to comment.