Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ bump-utils: # Bump notifications-utils package to latest version
lint: ## Run static analysis
ruff check .
ruff format --check .
mypy

.PHONY: test
test: lint ## Run tests
Expand Down
4 changes: 4 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[mypy]
files = notifications_python_client
follow_untyped_imports = true
check_untyped_defs = true
2 changes: 1 addition & 1 deletion notifications_python_client/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def __init__(self):


class APIError(Exception):
def __init__(self, response: Response = None, message: str = None):
def __init__(self, response: Union[Response, None] = None, message: Union[str, None] = None): # noqa: UP007 – Python <3.10 compatibility
self.response = response
self._message = message

Expand Down
12 changes: 8 additions & 4 deletions notifications_python_client/notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,10 @@ def get_received_texts_iterator(self, older_than=None):
while received_texts:
yield from received_texts
next_link = result["links"].get("next")
received_text_id = re.search("[0-F]{8}-[0-F]{4}-[0-F]{4}-[0-F]{4}-[0-F]{12}", next_link, re.I).group(0)
result = self.get_received_texts(older_than=received_text_id)
received_text_id = re.search("[0-F]{8}-[0-F]{4}-[0-F]{4}-[0-F]{4}-[0-F]{12}", next_link, re.I)
if not received_text_id:
break
result = self.get_received_texts(older_than=received_text_id.group(0))
received_texts = result.get("received_text_messages")

def get_notification_by_id(self, id):
Expand Down Expand Up @@ -112,8 +114,10 @@ def get_all_notifications_iterator(self, status=None, template_type=None, refere
while notifications:
yield from notifications
next_link = result["links"].get("next")
notification_id = re.search("[0-F]{8}-[0-F]{4}-[0-F]{4}-[0-F]{4}-[0-F]{12}", next_link, re.I).group(0)
result = self.get_all_notifications(status, template_type, reference, notification_id)
notification_id_match = re.search("[0-F]{8}-[0-F]{4}-[0-F]{4}-[0-F]{4}-[0-F]{12}", next_link, re.I)
if not notification_id_match:
break
result = self.get_all_notifications(status, template_type, reference, notification_id_match.group(0))
notifications = result.get("notifications")

def post_template_preview(self, template_id, personalisation):
Expand Down
1 change: 1 addition & 0 deletions requirements_for_test.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
-r requirements_for_test_common.in

jsonschema>=2.5.1
mypy
266 changes: 264 additions & 2 deletions requirements_for_test.txt

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ deps=
.
-r requirements_for_test.in
commands =
make lint
make test
make integration-test

Expand Down
Loading