Skip to content

Commit

Permalink
Remove unwanted config objects
Browse files Browse the repository at this point in the history
Remove object level phone number declaration
Release `v1.0.2`
  • Loading branch information
dormant-user committed Jun 5, 2024
1 parent fe8b920 commit 60d998a
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 50 deletions.
13 changes: 10 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,24 @@ repos:
- id: requirements-txt-fixer
- id: trailing-whitespace

- repo: https://github.com/PyCQA/isort
rev: 5.12.0
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: isort
- id: black
exclude: doc_generator/

- repo: https://github.com/PyCQA/flake8
rev: 7.0.0
hooks:
- id: flake8
args: [-j8, '--ignore=F401,W503,E203,E501,F821,E306,E722,N812']

- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
args: [--profile, black]

- repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt
rev: 0.2.3
hooks:
Expand Down
13 changes: 1 addition & 12 deletions docs/genindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ <h1 id="index">Index</h1>
| <a href="#M"><strong>M</strong></a>
| <a href="#N"><strong>N</strong></a>
| <a href="#O"><strong>O</strong></a>
| <a href="#P"><strong>P</strong></a>
| <a href="#R"><strong>R</strong></a>
| <a href="#S"><strong>S</strong></a>
| <a href="#T"><strong>T</strong></a>
Expand Down Expand Up @@ -413,24 +412,14 @@ <h2 id="O">O</h2>
</ul></td>
</tr></table>

<h2 id="P">P</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="index.html#gmailconnector.models.config.EgressConfig.phone">phone (gmailconnector.models.config.EgressConfig attribute)</a>
</li>
</ul></td>
</tr></table>

<h2 id="R">R</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="index.html#gmailconnector.read_email.ReadEmail.read_mail">read_mail() (gmailconnector.read_email.ReadEmail method)</a>
</li>
<li><a href="index.html#gmailconnector.read_email.ReadEmail">ReadEmail (class in gmailconnector.read_email)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="index.html#gmailconnector.models.config.EgressConfig.recipient">recipient (gmailconnector.models.config.EgressConfig attribute)</a>
<li><a href="index.html#gmailconnector.read_email.ReadEmail">ReadEmail (class in gmailconnector.read_email)</a>
</li>
<li><a href="index.html#gmailconnector.models.responder.Response">Response (class in gmailconnector.models.responder)</a>
</li>
Expand Down
28 changes: 9 additions & 19 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.

2 changes: 1 addition & 1 deletion gmailconnector/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
from .validator.address import EmailAddress # noqa: F401
from .validator.validate_email import validate_email # noqa: F401

version = "1.0.1"
version = "1.0.2"
2 changes: 0 additions & 2 deletions gmailconnector/models/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ class EgressConfig(BaseSettings):

gmail_user: EmailStr
gmail_pass: str
recipient: Union[EmailStr, None] = None
phone: Union[str, None] = Field(None, pattern="\\d{10}$")
gmail_host: str = "smtp.gmail.com"
encryption: Encryption = Encryption.TLS
timeout: int = 10
Expand Down
8 changes: 6 additions & 2 deletions gmailconnector/send_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,16 @@ def send_email(
attachments = (
[attachment]
if isinstance(attachment, str)
else attachment if attachment else []
else attachment
if attachment
else []
)
filenames = (
[filename]
if isinstance(filename, str)
else filename if filename else []
else filename
if filename
else []
)

msg = self.multipart_message(
Expand Down
11 changes: 3 additions & 8 deletions gmailconnector/send_sms.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,19 +123,14 @@ def send_sms(
Response:
A custom response object with properties: ok, status and body to the user.
"""
if phone:
self.env.phone = phone
self.env = EgressConfig(**self.env.__dict__)
elif not self.env.phone:
raise ValueError(
'\n\tcannot proceed without phone number'
)
if not all((phone, len(phone) == 10)):
raise ValueError("\n\tcannot proceed without a valid phone number")
if not sms_gateway:
sms_gateway = SMSGateway.tmobile
if not country_code:
country_code = "+1"
if COUNTRY_CODE.match(country_code):
to = country_code + self.env.phone + "@" + sms_gateway
to = country_code + phone + "@" + sms_gateway
else:
raise ValueError(
f"\n\tcountry code should match the pattern {COUNTRY_CODE.pattern}"
Expand Down
8 changes: 6 additions & 2 deletions gmailconnector/validator/validate_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@
from ..models.responder import Response
from .address import EmailAddress
from .domain import get_mx_records
from .exceptions import (AddressFormatError, InvalidDomain, NotMailServer,
UnresponsiveMailServer)
from .exceptions import (
AddressFormatError,
InvalidDomain,
NotMailServer,
UnresponsiveMailServer,
)

formatter = logging.Formatter(fmt="%(levelname)s\t %(message)s")

Expand Down
5 changes: 5 additions & 0 deletions release_notes.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Release Notes
=============

v1.0.2 (06/05/2024)
-------------------
- Removes complexity with phone number validation
- Improved code readability

v1.0.1 (05/26/2024)
-------------------
- Includes a retry logic for occasional errors while sending emails
Expand Down

0 comments on commit 60d998a

Please sign in to comment.