Make mypy happy

This commit is contained in:
Mikkel Munch Mortensen 2021-11-04 12:38:03 +01:00
parent b414aac902
commit 5401e59fb5

View file

@ -22,7 +22,7 @@ import getopt
import json import json
import re import re
from urllib import error, parse, request from urllib import error, parse, request
from typing import Any, Tuple from typing import Any, Dict, Tuple
class Gateway: class Gateway:
@ -32,7 +32,7 @@ class Gateway:
Please look at the README for further description. Please look at the README for further description.
""" """
options: dict[str, Any] = {} options: Dict[str, Any] = {}
username: str username: str
password: str password: str
gateway_url: str = "https://api.cpsms.dk/v2/send" gateway_url: str = "https://api.cpsms.dk/v2/send"
@ -109,12 +109,14 @@ class Gateway:
# Raise error if recipient is not a number. # Raise error if recipient is not a number.
pattern = re.compile("^[1-9]+$") pattern = re.compile("^[1-9]+$")
if pattern.match(self.options["to"]) is None: if pattern.match(self.options["to"]) is None:
raise ValueError("Recipient number must be numbers only (no characters, spaces or +)") raise ValueError(
"Recipient number must be numbers only (no characters, spaces or +)"
)
# Prepare the data to send along. # Prepare the data to send along.
data = self.options options = self.options
data["flash"] = int(data["flash"]) options["flash"] = int(options["flash"])
data = json.dumps(data).encode() data = json.dumps(options).encode()
# Prepare authentication. # Prepare authentication.
auth_header = "{}:{}".format(self.username, self.password) auth_header = "{}:{}".format(self.username, self.password)