python-ntfy 0.10.5__tar.gz → 0.11.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-ntfy
3
- Version: 0.10.5
3
+ Version: 0.11.1
4
4
  Summary: An easy-to-use library for the ntfy notification service.
5
5
  Keywords: ntfy,notifications,push,http,api
6
6
  Author: Matthew Cane
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "python-ntfy"
3
- version = "0.10.5"
3
+ version = "0.11.1"
4
4
  description = "An easy-to-use library for the ntfy notification service."
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -130,13 +130,3 @@ disallow_untyped_defs = true
130
130
  [tool.ty.environment]
131
131
  root = ["."]
132
132
  python = "./.venv"
133
-
134
- [tool.uv-secure.vulnerability_criteria]
135
- show_severity = true
136
- ignore_unfixed = true
137
-
138
- [tool.uv-secure.maintainability_criteria]
139
- forbid_yanked = true
140
- forbid_archived = true
141
- forbid_deprecated = true
142
- forbid_quarantined = true
@@ -1,5 +1,5 @@
1
- class MessageSendError(Exception):
2
- """Exception raised when a message fails to send."""
1
+ class NtfyMessageError(Exception):
2
+ """Base exception for ntfy message errors."""
3
3
 
4
4
  def __init__(self, message: str) -> None:
5
5
  """Initialize the exception.
@@ -9,3 +9,11 @@ class MessageSendError(Exception):
9
9
  """
10
10
  self.message = message
11
11
  super().__init__(self.message)
12
+
13
+
14
+ class MessageSendError(NtfyMessageError):
15
+ """Exception raised when a message fails to send."""
16
+
17
+
18
+ class MessageReceiveError(NtfyMessageError):
19
+ """Exception raised when a message fails to retrieved."""
@@ -2,6 +2,8 @@ import json
2
2
 
3
3
  import requests
4
4
 
5
+ from python_ntfy._exceptions import MessageReceiveError
6
+
5
7
 
6
8
  def get_cached_messages(
7
9
  self,
@@ -19,6 +21,9 @@ def get_cached_messages(
19
21
  Returns:
20
22
  A list of messages.
21
23
 
24
+ Raises:
25
+ MessageReceiveError: If the request fails or the response is invalid.
26
+
22
27
  Examples:
23
28
  >>> response = client.get(since="all")
24
29
 
@@ -34,16 +39,18 @@ def get_cached_messages(
34
39
  if since:
35
40
  params.update({"since": since})
36
41
 
37
- response = [
38
- json.loads(line)
39
- for line in requests.get(
42
+ try:
43
+ response = requests.get(
40
44
  url=self.url + "/json",
41
45
  params=params,
42
46
  auth=self._auth,
43
47
  timeout=timeout_seconds,
44
48
  )
45
- .text.strip()
46
- .splitlines()
47
- ]
49
+ response.raise_for_status()
50
+ messages = [json.loads(line) for line in response.text.strip().splitlines()]
51
+ except requests.exceptions.RequestException as e:
52
+ error_message = f"Failed to receive messages: {e}"
53
+ raise MessageReceiveError(error_message) from e
54
+
48
55
  # Reverse the list so that the most recent notification is first
49
- return sorted(response, key=lambda x: x["time"], reverse=True)
56
+ return sorted(messages, key=lambda x: x["time"], reverse=True)
File without changes